搜索api 换成 zhipu-search并提升agent 提示词
This commit is contained in:
parent
122033131b
commit
b577a3ad18
|
|
@ -116,7 +116,7 @@ def tavily_search(text, config, top_k):
|
||||||
|
|
||||||
def zhipu_search(text, config, top_k):
|
def zhipu_search(text, config, top_k):
|
||||||
api_key = config["zhipu_api_key"]
|
api_key = config["zhipu_api_key"]
|
||||||
endpoint = " https://open.bigmodel.cn/api/paas/v4/web_search"
|
endpoint = "https://open.bigmodel.cn/api/paas/v4/web_search"
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {api_key}",
|
"Authorization": f"Bearer {api_key}",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|
@ -185,7 +185,8 @@ def search_engine(query: str, top_k: int = 0, engine_name: str = "", config: dic
|
||||||
|
|
||||||
docs = [x for x in search_result2docs(results, engine_name, top_k) if x.page_content and x.page_content.strip()]
|
docs = [x for x in search_result2docs(results, engine_name, top_k) if x.page_content and x.page_content.strip()]
|
||||||
print(f"len(docs): {len(docs)}")
|
print(f"len(docs): {len(docs)}")
|
||||||
print(f"docs: {docs[:150]}")
|
# print(f"docs:{docs}")
|
||||||
|
# # print(f"docs: {docs[:150]}")
|
||||||
return {"docs": docs, "search_engine": engine_name}
|
return {"docs": docs, "search_engine": engine_name}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ class ToolSettings(BaseFileSettings):
|
||||||
|
|
||||||
search_internet: dict = {
|
search_internet: dict = {
|
||||||
"use": False,
|
"use": False,
|
||||||
"search_engine_name": "tavily",
|
"search_engine_name": "zhipu_search",
|
||||||
"search_engine_config": {
|
"search_engine_config": {
|
||||||
"bing": {
|
"bing": {
|
||||||
"bing_search_url": "https://api.bing.microsoft.com/v7.0/search",
|
"bing_search_url": "https://api.bing.microsoft.com/v7.0/search",
|
||||||
|
|
@ -513,9 +513,12 @@ class ToolSettings(BaseFileSettings):
|
||||||
"search_depth": "advanced",
|
"search_depth": "advanced",
|
||||||
"include_raw_content": True,
|
"include_raw_content": True,
|
||||||
"max_results": 1
|
"max_results": 1
|
||||||
|
},
|
||||||
|
"zhipu_search":{
|
||||||
|
"zhipu_api_key": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"top_k": 5,
|
"top_k": 1,
|
||||||
"verbose": "Origin",
|
"verbose": "Origin",
|
||||||
"conclude_prompt": "<指令>这是搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题,不得包含有重复的词汇或句子。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 "
|
"conclude_prompt": "<指令>这是搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题,不得包含有重复的词汇或句子。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 "
|
||||||
"</指令>\n<已知信息>{{ context }}</已知信息>\n"
|
"</指令>\n<已知信息>{{ context }}</已知信息>\n"
|
||||||
|
|
@ -748,6 +751,8 @@ class PromptSettings(BaseFileSettings):
|
||||||
"Begin!\n\n"
|
"Begin!\n\n"
|
||||||
"Question: {input}\n\n"
|
"Question: {input}\n\n"
|
||||||
"{agent_scratchpad}\n\n"
|
"{agent_scratchpad}\n\n"
|
||||||
|
"Important: After the last Observation, you must always add a Final Answer "
|
||||||
|
"summarizing the result. Do not skip this step."
|
||||||
),
|
),
|
||||||
"structured-chat-agent": (
|
"structured-chat-agent": (
|
||||||
"Respond to the human as helpfully and accurately as possible. You have access to the following tools:\n\n"
|
"Respond to the human as helpfully and accurately as possible. You have access to the following tools:\n\n"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue