更新
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""快速测试 AI API 连接是否可用"""
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from ai_config import AI_API_BASE, AI_API_KEY, AI_MODEL
|
||||
from ai_chat import call_ai_text
|
||||
|
||||
print(f"API 地址: {AI_API_BASE}")
|
||||
print(f"模型名称: {AI_MODEL}")
|
||||
print(f"API Key: {AI_API_KEY[:4]}****")
|
||||
|
||||
# 打印实际请求 URL(方便排查路径问题)
|
||||
from ai_chat import _completions_url
|
||||
print(f"请求 URL: {_completions_url()}")
|
||||
print("-" * 40)
|
||||
print("正在发送测试消息...")
|
||||
|
||||
try:
|
||||
reply = call_ai_text("你好")
|
||||
print(f"\n[+] AI 回复: {reply}")
|
||||
print("\n测试通过!AI 模型可以正常使用。")
|
||||
except Exception as e:
|
||||
print(f"\n[-] 测试失败: {e}")
|
||||
# 打印服务器返回的详细信息
|
||||
if hasattr(e, 'response') and e.response is not None:
|
||||
print(f"状态码: {e.response.status_code}")
|
||||
print(f"响应体: {e.response.text[:500]}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user