diff --git a/libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py b/libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py index e7c3838..54cb26a 100644 --- a/libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py +++ b/libs/chatchat-server/chatchat/server/agent/tools_factory/search_internet.py @@ -116,7 +116,7 @@ def tavily_search(text, config, top_k): def zhipu_search(text, config, top_k): 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 = { "Authorization": f"Bearer {api_key}", "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()] 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} diff --git a/libs/chatchat-server/chatchat/settings.py b/libs/chatchat-server/chatchat/settings.py index 3d59e4b..d3b76d0 100644 --- a/libs/chatchat-server/chatchat/settings.py +++ b/libs/chatchat-server/chatchat/settings.py @@ -488,7 +488,7 @@ class ToolSettings(BaseFileSettings): search_internet: dict = { "use": False, - "search_engine_name": "tavily", + "search_engine_name": "zhipu_search", "search_engine_config": { "bing": { "bing_search_url": "https://api.bing.microsoft.com/v7.0/search", @@ -513,9 +513,12 @@ class ToolSettings(BaseFileSettings): "search_depth": "advanced", "include_raw_content": True, "max_results": 1 + }, + "zhipu_search":{ + "zhipu_api_key": "" } }, - "top_k": 5, + "top_k": 1, "verbose": "Origin", "conclude_prompt": "<指令>这是搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题,不得包含有重复的词汇或句子。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 " "\n<已知信息>{{ context }}\n" @@ -748,6 +751,8 @@ class PromptSettings(BaseFileSettings): "Begin!\n\n" "Question: {input}\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": ( "Respond to the human as helpfully and accurately as possible. You have access to the following tools:\n\n"