mirror of
https://github.com/Usagi-org/ai-goofish-monitor.git
synced 2025-11-25 11:29:41 +08:00
Merge pull request #203 from just-ads/master
fix: 显式禁用AI思考模式(qwen),修复后端容器测试失败
This commit is contained in:
@@ -534,6 +534,7 @@ async def get_ai_analysis(product_data, image_paths=None, prompt_text=""):
|
||||
response_format={"type": "json_object"},
|
||||
temperature=current_temperature,
|
||||
max_tokens=4000,
|
||||
extra_body={"enable_thinking": False}
|
||||
)
|
||||
|
||||
ai_response_content = response.choices[0].message.content
|
||||
|
||||
@@ -62,6 +62,7 @@ async def generate_criteria(user_description: str, reference_file_path: str) ->
|
||||
model=MODEL_NAME,
|
||||
messages=[{"role": "user", "content": prompt}],
|
||||
temperature=0.5, # Lower temperature for more predictable structure
|
||||
extra_body={"enable_thinking": False}
|
||||
)
|
||||
generated_text = response.choices[0].message.content
|
||||
print("AI已成功生成内容。")
|
||||
|
||||
@@ -1342,9 +1342,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
closeModalBtn.addEventListener('click', closeModal);
|
||||
cancelBtn.addEventListener('click', closeModal);
|
||||
modal.addEventListener('click', (event) => {
|
||||
|
||||
let canClose = false;
|
||||
modal.addEventListener('mousedown', event => {
|
||||
canClose = event.target === modal;
|
||||
});
|
||||
modal.addEventListener('mouseup', (event) => {
|
||||
// Close if clicked on the overlay background
|
||||
if (event.target === modal) {
|
||||
if (canClose && event.target === modal) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1080,15 +1080,19 @@ async def test_ai_settings(settings: dict, username: str = Depends(verify_creden
|
||||
if proxy_url:
|
||||
client_params["http_client"] = httpx.Client(proxy=proxy_url)
|
||||
|
||||
mode_name = settings.get("OPENAI_MODEL_NAME", "")
|
||||
print(f"LOG: 后端容器AI测试 BASE_URL: {client_params['base_url']}, MODEL_NAME: {mode_name}, PROXY_URL: {proxy_url}")
|
||||
|
||||
client = OpenAI(**client_params)
|
||||
|
||||
# 测试连接
|
||||
response = client.chat.completions.create(
|
||||
model=settings.get("OPENAI_MODEL_NAME", ""),
|
||||
model=mode_name,
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello, this is a test message to verify the connection."}
|
||||
],
|
||||
max_tokens=10
|
||||
max_tokens=10,
|
||||
extra_body={"enable_thinking": False}
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -1109,7 +1113,7 @@ async def test_ai_settings_backend(username: str = Depends(verify_credentials)):
|
||||
测试AI模型设置是否有效(从后端容器内发起)。
|
||||
"""
|
||||
try:
|
||||
from src.config import client, MODEL_NAME
|
||||
from src.config import client, BASE_URL, MODEL_NAME
|
||||
|
||||
# 使用与spider_v2.py相同的AI客户端配置
|
||||
if not client:
|
||||
@@ -1118,13 +1122,15 @@ async def test_ai_settings_backend(username: str = Depends(verify_credentials)):
|
||||
"message": "后端AI客户端未初始化,请检查.env配置文件中的AI设置。"
|
||||
}
|
||||
|
||||
print(f"LOG: 后端容器AI测试 BASE_URL: {BASE_URL}, MODEL_NAME: {MODEL_NAME}")
|
||||
# 测试连接
|
||||
response = client.chat.completions.create(
|
||||
response = await client.chat.completions.create(
|
||||
model=MODEL_NAME,
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello, this is a test message from backend container to verify connection."}
|
||||
],
|
||||
max_tokens=10
|
||||
max_tokens=10,
|
||||
extra_body={"enable_thinking": False}
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user