|
@@ -5,44 +5,6 @@ class QwenClient:
|
|
|
def __init__(self):
|
|
|
self.api_key = "sk-1022fe8e15ff4e0e9abc20541b281165"
|
|
|
|
|
|
- def chat(
|
|
|
- self,
|
|
|
- model="qwen3-max",
|
|
|
- system_prompt="You are a helpful assistant.",
|
|
|
- user_prompt="",
|
|
|
- ):
|
|
|
- """
|
|
|
- 普通聊天,不使用搜索功能
|
|
|
-
|
|
|
- Args:
|
|
|
- model: 模型名称,默认为qwen3-max
|
|
|
- system_prompt: 系统提示词
|
|
|
- user_prompt: 用户提示词
|
|
|
-
|
|
|
- Returns:
|
|
|
- str: AI回复内容
|
|
|
- """
|
|
|
- try:
|
|
|
- messages = [
|
|
|
- {"role": "system", "content": system_prompt},
|
|
|
- {"role": "user", "content": user_prompt},
|
|
|
- ]
|
|
|
-
|
|
|
- response = dashscope.Generation.call(
|
|
|
- api_key=self.api_key,
|
|
|
- model=model,
|
|
|
- messages=messages,
|
|
|
- result_format="message",
|
|
|
- )
|
|
|
-
|
|
|
- if response.status_code != 200:
|
|
|
- raise Exception(f"API调用失败: {response.message}")
|
|
|
-
|
|
|
- return response["output"]["choices"][0]["message"]["content"]
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- raise Exception(f"QwenClient chat失败: {str(e)}")
|
|
|
-
|
|
|
def search_and_chat(
|
|
|
self,
|
|
|
model="qwen3-max",
|