|
|
@@ -5,14 +5,16 @@ import os
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
from sqlalchemy import select
|
|
|
from app.core.config import settings
|
|
|
+from app.core.biz_exception import NotFoundError
|
|
|
from app.schemas.llm import ParseUserInputsPayload, ParseUserInputsOut
|
|
|
from app.models.schema import VasSchema
|
|
|
|
|
|
# --- 配置区 ---
|
|
|
# 请换成你新生成的 API Key
|
|
|
API_KEY = settings.openai_api_key
|
|
|
-API_URL = "https://api.openai.com/v1/chat/completions"
|
|
|
|
|
|
+# API_URL = "https://api.openai.com/v1/chat/completions"
|
|
|
+API_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
|
|
|
|
|
|
class LlmService:
|
|
|
|
|
|
@@ -49,7 +51,8 @@ class LlmService:
|
|
|
"""
|
|
|
|
|
|
payload = {
|
|
|
- "model": "gpt-4o", # 或 gpt-3.5-turbo
|
|
|
+ # "model": "gpt-4o", # 或 gpt-3.5-turbo
|
|
|
+ "model": "qwen-plus",
|
|
|
"messages": [
|
|
|
{"role": "system", "content": system_instruction},
|
|
|
{"role": "user", "content": user_prompt}
|
|
|
@@ -91,5 +94,5 @@ if __name__ == "__main__":
|
|
|
user_input = "我是张三,打算花2000块钱买个耳机和键盘。"
|
|
|
|
|
|
print("正在解析...")
|
|
|
- result = parse_data_api(user_input, my_schema)
|
|
|
+ result = LlmService.parse_data_async(user_input, my_schema)
|
|
|
print(json.dumps(result, ensure_ascii=False, indent=2))
|