From 2cfc960bc34177a03094fbf98a50511bece46c0a Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 25 Jul 2025 16:11:48 +0800 Subject: [PATCH] . --- meta_ui.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meta_ui.py b/meta_ui.py index 872ed9c..cf9b8da 100644 --- a/meta_ui.py +++ b/meta_ui.py @@ -19,7 +19,7 @@ def chat(user_message, history, max_tokens, temperature): } payload = { "model": MODEL_NAME, - "prompt": prompt, + "text": prompt, # ✅ 注意是 text,不是 prompt "max_tokens": max_tokens, "temperature": temperature } @@ -27,7 +27,7 @@ def chat(user_message, history, max_tokens, temperature): try: response = requests.post(API_URL, headers=headers, json=payload, timeout=30) result = response.json() - reply = result["text"].strip() # ✅ /generate 接口返回字段是 text + reply = result["text"].strip() # ✅ generate 接口返回字段是 text except Exception as e: reply = f"[请求失败] {e}" @@ -41,14 +41,14 @@ def test_api_connection(max_tokens, temperature): } payload = { "model": MODEL_NAME, - "prompt": "Ping?", + "text": "Ping?", # ✅ 也改成 text 字段 "max_tokens": max_tokens, "temperature": temperature } try: resp = requests.post(API_URL, headers=headers, json=payload, timeout=10) - out = resp.json()["text"].strip() # ✅ 修改这里 + out = resp.json()["text"].strip() return f"✅ API 可用,响应: {out}" except Exception as e: return f"❌ API 请求失败: {e}"