camel-ai 0.1.5.6__py3-none-any.whl → 0.1.5.7__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 camel-ai might be problematic. Click here for more details.

Files changed (61) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +1 -1
  3. camel/configs/gemini_config.py +15 -14
  4. camel/configs/litellm_config.py +1 -1
  5. camel/configs/openai_config.py +1 -1
  6. camel/configs/zhipuai_config.py +1 -1
  7. camel/models/base_model.py +4 -1
  8. camel/models/litellm_model.py +16 -0
  9. camel/models/ollama_model.py +16 -0
  10. camel/models/zhipuai_model.py +0 -1
  11. camel/toolkits/__init__.py +36 -0
  12. camel/toolkits/base.py +1 -1
  13. camel/toolkits/code_execution.py +1 -1
  14. camel/toolkits/github_toolkit.py +3 -2
  15. camel/toolkits/google_maps_toolkit.py +367 -0
  16. camel/toolkits/math_toolkit.py +79 -0
  17. camel/toolkits/open_api_toolkit.py +548 -0
  18. camel/toolkits/retrieval_toolkit.py +76 -0
  19. camel/toolkits/search_toolkit.py +326 -0
  20. camel/toolkits/slack_toolkit.py +308 -0
  21. camel/toolkits/twitter_toolkit.py +522 -0
  22. camel/toolkits/weather_toolkit.py +173 -0
  23. camel/utils/async_func.py +1 -1
  24. {camel_ai-0.1.5.6.dist-info → camel_ai-0.1.5.7.dist-info}/METADATA +2 -2
  25. {camel_ai-0.1.5.6.dist-info → camel_ai-0.1.5.7.dist-info}/RECORD +52 -53
  26. camel/functions/__init__.py +0 -51
  27. camel/functions/google_maps_function.py +0 -335
  28. camel/functions/math_functions.py +0 -61
  29. camel/functions/open_api_function.py +0 -508
  30. camel/functions/retrieval_functions.py +0 -61
  31. camel/functions/search_functions.py +0 -298
  32. camel/functions/slack_functions.py +0 -286
  33. camel/functions/twitter_function.py +0 -479
  34. camel/functions/weather_functions.py +0 -144
  35. /camel/{functions → toolkits}/open_api_specs/biztoc/__init__.py +0 -0
  36. /camel/{functions → toolkits}/open_api_specs/biztoc/ai-plugin.json +0 -0
  37. /camel/{functions → toolkits}/open_api_specs/biztoc/openapi.yaml +0 -0
  38. /camel/{functions → toolkits}/open_api_specs/coursera/__init__.py +0 -0
  39. /camel/{functions → toolkits}/open_api_specs/coursera/openapi.yaml +0 -0
  40. /camel/{functions → toolkits}/open_api_specs/create_qr_code/__init__.py +0 -0
  41. /camel/{functions → toolkits}/open_api_specs/create_qr_code/openapi.yaml +0 -0
  42. /camel/{functions → toolkits}/open_api_specs/klarna/__init__.py +0 -0
  43. /camel/{functions → toolkits}/open_api_specs/klarna/openapi.yaml +0 -0
  44. /camel/{functions → toolkits}/open_api_specs/nasa_apod/__init__.py +0 -0
  45. /camel/{functions → toolkits}/open_api_specs/nasa_apod/openapi.yaml +0 -0
  46. /camel/{functions → toolkits}/open_api_specs/outschool/__init__.py +0 -0
  47. /camel/{functions → toolkits}/open_api_specs/outschool/ai-plugin.json +0 -0
  48. /camel/{functions → toolkits}/open_api_specs/outschool/openapi.yaml +0 -0
  49. /camel/{functions → toolkits}/open_api_specs/outschool/paths/__init__.py +0 -0
  50. /camel/{functions → toolkits}/open_api_specs/outschool/paths/get_classes.py +0 -0
  51. /camel/{functions → toolkits}/open_api_specs/outschool/paths/search_teachers.py +0 -0
  52. /camel/{functions → toolkits}/open_api_specs/security_config.py +0 -0
  53. /camel/{functions → toolkits}/open_api_specs/speak/__init__.py +0 -0
  54. /camel/{functions → toolkits}/open_api_specs/speak/openapi.yaml +0 -0
  55. /camel/{functions → toolkits}/open_api_specs/web_scraper/__init__.py +0 -0
  56. /camel/{functions → toolkits}/open_api_specs/web_scraper/ai-plugin.json +0 -0
  57. /camel/{functions → toolkits}/open_api_specs/web_scraper/openapi.yaml +0 -0
  58. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/__init__.py +0 -0
  59. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/scraper.py +0 -0
  60. /camel/{functions → toolkits}/openai_function.py +0 -0
  61. {camel_ai-0.1.5.6.dist-info → camel_ai-0.1.5.7.dist-info}/WHEEL +0 -0
