Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"GOOGLE_API_KEY": "", //谷歌API Key,用于川虎助理Pro模式
"WOLFRAM_ALPHA_APPID": "", //Wolfram Alpha API Key,用于川虎助理Pro模式,获取方式请看 https://products.wolframalpha.com/api/
"SERPAPI_API_KEY": "", //SerpAPI API Key,用于川虎助理Pro模式,获取方式请看 https://serpapi.com/
"TAVILY_API_KEY": "", //Tavily API Key,用于川虎助理Pro模式,获取方式请看 https://app.tavily.com

//== 文档处理与显示 ==
"latex_option": "default", // LaTeX 公式渲染策略,可选"default", "strict", "all"或者"disabled"
Expand Down
2 changes: 1 addition & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def load_config_to_environ(key_list):

default_chuanhu_assistant_model = config.get(
"default_chuanhu_assistant_model", "gpt-4-turbo-preview")
for x in ["GOOGLE_CSE_ID", "GOOGLE_API_KEY", "WOLFRAM_ALPHA_APPID", "SERPAPI_API_KEY"]:
for x in ["GOOGLE_CSE_ID", "GOOGLE_API_KEY", "WOLFRAM_ALPHA_APPID", "SERPAPI_API_KEY", "TAVILY_API_KEY"]:
if config.get(x, None) is not None:
os.environ[x] = config[x]

Expand Down
12 changes: 12 additions & 0 deletions modules/models/ChuanhuAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ def __init__(self, model_name, openai_api_key, user_name="") -> None:
logging.warning("SERPAPI_API_KEY not found, serpapi is disabled.")
self.tools += load_tools(tools_to_enable, llm=self.llm)

# if exists TAVILY_API_KEY, enable tavily search
if os.environ.get("TAVILY_API_KEY", None) is not None:
try:
from langchain_community.tools.tavily_search import TavilySearchResults
tavily_tool = TavilySearchResults(max_results=5)
self.tools.append(tavily_tool)
logging.info("Tavily search tool enabled.")
except Exception as e:
logging.warning(f"Failed to load Tavily search tool: {e}")
else:
logging.warning("TAVILY_API_KEY not found, tavily search is disabled.")

self.tools.append(
Tool.from_function(
func=self.summary_url,
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ python-docx
websocket_client
pydantic==2.5.2
google-search-results
tavily-python
anthropic==0.18.1
Pillow>=10.1.0
protobuf==3.20.3
Expand Down