tooluniverse 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tooluniverse might be problematic. Click here for more details.

tooluniverse/__init__.py CHANGED
@@ -215,10 +215,15 @@ if not LAZY_LOADING_ENABLED:
215
215
  GWASAssociationsForStudy,
216
216
  )
217
217
 
218
- # from .admetai_tool import ADMETAITool
219
- from .mcp_client_tool import MCPClientTool, MCPAutoLoaderTool
220
- from .admetai_tool import ADMETAITool
221
- from .alphafold_tool import AlphaFoldRESTTool
218
+ from .mcp_client_tool import MCPClientTool, MCPAutoLoaderTool
219
+ from .admetai_tool import ADMETAITool
220
+ from .alphafold_tool import AlphaFoldRESTTool
221
+ from .odphp_tool import (
222
+ ODPHPMyHealthfinder,
223
+ ODPHPItemList,
224
+ ODPHPTopicSearch,
225
+ ODPHPOutlinkFetch,
226
+ )
222
227
  else:
223
228
  # With lazy loading, create lazy import proxies that import modules only when accessed
224
229
  MonarchTool = _LazyImportProxy("restful_tool", "MonarchTool")
@@ -296,7 +301,10 @@ else:
296
301
  MCPAutoLoaderTool = _LazyImportProxy("mcp_client_tool", "MCPAutoLoaderTool")
297
302
  ADMETAITool = _LazyImportProxy("admetai_tool", "ADMETAITool")
298
303
  AlphaFoldRESTTool = _LazyImportProxy("alphafold_tool", "AlphaFoldRESTTool")
299
-
304
+ ODPHPItemList = _LazyImportProxy("odphp_tool", "ODPHPItemList")
305
+ ODPHPMyHealthfinder = _LazyImportProxy("odphp_tool", "ODHPHPMyHealthfinder")
306
+ ODPHPTopicSearch = _LazyImportProxy("odphp_tool", "ODPHPTopicSearch")
307
+ ODPHPOutlinkFetch = _LazyImportProxy("odphp_tool", "ODPHPOutlinkFetch")
300
308
 