@@ -1,508 +0,0 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the “License”);
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an “AS IS” BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- import json
15
- import os
16
- from typing import Any, Callable, Dict, List, Optional, Tuple
17
-
18
- import requests
19
-
20
- from camel.functions import OpenAIFunction, openapi_security_config
21
- from camel.types import OpenAPIName
22
-
23
-
24
- def parse_openapi_file(openapi_spec_path: str) -> Optional[Dict[str, Any]]:
25
- r"""Load and parse an OpenAPI specification file.
26
-
27
- This function utilizes the `prance.ResolvingParser` to parse and resolve
28
- the given OpenAPI specification file, returning the parsed OpenAPI
29
- specification as a dictionary.
30
-
31
- Args:
32
- openapi_spec_path (str): The file path or URL to the OpenAPI
33
- specification.
34
-
35
- Returns:
36
- Optional[Dict[str, Any]]: The parsed OpenAPI specification
37
- as a dictionary. :obj:`None` if the package is not installed.
38
- """
39
- try:
40
- import prance
41
- except Exception:
42
- return None
43
-
44
- # Load the OpenAPI spec
45
- parser = prance.ResolvingParser(
46
- openapi_spec_path, backend="openapi-spec-validator", strict=False
47
- )
48
- openapi_spec = parser.specification
49
- version = openapi_spec.get('openapi', {})
50
- if not version:
51
- raise ValueError(
52
- "OpenAPI version not specified in the spec. "
53
- "Only OPENAPI 3.0.x and 3.1.x are supported."
54
- )
55
- if not (version.startswith('3.0') or version.startswith('3.1')):
56
- raise ValueError(
57
- f"Unsupported OpenAPI version: {version}. "
58
- f"Only OPENAPI 3.0.x and 3.1.x are supported."
59
- )
60
- return openapi_spec
61
-
62
-
63
- def openapi_spec_to_openai_schemas(
64
- api_name: str, openapi_spec: Dict[str, Any]
65
- ) -> List[Dict[str, Any]]:
66
- r"""Convert OpenAPI specification to OpenAI schema format.
67
-
68
- This function iterates over the paths and operations defined in an
69
- OpenAPI specification, filtering out deprecated operations. For each
70
- operation, it constructs a schema in a format suitable for OpenAI,
71
- including operation metadata such as function name, description,
72
- parameters, and request bodies. It raises a ValueError if an operation
73
- lacks a description or summary.
74
-
75
- Args:
76
- api_name (str): The name of the API, used to prefix generated function
77
- names.
78
- openapi_spec (Dict[str, Any]): The OpenAPI specification as a
79
- dictionary.
80
-
81
- Returns:
82
- List[Dict[str, Any]]: A list of dictionaries, each representing a
83
- function in the OpenAI schema format, including details about the
84
- function's name, description, and parameters.
85
-
86
- Raises:
87
- ValueError: If an operation in the OpenAPI specification does not have
88
- a description or summary.
89
-
90
- Note:
91
- This function assumes that the OpenAPI specification follows the 3.0+
92
- format.
93
-
94
- Reference:
95
- https://swagger.io/specification/
96
- """
97
- result = []
98
-
99
- for path, path_item in openapi_spec.get('paths', {}).items():
100
- for method, op in path_item.items():
101
- if op.get('deprecated') is True:
102
- continue
103
-
104
- # Get the function name from the operationId
105
- # or construct it from the API method, and path
106
- function_name = f"{api_name}"
107
- operation_id = op.get('operationId')
108
- if operation_id:
109
- function_name += f"_{operation_id}"
110
- else:
111
- function_name += f"{method}{path.replace('/', '_')}"
112
-
113
- description = op.get('description') or op.get('summary')
114
- if not description:
115
- raise ValueError(
116
- f"{method} {path} Operation from {api_name} "
117
- f"does not have a description or summary."
118
- )
119
- description += " " if description[-1] != " " else ""
120
- description += f"This function is from {api_name} API. "
121
-
122
- # If the OpenAPI spec has a description,
123
- # add it to the operation description
124
- if 'description' in openapi_spec.get('info', {}):
125
- description += f"{openapi_spec['info']['description']}"
126
-
127
- # Get the parameters for the operation, if any
128
- params = op.get('parameters', [])
129
- properties: Dict[str, Any] = {}
130
- required = []
131
-
132
- for param in params:
133
- if not param.get('deprecated', False):
134
- param_name = param['name'] + '_in_' + param['in']
135
- properties[param_name] = {}
136
-
137
- if 'description' in param:
138
- properties[param_name]['description'] = param[
139
- 'description'
140
- ]
141
-
142
- if 'schema' in param:
143
- if (
144
- properties[param_name].get('description')
145
- and 'description' in param['schema']
146
- ):
147
- param['schema'].pop('description')
148
- properties[param_name].update(param['schema'])
149
-
150
- if param.get('required'):
151
- required.append(param_name)
152
-
153
- # If the property dictionary does not have a description,
154
- # use the parameter name as the description
155
- if 'description' not in properties[param_name]:
156
- properties[param_name]['description'] = param['name']
157
-
158
- if 'type' not in properties[param_name]:
159
- properties[param_name]['type'] = 'Any'
160
-
161
- # Process requestBody if present
162
- if 'requestBody' in op:
163
- properties['requestBody'] = {}
164
- requestBody = op['requestBody']
165
- if requestBody.get('required') is True:
166
- required.append('requestBody')
167
-
168
- content = requestBody.get('content', {})
169
- json_content = content.get('application/json', {})
170
- json_schema = json_content.get('schema', {})
171
- if json_schema:
172
- properties['requestBody'] = json_schema
173
- if 'description' not in properties['requestBody']:
174
- properties['requestBody']['description'] = (
175
- "The request body, with parameters specifically "
176
- "described under the `properties` key"
177
- )
178
-
179
- function = {
180
- "type": "function",
181
- "function": {
182
- "name": function_name,
183
- "description": description,
184
- "parameters": {
185
- "type": "object",
186
- "properties": properties,
187
- "required": required,
188
- },
189
- },
190
- }
191
- result.append(function)
192
-
193
- return result # Return the result list
194
-
195
-
196
- def openapi_function_decorator(
197
- api_name: str,
198
- base_url: str,
199
- path: str,
200
- method: str,
201
- openapi_security: List[Dict[str, Any]],
202
- sec_schemas: Dict[str, Dict[str, Any]],
203
- operation: Dict[str, Any],
204
- ) -> Callable:
205
- r"""Decorate a function to make HTTP requests based on OpenAPI
206
- specification details.
207
-
208
- This decorator dynamically constructs and executes an API request based on
209
- the provided OpenAPI operation specifications, security requirements, and
210
- parameters. It supports operations secured with `apiKey` type security
211
- schemes and automatically injects the necessary API keys from environment
212
- variables. Parameters in `path`, `query`, `header`, and `cookie` are also
213
- supported.
214
-
215
- Args:
216
- api_name (str): The name of the API, used to retrieve API key names
217
- and URLs from the configuration.
218
- base_url (str): The base URL for the API.
219
- path (str): The path for the API endpoint, relative to the base URL.
220
- method (str): The HTTP method (e.g., 'get', 'post') for the request.
221
- openapi_security (List[Dict[str, Any]]): The global security
222
- definitions as specified in the OpenAPI specs.
223
- sec_schemas (Dict[str, Dict[str, Any]]): Detailed security schemes.
224
- operation (Dict[str, Any]): A dictionary containing the OpenAPI
225
- operation details, including parameters and request body
226
- definitions.
227
-
228
- Returns:
229
- Callable: A decorator that, when applied to a function, enables the
230
- function to make HTTP requests based on the provided OpenAPI
231
- operation details.
232
-
233
- Raises:
234
- TypeError: If the security requirements include unsupported types.
235
- ValueError: If required API keys are missing from environment
236
- variables or if the content type of the request body is
237
- unsupported.
238
- """
239
-
240
- def inner_decorator(openapi_function: Callable) -> Callable:
241
- def wrapper(**kwargs):
242
- request_url = f"{base_url.rstrip('/')}/{path.lstrip('/')}"
243
- headers = {}
244
- params = {}
245
- cookies = {}
246
-
247
- # Security definition of operation overrides any declared
248
- # top-level security.
249
- sec_requirements = operation.get('security', openapi_security)
250
- avail_sec_requirement = {}
251
- # Write to avaliable_security_requirement only if all the
252
- # security_type are "apiKey"
253
- for security_requirement in sec_requirements:
254
- have_unsupported_type = False
255
- for sec_scheme_name, _ in security_requirement.items():
256
- sec_type = sec_schemas.get(sec_scheme_name).get('type')
257
- if sec_type != "apiKey":
258
- have_unsupported_type = True
259
- break
260
- if have_unsupported_type is False:
261
- avail_sec_requirement = security_requirement
262
- break
263
-
264
- if sec_requirements and not avail_sec_requirement:
265
- raise TypeError(
266
- "Only security schemas of type `apiKey` are supported."
267
- )
268
-
269
- for sec_scheme_name, _ in avail_sec_requirement.items():
270
- try:
271
- API_KEY_NAME = openapi_security_config.get(api_name).get(
272
- sec_scheme_name
273
- )
274
- api_key_value = os.environ[API_KEY_NAME]
275
- except Exception:
276
- api_key_url = openapi_security_config.get(api_name).get(
277
- 'get_api_key_url'
278
- )
279
- raise ValueError(
280
- f"`{API_KEY_NAME}` not found in environment "
281
- f"variables. Get `{API_KEY_NAME}` here: {api_key_url}"
282
- )
283
- request_key_name = sec_schemas.get(sec_scheme_name).get('name')
284
- request_key_in = sec_schemas.get(sec_scheme_name).get('in')
285
- if request_key_in == 'query':
286
- params[request_key_name] = api_key_value
287
- elif request_key_in == 'header':
288
- headers[request_key_name] = api_key_value
289
- elif request_key_in == 'coolie':
290
- cookies[request_key_name] = api_key_value
291
-
292
- # Assign parameters to the correct position
293
- for param in operation.get('parameters', []):
294
- input_param_name = param['name'] + '_in_' + param['in']
295
- # Irrelevant arguments does not affect function operation
296
- if input_param_name in kwargs:
297
- if param['in'] == 'path':
298
- request_url = request_url.replace(
299
- f"{{{param['name']}}}",
300
- str(kwargs[input_param_name]),
301
- )
302
- elif param['in'] == 'query':
303
- params[param['name']] = kwargs[input_param_name]
304
- elif param['in'] == 'header':
305
- headers[param['name']] = kwargs[input_param_name]
306
- elif param['in'] == 'cookie':
307
- cookies[param['name']] = kwargs[input_param_name]
308
-
309
- if 'requestBody' in operation:
310
- request_body = kwargs.get('requestBody', {})
311
- content_type_list = list(
312
- operation.get('requestBody', {}).get('content', {}).keys()
313
- )
314
- if content_type_list:
315
- content_type = content_type_list[0]
316
- headers.update({"Content-Type": content_type})
317
-
318
- # send the request body based on the Content-Type
319
- if content_type == "application/json":
320
- response = requests.request(
321
- method.upper(),
322
- request_url,
323
- params=params,
324
- headers=headers,
325
- cookies=cookies,
326
- json=request_body,
327
- )
328
- else:
329
- raise ValueError(
330
- f"Unsupported content type: {content_type}"
331
- )
332
- else:
333
- # If there is no requestBody, no request body is sent
334
- response = requests.request(
335
- method.upper(),
336
- request_url,
337
- params=params,
338
- headers=headers,
339
- cookies=cookies,
340
- )
341
-
342
- try:
343
- return response.json()
344
- except json.JSONDecodeError:
345
- raise ValueError(
346
- "Response could not be decoded as JSON. "
347
- "Please check the input parameters."
348
- )
349
-
350
- return wrapper
351
-
352
- return inner_decorator
353
-
354
-
355
- def generate_openapi_funcs(
356
- api_name: str, openapi_spec: Dict[str, Any]
357
- ) -> List[Callable]:
358
- r"""Generates a list of Python functions based on an OpenAPI specification.
359
-
360
- This function dynamically creates a list of callable functions that
361
- represent the API operations defined in an OpenAPI specification document.
362
- Each function is designed to perform an HTTP request corresponding to an
363
- API operation (e.g., GET, POST) as defined in the specification. The
364
- functions are decorated with `openapi_function_decorator`, which
365
- configures them to construct and send the HTTP requests with appropriate
366
- parameters, headers, and body content.
367
-
368
- Args:
369
- api_name (str): The name of the API, used to prefix generated function
370
- names.
371
- openapi_spec (Dict[str, Any]): The OpenAPI specification as a
372
- dictionary.
373
-
374
- Returns:
375
- List[Callable]: A list containing the generated functions. Each
376
- function, when called, will make an HTTP request according to its
377
- corresponding API operation defined in the OpenAPI specification.
378
-
379
- Raises:
380
- ValueError: If the OpenAPI specification does not contain server
381
- information, which is necessary for determining the base URL for
382
- the API requests.
383
- """
384
- # Check server information
385
- servers = openapi_spec.get('servers', [])
386
- if not servers:
387
- raise ValueError("No server information found in OpenAPI spec.")
388
- base_url = servers[0].get('url') # Use the first server URL
389
-
390
- # Security requirement objects for all methods
391
- openapi_security = openapi_spec.get('security', {})
392
- # Security schemas which can be reused by different methods
393
- sec_schemas = openapi_spec.get('components', {}).get('securitySchemes', {})
394
- functions = []
395
-
396
- # Traverse paths and methods
397
- for path, methods in openapi_spec.get('paths', {}).items():
398
- for method, operation in methods.items():
399
- # Get the function name from the operationId
400
- # or construct it from the API method, and path
401
- operation_id = operation.get('operationId')
402
- if operation_id:
403
- function_name = f"{api_name}_{operation_id}"
404
- else:
405
- sanitized_path = path.replace('/', '_').strip('_')
406
- function_name = f"{api_name}_{method}_{sanitized_path}"
407
-
408
- @openapi_function_decorator(
409
- api_name,
410
- base_url,
411
- path,
412
- method,
413
- openapi_security,
414
- sec_schemas,
415
- operation,
416
- )
417
- def openapi_function(**kwargs):
418
- pass
419
-
420
- openapi_function.__name__ = function_name
421
-
422
- functions.append(openapi_function)
423
-
424
- return functions
425
-
426
-
427
- def apinames_filepaths_to_funs_schemas(
428
- apinames_filepaths: List[Tuple[str, str]],
429
- ) -> Tuple[List[Callable], List[Dict[str, Any]]]:
430
- r"""Combines functions and schemas from multiple OpenAPI specifications,
431
- using API names as keys.
432
-
433
- This function iterates over tuples of API names and OpenAPI spec file
434
- paths, parsing each spec to generate callable functions and schema
435
- dictionaries, all organized by API name.
436
-
437
- Args:
438
- apinames_filepaths (List[Tuple[str, str]]): A list of tuples, where each
439
- tuple consists of:
440
- - The API name (str) as the first element.
441
- - The file path (str) to the API's OpenAPI specification file as the
442
- second element.
443
-
444
- Returns:
445
- Tuple[List[Callable], List[Dict[str, Any]]]:: one of callable
446
- functions for API operations, and another of dictionaries
447
- representing the schemas from the specifications.
448
- """
449
- combined_func_lst = []
450
- combined_schemas_list = []
451
- for api_name, file_path in apinames_filepaths:
452
- # Parse the OpenAPI specification for each API
453
- current_dir = os.path.dirname(__file__)
454
- file_path = os.path.join(
455
- current_dir, 'open_api_specs', f'{api_name}', 'openapi.yaml'
456
- )
457
-
458
- openapi_spec = parse_openapi_file(file_path)
459
- if openapi_spec is None:
460
- return [], []
461
-
462
- # Generate and merge function schemas
463
- openapi_functions_schemas = openapi_spec_to_openai_schemas(
464
- api_name, openapi_spec
465
- )
466
- combined_schemas_list.extend(openapi_functions_schemas)
467
-
468
- # Generate and merge function lists
469
- openapi_functions_list = generate_openapi_funcs(api_name, openapi_spec)
470
- combined_func_lst.extend(openapi_functions_list)
471
-
472
- return combined_func_lst, combined_schemas_list
473
-
474
-
475
- def generate_apinames_filepaths() -> List[Tuple[str, str]]:
476
- """Generates a list of tuples containing API names and their corresponding
477
- file paths.
478
-
479
- This function iterates over the OpenAPIName enum, constructs the file path
480
- for each API's OpenAPI specification file, and appends a tuple of the API
481
- name and its file path to the list. The file paths are relative to the
482
- 'open_api_specs' directory located in the same directory as this script.
483
-
484
- Returns:
485
- List[Tuple[str, str]]: A list of tuples where each tuple contains two
486
- elements. The first element of each tuple is a string representing
487
- the name of an API, and the second element is a string that
488
- specifies the file path to that API's OpenAPI specification file.
489
- """
490
- apinames_filepaths = []
491
- current_dir = os.path.dirname(__file__)
492
- for api_name in OpenAPIName:
493
- file_path = os.path.join(
494
- current_dir, 'open_api_specs', f'{api_name.value}', 'openapi.yaml'
495
- )
496
- apinames_filepaths.append((api_name.value, file_path))
497
- return apinames_filepaths
498
-
499
-
500
- apinames_filepaths = generate_apinames_filepaths()
501
- all_funcs_lst, all_schemas_lst = apinames_filepaths_to_funs_schemas(
502
- apinames_filepaths
503
- )
504
-
505
- OPENAPI_FUNCS: List[OpenAIFunction] = [
506
- OpenAIFunction(a_func, a_schema)
507
- for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
508
- ]
@@ -1,61 +0,0 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the “License”);
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an “AS IS” BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- from typing import List, Union
15
-
16
- from camel.functions import OpenAIFunction
17
- from camel.retrievers import AutoRetriever
18
- from camel.types import StorageType
19
-
20
-
21
- def information_retrieval(
22
- query: str, content_input_paths: Union[str, List[str]]
23
- ) -> str:
24
- r"""Retrieves information from a local vector storage based on the
25
- specified query. This function connects to a local vector storage system
26
- and retrieves relevant information by processing the input query. It is
27
- essential to use this function when the answer to a question requires
28
- external knowledge sources.
29
-
30
- Args:
31
- query (str): The question or query for which an answer is required.
32
- content_input_paths (Union[str, List[str]]): Paths to local
33
- files or remote URLs.
34
-
35
- Returns:
36
- str: The information retrieved in response to the query, aggregated
37
- and formatted as a string.
38
-
39
- Example:
40
- # Retrieve information about CAMEL AI.
41
- information_retrieval(query = "what is CAMEL AI?",
42
- content_input_paths="https://www.camel-ai.org/")
43
- """
44
- auto_retriever = AutoRetriever(
45
- vector_storage_local_path="camel/temp_storage",
46
- storage_type=StorageType.QDRANT,
47
- )
48
-
49
- retrieved_info = auto_retriever.run_vector_retriever(
50
- query=query, content_input_paths=content_input_paths, top_k=3
51
- )
52
- return retrieved_info
53
-
54
-
55
- # add the function to OpenAIFunction list
56
- RETRIEVAL_FUNCS: List[OpenAIFunction] = [
57
- OpenAIFunction(func)
58
- for func in [
59
- information_retrieval,
60
- ]
61
- ]