-
Notifications
You must be signed in to change notification settings - Fork 273
/
host_local_tools.py
174 lines (139 loc) · 7.17 KB
/
host_local_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import bmtools
import os
def run_tool_server():
def load_weather_tool():
WEATHER_API_KEYS = os.environ.get('WEATHER_API_KEYS', None)
if not WEATHER_API_KEYS:
raise RuntimeError("WEATHER_API_KEYS not provided, please register one from https://www.weatherapi.com/ and add it to environment variables.")
server.load_tool("weather", {"subscription_key": WEATHER_API_KEYS})
# def load_database_tool():
# server.load_tool("database")
# def load_db_diag_tool():
# server.load_tool("db_diag")
def load_chemical_prop_tool():
server.load_tool("chemical-prop")
def load_douban_tool():
server.load_tool("douban-film")
def load_wikipedia_tool():
server.load_tool("wikipedia")
# def load_wikidata_tool():
# server.load_tool("wikidata")
def load_travel_tool():
server.load_tool("travel")
def load_wolframalpha_tool():
WOLFRAMALPH_APP_ID = os.environ.get("WOLFRAMALPH_APP_ID", None)
if not WOLFRAMALPH_APP_ID:
raise RuntimeError("WOLFRAMALPH_APP_ID not provided, please register one from https://products.wolframalpha.com/api/ and add it to environment variables.")
server.load_tool("wolframalpha", {"subscription_key": WOLFRAMALPH_APP_ID})
def load_bing_search_tool():
BING_SUBSCRIPT_KEY = os.environ.get('BING_SUBSCRIPT_KEY', None)
if not BING_SUBSCRIPT_KEY:
raise RuntimeError("Bing search key not provided, please register one from https://www.microsoft.com/en-us/bing/apis/bing-web-search-api and add it to environment variables.")
server.load_tool("bing_search", {"subscription_key": BING_SUBSCRIPT_KEY})
def load_office_ppt_tool():
server.load_tool("office-ppt")
def load_alpha_vantage_tool():
ALPHA_VANTAGE_KEY = os.environ.get('ALPHA_VANTAGE_KEY', None)
if not ALPHA_VANTAGE_KEY:
raise RuntimeError("Stock key not provided, please register one from https://www.alphavantage.co/support/#api-key and add it to environment variables.")
server.load_tool("stock", {"subscription_key": ALPHA_VANTAGE_KEY})
def load_map_tool():
BING_MAP_KEY = os.environ.get('BING_MAP_KEY', None)
if not BING_MAP_KEY:
raise RuntimeError("Bing map key not provided, please register one from https://www.bingmapsportal.com/ and add it to environment variables.")
server.load_tool("bing_map", {"subscription_key": BING_MAP_KEY})
# baidu map tool
# BAIDU_SECRET_KEY = os.environ.get('BAIDU_SECRET_KEY', None)
# BAIDU_MAP_KEY = os.environ.get('BAIDU_MAP_KEY', None)
# if not BAIDU_SECRET_KEY or not BAIDU_MAP_KEY:
# raise RuntimeError("Baidu map key not provided, please register one from https://lbsyun.baidu.com/apiconsole/key and add it to environment variables.")
# server.load_tool("baidu_map", {"subscription_key": BAIDU_MAP_KEY, "baidu_secret_key": BAIDU_SECRET_KEY})
def load_rapidapi_tool():
RAPIDAPI_KEY = os.environ.get('RAPIDAPI_KEY', None)
if not RAPIDAPI_KEY:
raise RuntimeError("RAPIDAPI_KEY not provided, please register one from https://rapidapi.com/ and add it to environment variables.")
server.load_tool("zillow", {"subscription_key": RAPIDAPI_KEY})
server.load_tool("airbnb", {"subscription_key": RAPIDAPI_KEY})
server.load_tool("job_search", {"subscription_key": RAPIDAPI_KEY})
# def load_nllb_translation_tool():
# server.load_tool("nllb-translation")
# def load_baidu_translation_tool():
# server.load_tool("baidu-translation")
def load_tutorial_tool():
server.load_tool("tutorial")
def load_file_operation_tool():
server.load_tool("file_operation")
def load_meta_analysis_tool():
server.load_tool("meta_analysis")
def load_code_interpreter_tool():
server.load_tool("code_interpreter")
def load_arxiv_tool():
server.load_tool("arxiv")
def load_google_places_tool():
GPLACES_API_KEY = os.environ.get('GPLACES_API_KEY', '')
if not GPLACES_API_KEY:
raise RuntimeError("GPLACES_API_KEY not provided, please register one from https://developers.google.com/maps/documentation/elevation/get-api-key and add it to environment variables.")
server.load_tool("google_places", {"subscription_key": GPLACES_API_KEY})
def load_google_serper_tool():
SERPER_API_KEY = os.environ.get('SERPER_API_KEY', None)
if not SERPER_API_KEY:
raise RuntimeError("SERPER_API_KEY not provided, please register one from https://serper.dev and add it to environment variables.")
server.load_tool("google_serper", {"subscription_key": SERPER_API_KEY})
server.load_tool("google_scholar", {"subscription_key": SERPER_API_KEY})
server.load_tool("walmart", {"subscription_key": SERPER_API_KEY})
def load_python_tool():
server.load_tool("python")
def load_sceneXplain_tool():
SCENEX_API_KEY = os.environ.get('SCENEX_API_KEY', None)
if not SCENEX_API_KEY:
raise RuntimeError("SCENEX_API_KEY is not provided. Please sign up for a free account at https://scenex.jina.ai/, create a new API key, and add it to environment variables.")
server.load_tool("sceneXplain", {"subscription_key": SCENEX_API_KEY})
def load_shell_tool():
server.load_tool("shell")
def load_image_generation_tool():
STEAMSHIP_API_KEY = os.environ.get('STEAMSHIP_API_KEY', None)
if not STEAMSHIP_API_KEY:
raise RuntimeError("STEAMSHIP_API_KEY is not provided. Please sign up for a free account at https://steamship.com/account/api, create a new API key, and add it to environment variables.")
server.load_tool("image_generation")
def load_hugging_tools():
HUGGINGFACE_API_KEY = os.environ.get('HUGGINGFACE_API_KEY', None)
if not HUGGINGFACE_API_KEY:
raise RuntimeError("Huggingface api key (access tokens) not provided, please register one from https://huggingface.co/ and add it to environment variables.")
server.load_tool("hugging_tools")
def load_gradio_tools():
server.load_tool("gradio_tools")
server = bmtools.ToolServer()
print(server.list_tools())
# tool_choice = input("Enter 'ALL' to load all tools, or enter the specific tools you want to load (comma-separated): ")
load_weather_tool()
# load_database_tool()
# load_db_diag_tool()
load_chemical_prop_tool()
load_douban_tool()
load_wikipedia_tool()
# load_wikidata_tool()
load_wolframalpha_tool()
load_bing_search_tool()
load_office_ppt_tool()
load_alpha_vantage_tool()
load_map_tool()
load_rapidapi_tool()
# load_nllb_translation_tool()
# load_baidu_translation_tool()
load_tutorial_tool()
load_file_operation_tool()
load_meta_analysis_tool()
load_code_interpreter_tool()
load_arxiv_tool()
load_google_places_tool()
load_google_serper_tool()
load_python_tool()
load_sceneXplain_tool()
load_shell_tool()
load_image_generation_tool()
load_hugging_tools()
load_gradio_tools()
load_travel_tool()
server.serve()
if __name__ == "__main__":
run_tool_server()