camel-ai 0.1.5__py3-none-any.whl → 0.1.5.2__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 (78) hide show
  1. camel/agents/__init__.py +2 -0
  2. camel/agents/chat_agent.py +217 -36
  3. camel/agents/deductive_reasoner_agent.py +86 -31
  4. camel/agents/knowledge_graph_agent.py +41 -18
  5. camel/agents/role_assignment_agent.py +4 -1
  6. camel/agents/search_agent.py +122 -0
  7. camel/bots/__init__.py +20 -0
  8. camel/bots/discord_bot.py +103 -0
  9. camel/bots/telegram_bot.py +84 -0
  10. camel/configs/__init__.py +3 -0
  11. camel/configs/anthropic_config.py +1 -1
  12. camel/configs/litellm_config.py +113 -0
  13. camel/embeddings/__init__.py +2 -0
  14. camel/embeddings/openai_embedding.py +2 -2
  15. camel/embeddings/sentence_transformers_embeddings.py +6 -5
  16. camel/embeddings/vlm_embedding.py +146 -0
  17. camel/functions/__init__.py +9 -0
  18. camel/functions/open_api_function.py +150 -29
  19. camel/functions/open_api_specs/biztoc/__init__.py +13 -0
  20. camel/functions/open_api_specs/biztoc/ai-plugin.json +34 -0
  21. camel/functions/open_api_specs/biztoc/openapi.yaml +21 -0
  22. camel/functions/open_api_specs/create_qr_code/__init__.py +13 -0
  23. camel/functions/open_api_specs/create_qr_code/openapi.yaml +44 -0
  24. camel/functions/open_api_specs/nasa_apod/__init__.py +13 -0
  25. camel/functions/open_api_specs/nasa_apod/openapi.yaml +72 -0
  26. camel/functions/open_api_specs/outschool/__init__.py +13 -0
  27. camel/functions/open_api_specs/outschool/ai-plugin.json +34 -0
  28. camel/functions/open_api_specs/outschool/openapi.yaml +1 -0
  29. camel/functions/open_api_specs/outschool/paths/__init__.py +14 -0
  30. camel/functions/open_api_specs/outschool/paths/get_classes.py +29 -0
  31. camel/functions/open_api_specs/outschool/paths/search_teachers.py +29 -0
  32. camel/functions/open_api_specs/security_config.py +21 -0
  33. camel/functions/open_api_specs/web_scraper/__init__.py +13 -0
  34. camel/functions/open_api_specs/web_scraper/ai-plugin.json +34 -0
  35. camel/functions/open_api_specs/web_scraper/openapi.yaml +71 -0
  36. camel/functions/open_api_specs/web_scraper/paths/__init__.py +13 -0
  37. camel/functions/open_api_specs/web_scraper/paths/scraper.py +29 -0
  38. camel/functions/openai_function.py +3 -1
  39. camel/functions/search_functions.py +104 -171
  40. camel/functions/slack_functions.py +2 -1
  41. camel/human.py +3 -1
  42. camel/loaders/base_io.py +3 -1
  43. camel/loaders/unstructured_io.py +16 -22
  44. camel/messages/base.py +135 -46
  45. camel/models/__init__.py +4 -0
  46. camel/models/anthropic_model.py +20 -14
  47. camel/models/base_model.py +2 -0
  48. camel/models/litellm_model.py +112 -0
  49. camel/models/model_factory.py +8 -1
  50. camel/models/open_source_model.py +1 -0
  51. camel/models/openai_model.py +6 -2
  52. camel/models/zhipuai_model.py +125 -0
  53. camel/prompts/__init__.py +2 -0
  54. camel/prompts/base.py +2 -1
  55. camel/prompts/descripte_video_prompt.py +33 -0
  56. camel/prompts/task_prompt_template.py +9 -3
  57. camel/retrievers/auto_retriever.py +20 -11
  58. camel/retrievers/base.py +4 -2
  59. camel/retrievers/bm25_retriever.py +2 -1
  60. camel/retrievers/cohere_rerank_retriever.py +2 -1
  61. camel/retrievers/vector_retriever.py +10 -4
  62. camel/societies/babyagi_playing.py +2 -1
  63. camel/societies/role_playing.py +2 -1
  64. camel/storages/graph_storages/base.py +1 -0
  65. camel/storages/graph_storages/neo4j_graph.py +5 -3
  66. camel/storages/vectordb_storages/base.py +2 -1
  67. camel/storages/vectordb_storages/milvus.py +5 -2
  68. camel/toolkits/github_toolkit.py +120 -26
  69. camel/types/__init__.py +3 -2
  70. camel/types/enums.py +25 -1
  71. camel/utils/__init__.py +11 -2
  72. camel/utils/commons.py +74 -4
  73. camel/utils/constants.py +26 -0
  74. camel/utils/token_counting.py +58 -5
  75. {camel_ai-0.1.5.dist-info → camel_ai-0.1.5.2.dist-info}/METADATA +29 -13
  76. camel_ai-0.1.5.2.dist-info/RECORD +148 -0
  77. camel_ai-0.1.5.dist-info/RECORD +0 -119
  78. {camel_ai-0.1.5.dist-info → camel_ai-0.1.5.2.dist-info}/WHEEL +0 -0