301
309
  __all__ = [
302
310
  "__version__",
@@ -364,4 +372,8 @@ __all__ = [
364
372
  "EmbeddingSync",
365
373
  "ToolFinderEmbedding",
366
374
  "AlphaFoldRESTTool",
375
+ "ODPHPMyHealthfinder",
376
+ "ODPHPItemList",
377
+ "ODPHPTopicSearch",
378
+ "ODPHPOutlinkFetch",
367
379
  ]
@@ -8,18 +8,20 @@ from typing import Any, Dict, List, Optional
8
8
  from .base_tool import BaseTool
9
9
  from .tool_registry import register_tool
10
10
  from .logging_config import get_logger
11
- from .llm_clients import AzureOpenAIClient, GeminiClient
11
+ from .llm_clients import AzureOpenAIClient, GeminiClient, OpenRouterClient
12
12
 
13
13
 
14
14
  # Global default fallback configuration
15
15
  DEFAULT_FALLBACK_CHAIN = [
16
16
  {"api_type": "CHATGPT", "model_id": "gpt-4o-1120"},
17
+ {"api_type": "OPENROUTER", "model_id": "openai/gpt-4o"},
17
18
  {"api_type": "GEMINI", "model_id": "gemini-2.0-flash"},
18
19
  ]
19
20
 
20
21
  # API key environment variable mapping
21
22
  API_KEY_ENV_VARS = {
22
23
  "CHATGPT": ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"],
24
+ "OPENROUTER": ["OPENROUTER_API_KEY"],
23
25
  "GEMINI": ["GEMINI_API_KEY"],
24
26
  }
25
27
 
@@ -202,6 +204,8 @@ class AgenticTool(BaseTool):
202
204
  try:
203
205
  if api_type == "CHATGPT":
204
206
  self._llm_client = AzureOpenAIClient(model_id, None, self.logger)
207
+ elif api_type == "OPENROUTER":
208
+ self._llm_client = OpenRouterClient(model_id, self.logger)
205
209
  elif api_type == "GEMINI":
206
210
  self._llm_client = GeminiClient(model_id, self.logger)
207
211
  else:
@@ -237,7 +241,7 @@ class AgenticTool(BaseTool):
237
241
 
238
242
  # ------------------------------------------------------------------ LLM utilities -----------
239
243
  def _validate_model_config(self):
240
- supported_api_types = ["CHATGPT", "GEMINI"]
244
+ supported_api_types = ["CHATGPT", "OPENROUTER", "GEMINI"]
241
245
  if self._api_type not in supported_api_types:
242
246
  raise ValueError(
243
247
  f"Unsupported API type: {self._api_type}. Supported types: {supported_api_types}"
@@ -440,6 +444,8 @@ class AgenticTool(BaseTool):
440
444
  try:
441
445
  if self._api_type == "CHATGPT":
442
446
  self._llm_client = AzureOpenAIClient(self._model_id, None, self.logger)
447
+ elif self._api_type == "OPENROUTER":
448
+ self._llm_client = OpenRouterClient(self._model_id, self.logger)
443
449
  elif self._api_type == "GEMINI":
444
450
  self._llm_client = GeminiClient(self._gemini_model_id, self.logger)
445
451
  else:
@@ -1162,7 +1162,7 @@
1162
1162
  "type": "AgenticTool",
1163
1163
  "name": "ToolMetadataGenerator",
1164
1164
  "description": "Generates a JSON structure with the metadata of a tool in ToolUniverse, given the JSON configuration of the tool.",
1165
- "prompt": "You are an expert in processing ToolUniverse tool configurations. Your task is to extract and generate key metadata from a given tool's JSON configuration and return it as a new, structured JSON object.\n\n**Input Tool Configuration:**\n```json\n{tool_config}\n```\n\n**Tool Type Mappings (for simplifying toolType):**\n```json\n{tool_type_mappings}\n```\n\n**Instructions:**\nFrom the input configuration, generate a new JSON object with the specified structure. All fields enclosed in '<','>' are placeholders for instructions; you should generate a specific value for the tool based on its configuration. Fields not in brackets should use the default values provided.\n\n**Output JSON Structure:**\n```json\n{\n \"id\": \"<generate a new uuid>\",\n \"name\": \"<extract from tool_config.name>\",\n \"description\": \"<extract and tool_config.description and slightly summarize it if it is too long>\",\n \"detailed_description\": \"<extract from tool_config.description>\",\n \"toolType\": \"<if tool_config.type or tool_config.name appears in tool_type_mappings dict in one of the lists (among the dict's values), extract the corresponding key and set it as the simplified toolType. otherwise, set toolType to be 'API' (the default)>\",\n \"tags\": [],\n \"category\": \"<extract from tool_config.type>\",\n \"lab\": \"Zitnik Lab\",\n \"source\": \"<extract the name of the database, package, model, or write 'Agentic'>\",\n \"version\": \"v1.0.0\",\n \"reviewed\": true,\n \"isValidated\": true,\n \"usageStats\": \"100+ uses\",\n \"capabilities\": [\n \"<list capabilities strictly derivable from tool_config>\"\n ],\n \"limitations\": [\n \"None for now\"\n ],\n \"parameters\": {<for each parameter key include an object with type and description>},\n \"inputSchema\": <echo tool_config.parameter exactly>,\n \"exampleInput\": <JSON object with example values for each parameter>,\n \"apiEndpoints\": [\n {\n \"method\": \"MCP\",\n \"url\": \"https://tooluniversemcpserver.onrender.com/mcp/\"\n }\n ]\n}\n```\n\nReturn ONLY the final JSON object with no extra commentary.",
1165
+ "prompt": "You are an expert in processing ToolUniverse tool configurations. Your task is to extract and generate key metadata from a given tool's JSON configuration and return it as a new, structured JSON object.\n\n**Input Tool Configuration:**\n```json\n{tool_config}\n```\n\n**Tool Type Mappings (for simplifying toolType):**\n```json\n{tool_type_mappings}\n```\n\n**Instructions:**\nFrom the input configuration, generate a new JSON object with the specified structure. All fields enclosed in '<','>' are placeholders for instructions; you should generate a specific value for the tool based on its configuration. Fields not in brackets should use the default values provided.\n\n**Output JSON Structure:**\n```json\n{\n \"id\": \"<generate a new uuid>\",\n \"name\": \"<extract from tool_config.name>\",\n \"description\": \"<extract and tool_config.description and slightly summarize it if it is too long>\",\n \"detailed_description\": \"<extract from tool_config.description>\",\n \"toolType\": \"<if tool_config.type or tool_config.name appears in tool_type_mappings dict in one of the lists (among the dict's values), extract the corresponding key and set it as the simplified toolType. otherwise, set toolType to be 'API' (the default)>\",\n \"tags\": [],\n \"category\": \"<extract from tool_config.type>\",\n \"lab\": \"Zitnik Lab\",\n \"source\": \"<extract the name of the database, package, model, or write 'Agentic'>\",\n \"version\": \"v1.0.0\",\n \"reviewed\": true,\n \"isValidated\": true,\n \"usageStats\": \"100+ uses\",\n \"capabilities\": [\n \"<list capabilities strictly derivable from tool_config>\"\n ],\n \"limitations\": [\n \"None for now\"\n ],\n \"parameters\": {<for each parameter key include an object with type and description>},\n \"inputSchema\": <echo tool_config.parameter exactly>,\n \"exampleInput\": {},\n \"apiEndpoints\": [\n {\n \"method\": \"MCP\",\n \"url\": \"https://tooluniversemcpserver.onrender.com/mcp/\"\n }\n ]\n}\n```\n\nReturn ONLY the final JSON object with no extra commentary.",
1166
1166
  "input_arguments": [
1167
1167
  "tool_config",
1168
1168
  "tool_type_mappings"
@@ -1268,4 +1268,4 @@
1268
1268
  "return_json": true
1269
1269
  }
1270
1270
  }
1271
- ]
1271
+ ]
@@ -0,0 +1,354 @@
1
+ [
2
+ {
3
+ "name": "odphp_myhealthfinder",
4
+ "description": "This tool provides personalized preventive-care recommendations and it is helpful for different ages, sexes, pregnancy status, gives age/sex/pregnancy. It retrieves metadata, plain-language sections, and dataset links to the full article (AccessibleVersion links). If the user wants the full text of a recommendation, the `odphp_outlink_fetch` tool is helpful.",
5
+ "type": "ODPHPMyHealthfinder",
6
+ "parameter": {
7
+ "type": "object",
8
+ "properties": {
9
+ "lang": { "type": "string", "description": "Language code (en or es)" },
10
+ "age": { "type": "integer", "description": "Age in years (0–120)" },
11
+ "sex": { "type": "string", "description": "Male or Female" },
12
+ "pregnant": { "type": "string", "description": "\"Yes\" or \"No\"" },
13
+ "strip_html": { "type": "boolean", "description": "If true, also return PlainSections[] with HTML removed for each topic" }
14
+ }
15
+ },
16
+ "fields": { "endpoint": "/myhealthfinder.json", "return_format": "JSON" },
17
+ "return_schema": {
18
+ "type": "object",
19
+ "properties": {
20
+ "Error": { "type": "string" },
21
+ "Total": { "type": "integer" },
22
+ "Query": { "type": "object" },
23
+ "Language": { "type": "string" },
24
+ "MyHFHeading": { "type": "string" },
25
+ "TakeAction": { "type": "string" },
26
+ "AboutTheseResults": { "type": "string" },
27
+ "Resources": {
28
+ "type": "object",
29
+ "properties": {
30
+ "All": {
31
+ "type": "object",
32
+ "properties": {
33
+ "Resource": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "object",
37
+ "properties": {
38
+ "Type": { "type": "string" },
39
+ "Id": { "type": "string" },
40
+ "Title": { "type": "string" },
41
+ "TranslationId": { "type": "string" },
42
+ "TranslationTitle": { "type": "string" },
43
+ "Categories": { "type": "string" },
44
+ "MyHFTitle": { "type": "string" },
45
+ "MyHFCategory": { "type": "string" },
46
+ "MyHFCategoryHeading": { "type": "string" },
47
+ "LastUpdate": { "type": "string" },
48
+ "ImageUrl": { "type": "string" },
49
+ "ImageAlt": { "type": "string" },
50
+ "AccessibleVersion": { "type": "string" },
51
+ "RelatedItems": {
52
+ "type": "object",
53
+ "properties": {
54
+ "RelatedItem": {
55
+ "type": "array",
56
+ "items": {
57
+ "type": "object",
58
+ "properties": {
59
+ "Type": { "type": "string" },
60
+ "Id": { "type": "string" },
61
+ "Title": { "type": "string" },
62
+ "Url": { "type": "string" }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ },
68
+ "Sections": {
69
+ "type": "object",
70
+ "properties": {
71
+ "Section": {
72
+ "type": "array",
73
+ "items": {
74
+ "type": "object",
75
+ "properties": {
76
+ "Title": { "type": "string" },
77
+ "Content": { "type": "string" }
78
+ }
79
+ }
80
+ },
81
+ "section": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "properties": {
86
+ "Title": { "type": "string" },
87
+ "Content": { "type": "string" }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "HealthfinderLogo": { "type": "string" },
94
+ "HealthfinderUrl": { "type": "string" }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ },
102
+ "Callouts": {
103
+ "type": "object",
104
+ "properties": {
105
+ "All": {
106
+ "type": "object",
107
+ "properties": {
108
+ "Resource": {
109
+ "type": "array",
110
+ "items": {
111
+ "type": "object",
112
+ "properties": {
113
+ "Type": { "type": "string" },
114
+ "Id": { "type": "string" },
115
+ "Title": { "type": "string" },
116
+ "TranslationId": { "type": "string" },
117
+ "TranslationTitle": { "type": "string" },
118
+ "Categories": { "type": "string" },
119
+ "MyHFTitle": { "type": "string" },
120
+ "MyHFCategory": { "type": "string" },
121
+ "MyHFCategoryHeading": { "type": "string" },
122
+ "LastUpdate": { "type": "string" },
123
+ "ImageUrl": { "type": "string" },
124
+ "ImageAlt": { "type": "string" },
125
+ "AccessibleVersion": { "type": "string" },
126
+ "RelatedItems": {
127
+ "type": "object",
128
+ "properties": {
129
+ "RelatedItem": {
130
+ "type": "array",
131
+ "items": {
132
+ "type": "object",
133
+ "properties": {
134
+ "Type": { "type": "string" },
135
+ "Id": { "type": "string" },
136
+ "Title": { "type": "string" },
137
+ "Url": { "type": "string" }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ },
143
+ "Sections": {
144
+ "type": "object",
145
+ "properties": {
146
+ "Section": {
147
+ "type": "array",
148
+ "items": {
149
+ "type": "object",
150
+ "properties": {
151
+ "Title": { "type": "string" },
152
+ "Content": { "type": "string" }
153
+ }
154
+ }
155
+ },
156
+ "section": {
157
+ "type": "array",
158
+ "items": {
159
+ "type": "object",
160
+ "properties": {
161
+ "Title": { "type": "string" },
162
+ "Content": { "type": "string" }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ },
168
+ "HealthfinderLogo": { "type": "string" },
169
+ "HealthfinderUrl": { "type": "string" }
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+ },
180
+ {
181
+ "name": "odphp_itemlist",
182
+ "description": "This tools browses and returns available topics and categories and it is helpful to help narrow a broad request (e.g., “show me all topics”). For full topic content, `odphp_topicsearch` tool is helpful.",
183
+ "type": "ODPHPItemList",
184
+ "parameter": {
185
+ "type": "object",
186
+ "properties": {
187
+ "lang": { "type": "string", "description": "Language code (en or es)" },
188
+ "type": { "type": "string", "description": "topic or category" }
189
+ }
190
+ },
191
+ "fields": { "endpoint": "/itemlist.json", "return_format": "JSON" },
192
+ "return_schema": {
193
+ "type": "object",
194
+ "properties": {
195
+ "Error": { "type": "string" },
196
+ "Total": { "type": "integer" },
197
+ "Query": { "type": "object" },
198
+ "Language": { "type": "string" },
199
+ "Items": {
200
+ "type": "object",
201
+ "properties": {
202
+ "Item": {
203
+ "type": "array",
204
+ "items": {
205
+ "type": "object",
206
+ "properties": {
207
+ "Type": { "type": "string" },
208
+ "Id": { "type": "string" },
209
+ "Title": { "type": "string" },
210
+ "ParentId": { "type": "string" },
211
+ "TranslationId": { "type": "string" }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ },
220
+ {
221
+ "name": "odphp_topicsearch",
222
+ "description": "Find specific health topics and get their full content. Use when the user mentions a keyword (e.g., “folic acid”, “blood pressure”) or when you already have topic/category IDs from `odphp_itemlist`. Returns detailed topic pages (Title, Sections, RelatedItems) and an AccessibleVersion link. Next: to quote or summarize the actual page text, pass the AccessibleVersion (or RelatedItems URLs) to `odphp_outlink_fetch`.",
223
+ "type": "ODPHPTopicSearch",
224
+ "parameter": {
225
+ "type": "object",
226
+ "properties": {
227
+ "lang": { "type": "string", "description": "Language code (en or es)" },
228
+ "topicId": { "type": "string", "description": "Comma-separated topic IDs" },
229
+ "categoryId": { "type": "string", "description": "Comma-separated category IDs" },
230
+ "keyword": { "type": "string", "description": "Keyword search for topics" },
231
+ "strip_html": { "type": "boolean", "description": "If true, also return PlainSections[] with HTML removed for each topic" }
232
+ }
233
+ },
234
+ "fields": { "endpoint": "/topicsearch.json", "return_format": "JSON" },
235
+ "return_schema": {
236
+ "type": "object",
237
+ "properties": {
238
+ "Error": { "type": "string" },
239
+ "Total": { "type": "integer" },
240
+ "Query": { "type": "object" },
241
+ "Language": { "type": "string" },
242
+ "Resources": {
243
+ "type": "object",
244
+ "properties": {
245
+ "Resource": {
246
+ "type": "array",
247
+ "items": {
248
+ "type": "object",
249
+ "properties": {
250
+ "Type": { "type": "string" },
251
+ "Id": { "type": "string" },
252
+ "Title": { "type": "string" },
253
+ "TranslationId": { "type": "string" },
254
+ "TranslationTitle": { "type": "string" },
255
+ "Categories": { "type": "string" },
256
+ "MyHFTitle": { "type": "string" },
257
+ "MyHFCategory": { "type": "string" },
258
+ "MyHFCategoryHeading": { "type": "string" },
259
+ "LastUpdate": { "type": "string" },
260
+ "ImageUrl": { "type": "string" },
261
+ "ImageAlt": { "type": "string" },
262
+ "AccessibleVersion": { "type": "string" },
263
+ "RelatedItems": {
264
+ "type": "object",
265
+ "properties": {
266
+ "RelatedItem": {
267
+ "type": "array",
268
+ "items": {
269
+ "type": "object",
270
+ "properties": {
271
+ "Type": { "type": "string" },
272
+ "Id": { "type": "string" },
273
+ "Title": { "type": "string" },
274
+ "Url": { "type": "string" }
275
+ }
276
+ }
277
+ }
278
+ }
279
+ },
280
+ "Sections": {
281
+ "type": "object",
282
+ "properties": {
283
+ "Section": {
284
+ "type": "array",
285
+ "items": {
286
+ "type": "object",
287
+ "properties": {
288
+ "Title": { "type": "string" },
289
+ "Content": { "type": "string" }
290
+ }
291
+ }
292
+ },
293
+ "section": {
294
+ "type": "array",
295
+ "items": {
296
+ "type": "object",
297
+ "properties": {
298
+ "Title": { "type": "string" },
299
+ "Content": { "type": "string" }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ },
305
+ "HealthfinderLogo": { "type": "string" },
306
+ "HealthfinderUrl": { "type": "string" }
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ }
313
+ }
314
+ },
315
+ {
316
+ "name": "odphp_outlink_fetch",
317
+ "description": "This tool retrieves readable text from ODPHP article links and information sources. This is helpful after using the `odphp_myhealthfinder` or `odphp_topicsearch` tools or when the user wants to simply dive deeper into ODPHP data.",
318
+ "type": "ODPHPOutlinkFetch",
319
+ "parameter": {
320
+ "type": "object",
321
+ "properties": {
322
+ "urls": {
323
+ "type": "array",
324
+ "items": { "type": "string" },
325
+ "description": "1–3 absolute URLs from AccessibleVersion or RelatedItems.Url"
326
+ },
327
+ "max_chars": { "type": "integer", "description": "Optional hard cap on extracted text length (e.g., 5000)" },
328
+ "return_html": { "type": "boolean", "description": "If true, also return minimally cleaned HTML" }
329
+ },
330
+ "required": ["urls"]
331
+ },
332
+ "fields": { "endpoint": "/outlink", "return_format": "JSON" },
333
+ "return_schema": {
334
+ "type": "object",
335
+ "properties": {
336
+ "results": {
337
+ "type": "array",
338
+ "items": {
339
+ "type": "object",
340
+ "properties": {
341
+ "url": { "type": "string" },
342
+ "status": { "type": "integer" },
343
+ "content_type": { "type": "string" },
344
+ "title": { "type": "string" },
345
+ "text": { "type": "string" },
346
+ "html": { "type": "string" }
347
+ }
348
+ }
349
+ },
350
+ "metadata": { "type": "object" }
351
+ }
352
+ }
353
+ }
354
+ ]
@@ -113,6 +113,7 @@ default_tool_files = {
113
113
  "output_summarization": os.path.join(
114
114
  current_dir, "data", "output_summarization_tools.json"
115
115
  ),
116
+ "odphp": os.path.join(current_dir, "data", "odphp_tools.json"),
116
117
  }
117
118
 
118
119