mirror of
https://github.com/QwenLM/Qwen.git
synced 2026-05-20 08:25:47 +08:00
@@ -25,15 +25,16 @@ for _ in range(10): # 网络不稳定,多试几次
|
||||
name, device_map="auto", trust_remote_code=True
|
||||
).eval()
|
||||
model.generation_config = generation_config
|
||||
model.generation_config.top_k = 1
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# 将一个插件的关键信息拼接成一段文本的模版。
|
||||
TOOL_DESC = """{name_for_model}: Call this tool to interact with the {name_for_human} API. What is the {name_for_human} API useful for? {description_for_model} Parameters: {parameters}"""
|
||||
|
||||
# ReAct prompting 的 instruction 模版,将包含插件的详细信息。
|
||||
PROMPT_REACT = """Answer the following questions as best you can. You have access to the following tools:
|
||||
PROMPT_REACT = """Answer the following questions as best you can. You have access to the following APIs:
|
||||
|
||||
{tools_text}
|
||||
|
||||
@@ -236,7 +237,7 @@ def test():
|
||||
},
|
||||
]
|
||||
history = []
|
||||
for query in ['你好', '查一下谁是周杰伦', '搜下他老婆是谁', '给我画个可爱的小猫吧,最好是黑猫']:
|
||||
for query in ['你好', '搜索一下谁是周杰伦', '再搜下他老婆是谁', '给我画个可爱的小猫吧,最好是黑猫']:
|
||||
print(f"User's Query:\n{query}\n")
|
||||
response, history = llm_with_plugin(prompt=query, history=history, list_of_plugin_info=tools)
|
||||
print(f"Qwen's Response:\n{response}\n")
|
||||
@@ -254,7 +255,7 @@ Thought: 提供的工具对回答该问题帮助较小,我将不使用工具
|
||||
Final Answer: 你好!很高兴见到你。有什么我可以帮忙的吗?
|
||||
|
||||
User's Query:
|
||||
查一下谁是周杰伦
|
||||
搜索一下谁是周杰伦
|
||||
|
||||
Qwen's Response:
|
||||
Thought: 我应该使用Google搜索查找相关信息。
|
||||
@@ -265,7 +266,7 @@ Thought: I now know the final answer.
|
||||
Final Answer: 周杰伦(Jay Chou)是一位来自台湾的歌手、词曲创作人、音乐制作人、说唱歌手、演员、电视节目主持人和企业家。他以其独特的音乐风格和才华在华语乐坛享有很高的声誉。
|
||||
|
||||
User's Query:
|
||||
搜下他老婆是谁
|
||||
再搜下他老婆是谁
|
||||
|
||||
Qwen's Response:
|
||||
Thought: 我应该使用Google搜索查找相关信息。
|
||||
|
||||
Reference in New Issue
Block a user