@@ -17,6 +17,7 @@ from .openai_function import (
17
17
  get_openai_function_schema,
18
18
  get_openai_tool_schema,
19
19
  )
20
+ from .open_api_specs.security_config import openapi_security_config
20
21
 
21
22
  from .google_maps_function import MAP_FUNCS
22
23
  from .math_functions import MATH_FUNCS
@@ -27,10 +28,18 @@ from .twitter_function import TWITTER_FUNCS
27
28
  from .weather_functions import WEATHER_FUNCS
28
29
  from .slack_functions import SLACK_FUNCS
29
30
 
31
+ from .open_api_function import (
32
+ apinames_filepaths_to_funs_schemas,
33
+ generate_apinames_filepaths,
34
+ )
35
+
30
36
  __all__ = [
31
37
  'OpenAIFunction',
32
38
  'get_openai_function_schema',
33
39
  'get_openai_tool_schema',
40
+ 'openapi_security_config',
41
+ 'apinames_filepaths_to_funs_schemas',
42
+ 'generate_apinames_filepaths',
34
43
  'MAP_FUNCS',
35
44
  'MATH_FUNCS',
36
45
  'OPENAPI_FUNCS',
@@ -18,7 +18,7 @@ from typing import Any, Callable, Dict, List, Tuple
18
18
  import prance
19
19
  import requests
20
20
 
21
- from camel.functions import OpenAIFunction
21
+ from camel.functions import OpenAIFunction, openapi_security_config
22
22
  from camel.types import OpenAPIName
23
23
 
24
24
 
@@ -37,8 +37,21 @@ def parse_openapi_file(openapi_spec_path: str) -> Dict[str, Any]:
37
37
  Dict[str, Any]: The parsed OpenAPI specification as a dictionary.
38
38
  """
39
39
  # Load the OpenAPI spec
40
- parser = prance.ResolvingParser(openapi_spec_path)
40
+ parser = prance.ResolvingParser(
41
+ openapi_spec_path, backend="openapi-spec-validator", strict=False
42
+ )
41
43
  openapi_spec = parser.specification
44
+ version = openapi_spec.get('openapi', {})
45
+ if not version:
46
+ raise ValueError(
47
+ "OpenAPI version not specified in the spec. "
48
+ "Only OPENAPI 3.0.x and 3.1.x are supported."
49
+ )
50
+ if not (version.startswith('3.0') or version.startswith('3.1')):
51
+ raise ValueError(
52
+ f"Unsupported OpenAPI version: {version}. "
53
+ f"Only OPENAPI 3.0.x and 3.1.x are supported."
54
+ )
42
55
  return openapi_spec
43
56
 
44
57
 
@@ -176,22 +189,33 @@ def openapi_spec_to_openai_schemas(
176
189
 
177
190
 
178
191
  def openapi_function_decorator(
179
- base_url: str, path: str, method: str, operation: Dict[str, Any]
192
+ api_name: str,
193
+ base_url: str,
194
+ path: str,
195
+ method: str,
196
+ openapi_security: List[Dict[str, Any]],
197
+ sec_schemas: Dict[str, Dict[str, Any]],
198
+ operation: Dict[str, Any],
180
199
  ) -> Callable:
181
- r"""Decorate a function to make HTTP requests based on OpenAPI operation
182
- details.
200
+ r"""Decorate a function to make HTTP requests based on OpenAPI
201
+ specification details.
183
202
 
184
- This decorator takes the base URL, path, HTTP method, and operation details
185
- from an OpenAPI specification, and returns a decorator. The decorated
186
- function can then be called with keyword arguments corresponding to the
187
- operation's parameters. The decorator handles constructing the request URL,
188
- setting headers, query parameters, and the request body as specified by the
189
- operation details.
203
+ This decorator dynamically constructs and executes an API request based on
204
+ the provided OpenAPI operation specifications, security requirements, and
205
+ parameters. It supports operations secured with `apiKey` type security
206
+ schemes and automatically injects the necessary API keys from environment
207
+ variables. Parameters in `path`, `query`, `header`, and `cookie` are also
208
+ supported.
190
209
 
191
210
  Args:
211
+ api_name (str): The name of the API, used to retrieve API key names
212
+ and URLs from the configuration.
192
213
  base_url (str): The base URL for the API.
193
214
  path (str): The path for the API endpoint, relative to the base URL.
194
215
  method (str): The HTTP method (e.g., 'get', 'post') for the request.
216
+ openapi_security (List[Dict[str, Any]]): The global security
217
+ definitions as specified in the OpenAPI specs.
218
+ sec_schemas (Dict[str, Dict[str, Any]]): Detailed security schemes.
195
219
  operation (Dict[str, Any]): A dictionary containing the OpenAPI
196
220
  operation details, including parameters and request body
197
221
  definitions.
@@ -200,6 +224,12 @@ def openapi_function_decorator(
200
224
  Callable: A decorator that, when applied to a function, enables the
201
225
  function to make HTTP requests based on the provided OpenAPI
202
226
  operation details.
227
+
228
+ Raises:
229
+ TypeError: If the security requirements include unsupported types.
230
+ ValueError: If required API keys are missing from environment
231
+ variables or if the content type of the request body is
232
+ unsupported.
203
233
  """
204
234
 
205
235
  def inner_decorator(openapi_function: Callable) -> Callable:
@@ -209,6 +239,51 @@ def openapi_function_decorator(
209
239
  params = {}
210
240
  cookies = {}
211
241
 
242
+ # Security definition of operation overrides any declared
243
+ # top-level security.
244
+ sec_requirements = operation.get('security', openapi_security)
245
+ avail_sec_requirement = {}
246
+ # Write to avaliable_security_requirement only if all the
247
+ # security_type are "apiKey"
248
+ for security_requirement in sec_requirements:
249
+ have_unsupported_type = False
250
+ for sec_scheme_name, _ in security_requirement.items():
251
+ sec_type = sec_schemas.get(sec_scheme_name).get('type')
252
+ if sec_type != "apiKey":
253
+ have_unsupported_type = True
254
+ break
255
+ if have_unsupported_type is False:
256
+ avail_sec_requirement = security_requirement
257
+ break
258
+
259
+ if sec_requirements and not avail_sec_requirement:
260
+ raise TypeError(
261
+ "Only security schemas of type `apiKey` are supported."
262
+ )
263
+
264
+ for sec_scheme_name, _ in avail_sec_requirement.items():
265
+ try:
266
+ API_KEY_NAME = openapi_security_config.get(api_name).get(
267
+ sec_scheme_name
268
+ )
269
+ api_key_value = os.environ[API_KEY_NAME]
270
+ except Exception:
271
+ api_key_url = openapi_security_config.get(api_name).get(
272
+ 'get_api_key_url'
273
+ )
274
+ raise ValueError(
275
+ f"`{API_KEY_NAME}` not found in environment "
276
+ f"variables. Get `{API_KEY_NAME}` here: {api_key_url}"
277
+ )
278
+ request_key_name = sec_schemas.get(sec_scheme_name).get('name')
279
+ request_key_in = sec_schemas.get(sec_scheme_name).get('in')
280
+ if request_key_in == 'query':
281
+ params[request_key_name] = api_key_value
282
+ elif request_key_in == 'header':
283
+ headers[request_key_name] = api_key_value
284
+ elif request_key_in == 'coolie':
285
+ cookies[request_key_name] = api_key_value
286
+
212
287
  # Assign parameters to the correct position
213
288
  for param in operation.get('parameters', []):
214
289
  input_param_name = param['name'] + '_in_' + param['in']
@@ -307,6 +382,10 @@ def generate_openapi_funcs(
307
382
  raise ValueError("No server information found in OpenAPI spec.")
308
383
  base_url = servers[0].get('url') # Use the first server URL
309
384
 
385
+ # Security requirement objects for all methods
386
+ openapi_security = openapi_spec.get('security', {})
387
+ # Security schemas which can be reused by different methods
388
+ sec_schemas = openapi_spec.get('components', {}).get('securitySchemes', {})
310
389
  functions = []
311
390
 
312
391
  # Traverse paths and methods
@@ -321,7 +400,15 @@ def generate_openapi_funcs(
321
400
  sanitized_path = path.replace('/', '_').strip('_')
322
401
  function_name = f"{api_name}_{method}_{sanitized_path}"
323
402
 
324
- @openapi_function_decorator(base_url, path, method, operation)
403
+ @openapi_function_decorator(
404
+ api_name,
405
+ base_url,
406
+ path,
407
+ method,
408
+ openapi_security,
409
+ sec_schemas,
410
+ operation,
411
+ )
325
412
  def openapi_function(**kwargs):
326
413
  pass
327
414
 
@@ -332,13 +419,22 @@ def generate_openapi_funcs(
332
419
  return functions
333
420
 
334
421
 
335
- def combine_all_funcs_schemas() -> Tuple[List[Callable], List[Dict[str, Any]]]:
336
- r"""Combines functions and schemas from multiple OpenAPI specifications.
422
+ def apinames_filepaths_to_funs_schemas(
423
+ apinames_filepaths: List[Tuple[str, str]],
424
+ ) -> Tuple[List[Callable], List[Dict[str, Any]]]:
425
+ r"""Combines functions and schemas from multiple OpenAPI specifications,
426
+ using API names as keys.
427
+
428
+ This function iterates over tuples of API names and OpenAPI spec file
429
+ paths, parsing each spec to generate callable functions and schema
430
+ dictionaries, all organized by API name.
337
431
 
338
- Iterates over a list of OpenAPI specs, parses each, and generates functions
339
- and schemas based on the defined operations and schemas respectively.
340
- Assumes specification files are named 'openapi.yaml' located in
341
- `open_api_specs/<api_name>/`.
432
+ Args:
433
+ apinames_filepaths (List[Tuple[str, str]]): A list of tuples, where each
434
+ tuple consists of:
435
+ - The API name (str) as the first element.
436
+ - The file path (str) to the API's OpenAPI specification file as the
437
+ second element.
342
438
 
343
439
  Returns:
344
440
  Tuple[List[Callable], List[Dict[str, Any]]]:: one of callable
@@ -347,34 +443,59 @@ def combine_all_funcs_schemas() -> Tuple[List[Callable], List[Dict[str, Any]]]:
347
443
  """
348
444
  combined_func_lst = []
349
445
  combined_schemas_list = []
350
-
351
- for api_name in OpenAPIName:
446
+ for api_name, file_path in apinames_filepaths:
352
447
  # Parse the OpenAPI specification for each API
353
448
  current_dir = os.path.dirname(__file__)
354
- spec_file_path = os.path.join(
355
- current_dir, 'open_api_specs', f'{api_name.value}', 'openapi.yaml'
449
+ file_path = os.path.join(
450
+ current_dir, 'open_api_specs', f'{api_name}', 'openapi.yaml'
356
451
  )
357
452
 
358
- openapi_spec = parse_openapi_file(spec_file_path)
453
+ openapi_spec = parse_openapi_file(file_path)
359
454
 
360
455
  # Generate and merge function schemas
361
456
  openapi_functions_schemas = openapi_spec_to_openai_schemas(
362
- api_name.value, openapi_spec
457
+ api_name, openapi_spec
363
458
  )
364
459
  combined_schemas_list.extend(openapi_functions_schemas)
365
460
 
366
461
  # Generate and merge function lists
367
- openapi_functions_list = generate_openapi_funcs(
368
- api_name.value, openapi_spec
369
- )
462
+ openapi_functions_list = generate_openapi_funcs(api_name, openapi_spec)
370
463
  combined_func_lst.extend(openapi_functions_list)
371
464
 
372
465
  return combined_func_lst, combined_schemas_list
373
466
 
374
467
 
375
- combined_funcs_lst, combined_schemas_list = combine_all_funcs_schemas()
468
+ def generate_apinames_filepaths() -> List[Tuple[str, str]]:
469
+ """Generates a list of tuples containing API names and their corresponding
470
+ file paths.
471
+
472
+ This function iterates over the OpenAPIName enum, constructs the file path
473
+ for each API's OpenAPI specification file, and appends a tuple of the API
474
+ name and its file path to the list. The file paths are relative to the
475
+ 'open_api_specs' directory located in the same directory as this script.
476
+
477
+ Returns:
478
+ List[Tuple[str, str]]: A list of tuples where each tuple contains two
479
+ elements. The first element of each tuple is a string representing
480
+ the name of an API, and the second element is a string that
481
+ specifies the file path to that API's OpenAPI specification file.
482
+ """
483
+ apinames_filepaths = []
484
+ current_dir = os.path.dirname(__file__)
485
+ for api_name in OpenAPIName:
486
+ file_path = os.path.join(
487
+ current_dir, 'open_api_specs', f'{api_name.value}', 'openapi.yaml'
488
+ )
489
+ apinames_filepaths.append((api_name.value, file_path))
490
+ return apinames_filepaths
491
+
492
+
493
+ apinames_filepaths = generate_apinames_filepaths()
494
+ all_funcs_lst, all_schemas_lst = apinames_filepaths_to_funs_schemas(
495
+ apinames_filepaths
496
+ )
376
497
 
377
498
  OPENAPI_FUNCS: List[OpenAIFunction] = [
378
499
  OpenAIFunction(a_func, a_schema)
379
- for a_func, a_schema in zip(combined_funcs_lst, combined_schemas_list)
500
+ for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
380
501
  ]
@@ -0,0 +1,13 @@
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. ===========
@@ -0,0 +1,34 @@
1
+ {
2
+ "id": "plugin-da9afb50-fc07-4d30-b606-51ed1b105bfc",
3
+ "domain": "biztoc.com",
4
+ "namespace": "biztoc",
5
+ "status": "approved",
6
+ "manifest": {
7
+ "schema_version": "v1",
8
+ "name_for_model": "biztoc",
9
+ "name_for_human": "BizToc",
10
+ "description_for_model": "Plugin for querying BizToc for business news.",
11
+ "description_for_human": "Search BizToc for business & finance news.",
12
+ "auth": {
13
+ "type": null
14
+ },
15
+ "api": {
16
+ "type": "openapi",
17
+ "url": "https://ai.biztoc.com/openapi.yaml"
18
+ },
19
+ "logo_url": "https://biztoc.com/favicon.png",
20
+ "contact_email": "mail@biztoc.com",
21
+ "legal_info_url": "https://biztoc.com/s/legal"
22
+ },
23
+ "oauth_client_id": null,
24
+ "user_settings": {
25
+ "is_installed": false,
26
+ "is_authenticated": true
27
+ },
28
+ "categories": [
29
+ {
30
+ "id": "newly_added",
31
+ "title": "New"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,21 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: BizToc
4
+ description: Search BizToc for business & finance news.
5
+ version: 'v1'
6
+ servers:
7
+ - url: https://ai.biztoc.com
8
+ paths:
9
+ /ai/news:
10
+ get:
11
+ operationId: getNews
12
+ summary: Retrieves the latest news whose content contains the query string.
13
+ parameters:
14
+ - in: query
15
+ name: query
16
+ schema:
17
+ type: string
18
+ description: Used to query news articles on their title and body. For example, ?query=apple will return news stories that have 'apple' in their title or body.
19
+ responses:
20
+ "200":
21
+ description: OK
@@ -0,0 +1,13 @@
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. ===========
@@ -0,0 +1,44 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: QR Code API
4
+ version: 1.0.0
5
+ description: Create a QR code for any text or url.
6
+ servers:
7
+ - url: https://create-qr-code.modelxy.com
8
+ paths:
9
+ /create-qr-code:
10
+ get:
11
+ operationId: getQRCode
12
+ summary: Create a QR code
13
+ parameters:
14
+ - in: query
15
+ name: data
16
+ schema:
17
+ type: string
18
+ description: The data to encode in the QR code.
19
+ - in: query
20
+ name: size
21
+ schema:
22
+ type: string
23
+ default: '100x100'
24
+ description: The size of the QR code.
25
+ - in: query
26
+ name: alt
27
+ schema:
28
+ type: string
29
+ description: The alt text for the QR code image.
30
+ - in: query
31
+ name: title
32
+ schema:
33
+ type: string
34
+ description: The title for the QR code image.
35
+ responses:
36
+ '200':
37
+ description: A JSON object containing the QR code image tag.
38
+ content:
39
+ application/json:
40
+ schema:
41
+ type: object
42
+ properties:
43
+ img_tag:
44
+ type: string
@@ -0,0 +1,13 @@
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. ===========
@@ -0,0 +1,72 @@
1
+ openapi: 3.0.0
2
+ servers:
3
+ - url: https://api.nasa.gov/planetary
4
+ - url: http://api.nasa.gov/planetary
5
+ info:
6
+ contact:
7
+ email: evan.t.yates@nasa.gov
8
+ description: This endpoint structures the APOD imagery and associated metadata
9
+ so that it can be repurposed for other applications. In addition, if the
10
+ concept_tags parameter is set to True, then keywords derived from the image
11
+ explanation are returned. These keywords could be used as auto-generated
12
+ hashtags for twitter or instagram feeds; but generally help with
13
+ discoverability of relevant imagery
14
+ license:
15
+ name: Apache 2.0
16
+ url: http://www.apache.org/licenses/LICENSE-2.0.html
17
+ title: APOD
18
+ version: 1.0.0
19
+ x-apisguru-categories:
20
+ - media
21
+ - open_data
22
+ x-origin:
23
+ - format: swagger
24
+ url: https://raw.githubusercontent.com/nasa/api-docs/gh-pages/assets/json/APOD
25
+ version: "2.0"
26
+ x-providerName: nasa.gov
27
+ x-serviceName: apod
28
+ tags:
29
+ - description: An example tag
30
+ externalDocs:
31
+ description: Here's a link
32
+ url: https://example.com
33
+ name: request tag
34
+ paths:
35
+ /apod:
36
+ get:
37
+ description: Returns the picture of the day
38
+ parameters:
39
+ - description: The date of the APOD image to retrieve
40
+ in: query
41
+ name: date
42
+ required: false
43
+ schema:
44
+ type: string
45
+ - description: Retrieve the URL for the high resolution image
46
+ in: query
47
+ name: hd
48
+ required: false
49
+ schema:
50
+ type: boolean
51
+ responses:
52
+ "200":
53
+ content:
54
+ application/json:
55
+ schema:
56
+ items:
57
+ x-thing: ok
58
+ type: array
59
+ description: successful operation
60
+ "400":
61
+ description: Date must be between Jun 16, 1995 and Mar 28, 2019.
62
+ security:
63
+ - api_key: []
64
+ summary: Returns images
65
+ tags:
66
+ - request tag
67
+ components:
68
+ securitySchemes:
69
+ api_key:
70
+ in: query
71
+ name: api_key
72
+ type: apiKey
@@ -0,0 +1,13 @@
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. ===========
@@ -0,0 +1,34 @@
1
+ {
2
+ "id": "plugin-9335c256-4658-4376-bac8-a0baa5c1c889",
3
+ "domain": "chatgpt-plugin.outschool.com",
4
+ "namespace": "Outschool",
5
+ "status": "approved",
6
+ "manifest": {
7
+ "schema_version": "v1",
8
+ "name_for_model": "Outschool",
9
+ "name_for_human": "Outschool",
10
+ "description_for_model": "Search for top-quality online classes and teachers on Outschool.",
11
+ "description_for_human": "Search for top-quality online classes and teachers on Outschool.",
12
+ "auth": {
13
+ "type": "none"
14
+ },
15
+ "api": {
16
+ "type": "openapi",
17
+ "url": "https://chatgpt-plugin.outschool.com/openapi.json"
18
+ },
19
+ "logo_url": "https://chatgpt-plugin.outschool.com/logo.png",
20
+ "contact_email": "support@outschool.com",
21
+ "legal_info_url": "https://outschool.com/terms"
22
+ },
23
+ "oauth_client_id": null,
24
+ "user_settings": {
25
+ "is_installed": false,
26
+ "is_authenticated": true
27
+ },
28
+ "categories": [
29
+ {
30
+ "id": "newly_added",
31
+ "title": "New"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1 @@
1
+ {"openapi":"3.0.1","info":{"title":"Outschool Plugin","description":"Search for top-quality online classes and teachers on Outschool.","version":"v1"},"servers":[{"url":"https://chatgpt-plugin.outschool.com/api"}],"paths":{"/classes":{"get":{"operationId":"searchClasses","description":"Returns a list of online classes","parameters":[{"name":"timeZone","in":"query","required":true,"description":"IANA Time Zone identifier of the user. Either provided by user or derived from their location. Since Outschool parents and teachers can be from different time zones, this is required to search classes that are available in parent's timezone at reasonable hours. Only IANA format is accepted.","schema":{"type":"string"},"examples":{"losAngeles":{"value":"America/Los_Angeles"},"newYork":{"value":"America/New_York"},"london":{"value":"Europe/London"}}},{"name":"age","in":"query","required":true,"description":"Outschool has several classes serving different age groups. The age of the learner(s) helps to find classes that match the best. This is a comma separated list. If the age difference between the children is more than 5 years, it may be better to search for different ages separately to get better search results.","schema":{"type":"string","minimum":3,"maximum":18},"examples":{"12":{"value":"12"},"1213":{"value":"12,13"},"5617":{"value":"5,6,17"}}},{"name":"q","in":"query","required":false,"description":"Keywords to use to search in the class list. Classes matching the keyword closest will be returned.","schema":{"type":"string"}},{"name":"delivery","in":"query","required":false,"explode":true,"description":"Filters classes by delivery type. Description for different enum values:\n One-time: Classes that meets once\n Ongoing: Weekly classes that learners can enroll in any week\n Semester course: Multi-week/session classes, usually more than 4 weeks\n Short course: Multi-week/session classes, usually around 4 weeks\n Camp: Semester or short courses during summer and school breaks\n Group: Async chat groups on a specific topic where learners share ideas and experiences, like clubs","schema":{"type":"array","items":{"type":"string","enum":["One-time","Ongoing","Semester course","Short course","Camp","Group"]}}},{"name":"userUid","in":"query","required":false,"description":"Only search classes taught by a specific teacher. The userUid is the id of the teacher","schema":{"type":"string","format":"uuid"}},{"name":"order","in":"query","description":"Sort results by either upcoming, new, or relevance. Upcoming sorts by next section start date in ascending order, new sorts by class published date in descending order, and relevance sorts by the keyword relevance and popularity of the class.","schema":{"type":"string","enum":["upcoming","new","relevance"],"default":"relevance"}},{"name":"offset","in":"query","required":false,"description":"The offset for the results. Offset and limit used in combination to paginate in results. For instance, if limit is 10, to get next 10 results, the offset should be set to 10.","schema":{"type":"number","default":0}},{"name":"limit","in":"query","required":false,"description":"Number of results to return.","schema":{"type":"number","default":10}},{"name":"startAfter","in":"query","required":false,"description":"Search classes that have a section starting on or after a given date. Only today or future dates are allowed.","schema":{"type":"string","format":"date"},"examples":{"April152023":{"value":"2023-04-15"}}},{"name":"dow","in":"query","description":"The day of week to filter classes and only return classes that have a section on given days of the week.","schema":{"type":"array","items":{"type":"string","enum":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]}},"style":"form","explode":true,"required":false,"examples":{"Mon":{"value":"Mon"},"Mon_Tue":{"value":"Mon,Tue"},"Mon_Thu":{"value":"Mon,Tue,Wed,Thu"},"Weekdays":{"value":"Mon,Tue,Wed,Thu,Fri"},"Weekend":{"value":"Sat, Sun"}}},{"name":"startAfterTime","in":"query","description":"The start time of the class in 24 hour format as hour of the day normalized by the user's timezone","schema":{"type":"number","minimum":6,"maximum":22}},{"name":"endByTime","in":"query","description":"The end time of the class in 24 hour format as hour of the day normalized by the user's timezone","schema":{"type":"number","minimum":6,"maximum":22}}],"responses":{"200":{"description":"A list of classes","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/class"}}}}}}}},"/teachers":{"get":{"operationId":"searchTeachers","description":"Returns a list of teachers","parameters":[{"name":"name","in":"query","required":true,"description":"Name of the teacher to search for","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Number of results to return.","schema":{"type":"number","default":10}}],"responses":{"200":{"description":"A list of teachers","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/teacher"}}}}}}}}},"components":{"schemas":{"class":{"type":"object","properties":{"uid":{"type":"string","format":"uuid","description":"Unique ID of the class in the system that can be used in other API end points"},"title":{"type":"string","description":"Title of the class"},"summary":{"type":"string","description":"Summary of the class"},"url":{"type":"string","format":"uri","description":"URL to the class detail page"},"photo":{"type":"string","format":"uri","description":"Photo of the class"},"is_ongoing_weekly":{"type":"boolean","description":"Whether this class is an ongoing class or not. When a class is an ongoing class, parents can enroll their children for any week of an ongoing class, because the sections of that class meet every week and the weeks don't depend on each other."},"age_min":{"type":"number","description":"The minimum age a learner should be to enroll in the class. Although Outschool has classes for different age groups, individual classes may only be appropriate for a certain age range."},"age_max":{"type":"number","description":"The maximum age a learner should be to enroll in the class. Although Outschool has classes for different age groups, individual classes may only be appropriate for a certain age range."},"teacher":{"$ref":"#/components/schemas/teacher"},"nextSection":{"$ref":"#/components/schemas/section","nullable":true,"description":"The next section of the class that the parent/caregiver can enroll their children in. This is usually what parents are looking for to enroll in a class."}}},"teacher":{"type":"object","properties":{"uid":{"type":"string","format":"uuid","description":"Unique ID of the teacher in the system that can be used in other API end points"},"name":{"type":"string","description":"Name of the teacher"},"about":{"type":"string","description":"A short summary the teacher provides about themselves"},"photo":{"type":"string","format":"uri","description":"Photo of the teacher"},"url":{"type":"string","format":"uri","description":"URL to the Outschool profile page of the teacher"}}},"section":{"type":"object","description":"Sections are what parents enroll their children in for a given class. They are separate cohorts of a class.","properties":{"uid":{"type":"string","format":"uuid","description":"Unique ID of the section in the system that can be used in other API end points"},"url":{"type":"string","format":"uri","description":"URL pointing to the section page"},"start_time":{"type":"string","format":"datetime","description":"The start time for the first meeting of a section."},"end_time":{"type":"string","format":"datetime","description":"The end time for the last meeting of a section."},"size_max":{"type":"number","description":"How many learners can enroll in the section."},"filledSpaceCount":{"type":"number","description":"How many learners are enrolled in the section. size_max - filledSpaceCount gives how many seats are left to enroll in."},"nextOngoingMeeting":{"$ref":"#/components/schemas/meeting","nullable":true,"description":"If the class is an ongoing class, this points to the next meeting for the section."}}},"meeting":{"type":"object","description":"The online meeting for a section. Meetings are held on Zoom.","properties":{"uid":{"type":"string","format":"uuid","description":"Unique ID of the meeting in the system that can be used in other API end points"},"start_time":{"type":"string","format":"datetime","description":"The start time of the meeting."},"end_time":{"type":"string","format":"datetime","description":"The end time of the meeting."}}}}}}
@@ -0,0 +1,14 @@
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
+ path_dict = {"get_classes": "/classes", "search_teachers": "/teachers"}
@@ -0,0 +1,29 @@
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
+ """Get classes from Outschool API."""
15
+
16
+ from typing import Any, Dict
17
+
18
+ import requests
19
+
20
+
21
+ def call_api(input_json: Dict[str, Any]) -> Dict[str, Any]:
22
+ response = requests.get(
23
+ "https://chatgpt-plugin.outschool.com/api/classes", params=input_json
24
+ )
25
+
26
+ if response.status_code == 200:
27
+ return response.json()
28
+ else:
29
+ return {"status_code": response.status_code, "text": response.text}