Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
dbe4a3e
1
Parent(s):
015435f
feat: 切换到川虎助理时可以显示启用了的工具
Browse files- modules/models/ChuanhuAgent.py +17 -1
- modules/models/models.py +1 -0
modules/models/ChuanhuAgent.py
CHANGED
@@ -63,7 +63,23 @@ class ChuanhuAgent_Client(BaseLLMModel):
|
|
63 |
self.index_summary = None
|
64 |
self.index = None
|
65 |
if "Pro" in self.model_name:
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
else:
|
68 |
self.tools = load_tools(["ddg-search", "llm-math", "arxiv", "wikipedia"], llm=self.llm)
|
69 |
self.tools.append(
|
|
|
63 |
self.index_summary = None
|
64 |
self.index = None
|
65 |
if "Pro" in self.model_name:
|
66 |
+
tools_to_enable = ["llm-math", "arxiv", "wikipedia"]
|
67 |
+
# if exists GOOGLE_CSE_ID and GOOGLE_API_KEY, enable google-search-results-json
|
68 |
+
if os.environ.get("GOOGLE_CSE_ID", None) is not None and os.environ.get("GOOGLE_API_KEY", None) is not None:
|
69 |
+
tools_to_enable.append("google-search-results-json")
|
70 |
+
else:
|
71 |
+
logging.warning("GOOGLE_CSE_ID and/or GOOGLE_API_KEY not found, google-search-results-json is disabled.")
|
72 |
+
# if exists WOLFRAM_ALPHA_APPID, enable wolfram-alpha
|
73 |
+
if os.environ.get("WOLFRAM_ALPHA_APPID", None) is not None:
|
74 |
+
tools_to_enable.append("wolfram-alpha")
|
75 |
+
else:
|
76 |
+
logging.warning("WOLFRAM_ALPHA_APPID not found, wolfram-alpha is disabled.")
|
77 |
+
# if exists SERPAPI_API_KEY, enable serpapi
|
78 |
+
if os.environ.get("SERPAPI_API_KEY", None) is not None:
|
79 |
+
tools_to_enable.append("serpapi")
|
80 |
+
else:
|
81 |
+
logging.warning("SERPAPI_API_KEY not found, serpapi is disabled.")
|
82 |
+
self.tools = load_tools(tools_to_enable, llm=self.llm)
|
83 |
else:
|
84 |
self.tools = load_tools(["ddg-search", "llm-math", "arxiv", "wikipedia"], llm=self.llm)
|
85 |
self.tools.append(
|
modules/models/models.py
CHANGED
@@ -665,6 +665,7 @@ def get_model(
|
|
665 |
elif model_type == ModelType.ChuanhuAgent:
|
666 |
from .ChuanhuAgent import ChuanhuAgent_Client
|
667 |
model = ChuanhuAgent_Client(model_name, access_key, user_name=user_name)
|
|
|
668 |
elif model_type == ModelType.GooglePaLM:
|
669 |
from .Google_PaLM import Google_PaLM_Client
|
670 |
access_key = os.environ.get("GOOGLE_PALM_API_KEY", access_key)
|
|
|
665 |
elif model_type == ModelType.ChuanhuAgent:
|
666 |
from .ChuanhuAgent import ChuanhuAgent_Client
|
667 |
model = ChuanhuAgent_Client(model_name, access_key, user_name=user_name)
|
668 |
+
msg = i18n("启用的工具:") + ", ".join([i.name for i in model.tools])
|
669 |
elif model_type == ModelType.GooglePaLM:
|
670 |
from .Google_PaLM import Google_PaLM_Client
|
671 |
access_key = os.environ.get("GOOGLE_PALM_API_KEY", access_key)
|