camel-ai 0.1.1__py3-none-any.whl → 0.1.4__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 (117) hide show
  1. camel/__init__.py +1 -11
  2. camel/agents/__init__.py +7 -5
  3. camel/agents/chat_agent.py +134 -86
  4. camel/agents/critic_agent.py +28 -17
  5. camel/agents/deductive_reasoner_agent.py +235 -0
  6. camel/agents/embodied_agent.py +92 -40
  7. camel/agents/knowledge_graph_agent.py +221 -0
  8. camel/agents/role_assignment_agent.py +27 -17
  9. camel/agents/task_agent.py +60 -34
  10. camel/agents/tool_agents/base.py +0 -1
  11. camel/agents/tool_agents/hugging_face_tool_agent.py +7 -4
  12. camel/configs/__init__.py +29 -0
  13. camel/configs/anthropic_config.py +73 -0
  14. camel/configs/base_config.py +22 -0
  15. camel/{configs.py → configs/openai_config.py} +37 -64
  16. camel/embeddings/__init__.py +2 -0
  17. camel/embeddings/base.py +3 -2
  18. camel/embeddings/openai_embedding.py +10 -5
  19. camel/embeddings/sentence_transformers_embeddings.py +65 -0
  20. camel/functions/__init__.py +18 -3
  21. camel/functions/google_maps_function.py +335 -0
  22. camel/functions/math_functions.py +7 -7
  23. camel/functions/open_api_function.py +380 -0
  24. camel/functions/open_api_specs/coursera/__init__.py +13 -0
  25. camel/functions/open_api_specs/coursera/openapi.yaml +82 -0
  26. camel/functions/open_api_specs/klarna/__init__.py +13 -0
  27. camel/functions/open_api_specs/klarna/openapi.yaml +87 -0
  28. camel/functions/open_api_specs/speak/__init__.py +13 -0
  29. camel/functions/open_api_specs/speak/openapi.yaml +151 -0
  30. camel/functions/openai_function.py +346 -42
  31. camel/functions/retrieval_functions.py +61 -0
  32. camel/functions/search_functions.py +100 -35
  33. camel/functions/slack_functions.py +275 -0
  34. camel/functions/twitter_function.py +484 -0
  35. camel/functions/weather_functions.py +36 -23
  36. camel/generators.py +65 -46
  37. camel/human.py +17 -11
  38. camel/interpreters/__init__.py +25 -0
  39. camel/interpreters/base.py +49 -0
  40. camel/{utils/python_interpreter.py → interpreters/internal_python_interpreter.py} +129 -48
  41. camel/interpreters/interpreter_error.py +19 -0
  42. camel/interpreters/subprocess_interpreter.py +190 -0
  43. camel/loaders/__init__.py +22 -0
  44. camel/{functions/base_io_functions.py → loaders/base_io.py} +38 -35
  45. camel/{functions/unstructured_io_fuctions.py → loaders/unstructured_io.py} +199 -110
  46. camel/memories/__init__.py +17 -7
  47. camel/memories/agent_memories.py +156 -0
  48. camel/memories/base.py +97 -32
  49. camel/memories/blocks/__init__.py +21 -0
  50. camel/memories/{chat_history_memory.py → blocks/chat_history_block.py} +34 -34
  51. camel/memories/blocks/vectordb_block.py +101 -0
  52. camel/memories/context_creators/__init__.py +3 -2
  53. camel/memories/context_creators/score_based.py +32 -20
  54. camel/memories/records.py +6 -5
  55. camel/messages/__init__.py +2 -2
  56. camel/messages/base.py +99 -16
  57. camel/messages/func_message.py +7 -4
  58. camel/models/__init__.py +6 -2
  59. camel/models/anthropic_model.py +146 -0
  60. camel/models/base_model.py +10 -3
  61. camel/models/model_factory.py +17 -11
  62. camel/models/open_source_model.py +25 -13
  63. camel/models/openai_audio_models.py +251 -0
  64. camel/models/openai_model.py +20 -13
  65. camel/models/stub_model.py +10 -5
  66. camel/prompts/__init__.py +7 -5
  67. camel/prompts/ai_society.py +21 -14
  68. camel/prompts/base.py +54 -47
  69. camel/prompts/code.py +22 -14
  70. camel/prompts/evaluation.py +8 -5
  71. camel/prompts/misalignment.py +26 -19
  72. camel/prompts/object_recognition.py +35 -0
  73. camel/prompts/prompt_templates.py +14 -8
  74. camel/prompts/role_description_prompt_template.py +16 -10
  75. camel/prompts/solution_extraction.py +9 -5
  76. camel/prompts/task_prompt_template.py +24 -21
  77. camel/prompts/translation.py +9 -5
  78. camel/responses/agent_responses.py +5 -2
  79. camel/retrievers/__init__.py +26 -0
  80. camel/retrievers/auto_retriever.py +330 -0
  81. camel/retrievers/base.py +69 -0
  82. camel/retrievers/bm25_retriever.py +140 -0
  83. camel/retrievers/cohere_rerank_retriever.py +108 -0
  84. camel/retrievers/vector_retriever.py +183 -0
  85. camel/societies/__init__.py +1 -1
  86. camel/societies/babyagi_playing.py +56 -32
  87. camel/societies/role_playing.py +188 -133
  88. camel/storages/__init__.py +18 -0
  89. camel/storages/graph_storages/__init__.py +23 -0
  90. camel/storages/graph_storages/base.py +82 -0
  91. camel/storages/graph_storages/graph_element.py +74 -0
  92. camel/storages/graph_storages/neo4j_graph.py +582 -0
  93. camel/storages/key_value_storages/base.py +1 -2
  94. camel/storages/key_value_storages/in_memory.py +1 -2
  95. camel/storages/key_value_storages/json.py +8 -13
  96. camel/storages/vectordb_storages/__init__.py +33 -0
  97. camel/storages/vectordb_storages/base.py +202 -0
  98. camel/storages/vectordb_storages/milvus.py +396 -0
  99. camel/storages/vectordb_storages/qdrant.py +373 -0
  100. camel/terminators/__init__.py +1 -1
  101. camel/terminators/base.py +2 -3
  102. camel/terminators/response_terminator.py +21 -12
  103. camel/terminators/token_limit_terminator.py +5 -3
  104. camel/toolkits/__init__.py +21 -0
  105. camel/toolkits/base.py +22 -0
  106. camel/toolkits/github_toolkit.py +245 -0
  107. camel/types/__init__.py +18 -6
  108. camel/types/enums.py +129 -15
  109. camel/types/openai_types.py +10 -5
  110. camel/utils/__init__.py +20 -13
  111. camel/utils/commons.py +170 -85
  112. camel/utils/token_counting.py +135 -15
  113. {camel_ai-0.1.1.dist-info → camel_ai-0.1.4.dist-info}/METADATA +123 -75
  114. camel_ai-0.1.4.dist-info/RECORD +119 -0
  115. {camel_ai-0.1.1.dist-info → camel_ai-0.1.4.dist-info}/WHEEL +1 -1
  116. camel/memories/context_creators/base.py +0 -72
  117. camel_ai-0.1.1.dist-info/RECORD +0 -75
@@ -0,0 +1,380 @@
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, Tuple
17
+
18
+ import prance
19
+ import requests
20
+
21
+ from camel.functions import OpenAIFunction
22
+ from camel.types import OpenAPIName
23
+
24
+
25
+ def parse_openapi_file(openapi_spec_path: str) -> Dict[str, Any]:
26
+ r"""Load and parse an OpenAPI specification file.
27
+
28
+ This function utilizes the `prance.ResolvingParser` to parse and resolve
29
+ the given OpenAPI specification file, returning the parsed OpenAPI
30
+ specification as a dictionary.
31
+
32
+ Args:
33
+ openapi_spec_path (str): The file path or URL to the OpenAPI
34
+ specification.
35
+
36
+ Returns:
37
+ Dict[str, Any]: The parsed OpenAPI specification as a dictionary.
38
+ """
39
+ # Load the OpenAPI spec
40
+ parser = prance.ResolvingParser(openapi_spec_path)
41
+ openapi_spec = parser.specification
42
+ return openapi_spec
43
+
44
+
45
+ def openapi_spec_to_openai_schemas(
46
+ api_name: str, openapi_spec: Dict[str, Any]
47
+ ) -> List[Dict[str, Any]]:
48
+ r"""Convert OpenAPI specification to OpenAI schema format.
49
+
50
+ This function iterates over the paths and operations defined in an
51
+ OpenAPI specification, filtering out deprecated operations. For each
52
+ operation, it constructs a schema in a format suitable for OpenAI,
53
+ including operation metadata such as function name, description,
54
+ parameters, and request bodies. It raises a ValueError if an operation
55
+ lacks a description or summary.
56
+
57
+ Args:
58
+ api_name (str): The name of the API, used to prefix generated function
59
+ names.
60
+ openapi_spec (Dict[str, Any]): The OpenAPI specification as a
61
+ dictionary.
62
+
63
+ Returns:
64
+ List[Dict[str, Any]]: A list of dictionaries, each representing a
65
+ function in the OpenAI schema format, including details about the
66
+ function's name, description, and parameters.
67
+
68
+ Raises:
69
+ ValueError: If an operation in the OpenAPI specification does not have
70
+ a description or summary.
71
+
72
+ Note:
73
+ This function assumes that the OpenAPI specification follows the 3.0+
74
+ format.
75
+
76
+ Reference:
77
+ https://swagger.io/specification/
78
+ """
79
+ result = []
80
+
81
+ for path, path_item in openapi_spec.get('paths', {}).items():
82
+ for method, op in path_item.items():
83
+ if op.get('deprecated') is True:
84
+ continue
85
+
86
+ # Get the function name from the operationId
87
+ # or construct it from the API method, and path
88
+ function_name = f"{api_name}"
89
+ operation_id = op.get('operationId')
90
+ if operation_id:
91
+ function_name += f"_{operation_id}"
92
+ else:
93
+ function_name += f"{method}{path.replace('/', '_')}"
94
+
95
+ description = op.get('description') or op.get('summary')
96
+ if not description:
97
+ raise ValueError(
98
+ f"{method} {path} Operation from {api_name} "
99
+ f"does not have a description or summary."
100
+ )
101
+ description += " " if description[-1] != " " else ""
102
+ description += f"This function is from {api_name} API. "
103
+
104
+ # If the OpenAPI spec has a description,
105
+ # add it to the operation description
106
+ if 'description' in openapi_spec.get('info', {}):
107
+ description += f"{openapi_spec['info']['description']}"
108
+
109
+ # Get the parameters for the operation, if any
110
+ params = op.get('parameters', [])
111
+ properties: Dict[str, Any] = {}
112
+ required = []
113
+
114
+ for param in params:
115
+ if not param.get('deprecated', False):
116
+ param_name = param['name'] + '_in_' + param['in']
117
+ properties[param_name] = {}
118
+
119
+ if 'description' in param:
120
+ properties[param_name]['description'] = param[
121
+ 'description'
122
+ ]
123
+
124
+ if 'schema' in param:
125
+ if (
126
+ properties[param_name].get('description')
127
+ and 'description' in param['schema']
128
+ ):
129
+ param['schema'].pop('description')
130
+ properties[param_name].update(param['schema'])
131
+
132
+ if param.get('required'):
133
+ required.append(param_name)
134
+
135
+ # If the property dictionary does not have a description,
136
+ # use the parameter name as the description
137
+ if 'description' not in properties[param_name]:
138
+ properties[param_name]['description'] = param['name']
139
+
140
+ if 'type' not in properties[param_name]:
141
+ properties[param_name]['type'] = 'Any'
142
+
143
+ # Process requestBody if present
144
+ if 'requestBody' in op:
145
+ properties['requestBody'] = {}
146
+ requestBody = op['requestBody']
147
+ if requestBody.get('required') is True:
148
+ required.append('requestBody')
149
+
150
+ content = requestBody.get('content', {})
151
+ json_content = content.get('application/json', {})
152
+ json_schema = json_content.get('schema', {})
153
+ if json_schema:
154
+ properties['requestBody'] = json_schema
155
+ if 'description' not in properties['requestBody']:
156
+ properties['requestBody']['description'] = (
157
+ "The request body, with parameters specifically "
158
+ "described under the `properties` key"
159
+ )
160
+
161
+ function = {
162
+ "type": "function",
163
+ "function": {
164
+ "name": function_name,
165
+ "description": description,
166
+ "parameters": {
167
+ "type": "object",
168
+ "properties": properties,
169
+ "required": required,
170
+ },
171
+ },
172
+ }
173
+ result.append(function)
174
+
175
+ return result # Return the result list
176
+
177
+
178
+ def openapi_function_decorator(
179
+ base_url: str, path: str, method: str, operation: Dict[str, Any]
180
+ ) -> Callable:
181
+ r"""Decorate a function to make HTTP requests based on OpenAPI operation
182
+ details.
183
+
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.
190
+
191
+ Args:
192
+ base_url (str): The base URL for the API.
193
+ path (str): The path for the API endpoint, relative to the base URL.
194
+ method (str): The HTTP method (e.g., 'get', 'post') for the request.
195
+ operation (Dict[str, Any]): A dictionary containing the OpenAPI
196
+ operation details, including parameters and request body
197
+ definitions.
198
+
199
+ Returns:
200
+ Callable: A decorator that, when applied to a function, enables the
201
+ function to make HTTP requests based on the provided OpenAPI
202
+ operation details.
203
+ """
204
+
205
+ def inner_decorator(openapi_function: Callable) -> Callable:
206
+ def wrapper(**kwargs):
207
+ request_url = f"{base_url.rstrip('/')}/{path.lstrip('/')}"
208
+ headers = {}
209
+ params = {}
210
+ cookies = {}
211
+
212
+ # Assign parameters to the correct position
213
+ for param in operation.get('parameters', []):
214
+ input_param_name = param['name'] + '_in_' + param['in']
215
+ # Irrelevant arguments does not affect function operation
216
+ if input_param_name in kwargs:
217
+ if param['in'] == 'path':
218
+ request_url = request_url.replace(
219
+ f"{{{param['name']}}}",
220
+ str(kwargs[input_param_name]),
221
+ )
222
+ elif param['in'] == 'query':
223
+ params[param['name']] = kwargs[input_param_name]
224
+ elif param['in'] == 'header':
225
+ headers[param['name']] = kwargs[input_param_name]
226
+ elif param['in'] == 'cookie':
227
+ cookies[param['name']] = kwargs[input_param_name]
228
+
229
+ if 'requestBody' in operation:
230
+ request_body = kwargs.get('requestBody', {})
231
+ content_type_list = list(
232
+ operation.get('requestBody', {}).get('content', {}).keys()
233
+ )
234
+ if content_type_list:
235
+ content_type = content_type_list[0]
236
+ headers.update({"Content-Type": content_type})
237
+
238
+ # send the request body based on the Content-Type
239
+ if content_type == "application/json":
240
+ response = requests.request(
241
+ method.upper(),
242
+ request_url,
243
+ params=params,
244
+ headers=headers,
245
+ cookies=cookies,
246
+ json=request_body,
247
+ )
248
+ else:
249
+ raise ValueError(
250
+ f"Unsupported content type: {content_type}"
251
+ )
252
+ else:
253
+ # If there is no requestBody, no request body is sent
254
+ response = requests.request(
255
+ method.upper(),
256
+ request_url,
257
+ params=params,
258
+ headers=headers,
259
+ cookies=cookies,
260
+ )
261
+
262
+ try:
263
+ return response.json()
264
+ except json.JSONDecodeError:
265
+ raise ValueError(
266
+ "Response could not be decoded as JSON. "
267
+ "Please check the input parameters."
268
+ )
269
+
270
+ return wrapper
271
+
272
+ return inner_decorator
273
+
274
+
275
+ def generate_openapi_funcs(
276
+ api_name: str, openapi_spec: Dict[str, Any]
277
+ ) -> List[Callable]:
278
+ r"""Generates a list of Python functions based on an OpenAPI specification.
279
+
280
+ This function dynamically creates a list of callable functions that
281
+ represent the API operations defined in an OpenAPI specification document.
282
+ Each function is designed to perform an HTTP request corresponding to an
283
+ API operation (e.g., GET, POST) as defined in the specification. The
284
+ functions are decorated with `openapi_function_decorator`, which
285
+ configures them to construct and send the HTTP requests with appropriate
286
+ parameters, headers, and body content.
287
+
288
+ Args:
289
+ api_name (str): The name of the API, used to prefix generated function
290
+ names.
291
+ openapi_spec (Dict[str, Any]): The OpenAPI specification as a
292
+ dictionary.
293
+
294
+ Returns:
295
+ List[Callable]: A list containing the generated functions. Each
296
+ function, when called, will make an HTTP request according to its
297
+ corresponding API operation defined in the OpenAPI specification.
298
+
299
+ Raises:
300
+ ValueError: If the OpenAPI specification does not contain server
301
+ information, which is necessary for determining the base URL for
302
+ the API requests.
303
+ """
304
+ # Check server information
305
+ servers = openapi_spec.get('servers', [])
306
+ if not servers:
307
+ raise ValueError("No server information found in OpenAPI spec.")
308
+ base_url = servers[0].get('url') # Use the first server URL
309
+
310
+ functions = []
311
+
312
+ # Traverse paths and methods
313
+ for path, methods in openapi_spec.get('paths', {}).items():
314
+ for method, operation in methods.items():
315
+ # Get the function name from the operationId
316
+ # or construct it from the API method, and path
317
+ operation_id = operation.get('operationId')
318
+ if operation_id:
319
+ function_name = f"{api_name}_{operation_id}"
320
+ else:
321
+ sanitized_path = path.replace('/', '_').strip('_')
322
+ function_name = f"{api_name}_{method}_{sanitized_path}"
323
+
324
+ @openapi_function_decorator(base_url, path, method, operation)
325
+ def openapi_function(**kwargs):
326
+ pass
327
+
328
+ openapi_function.__name__ = function_name
329
+
330
+ functions.append(openapi_function)
331
+
332
+ return functions
333
+
334
+
335
+ def combine_all_funcs_schemas() -> Tuple[List[Callable], List[Dict[str, Any]]]:
336
+ r"""Combines functions and schemas from multiple OpenAPI specifications.
337
+
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>/`.
342
+
343
+ Returns:
344
+ Tuple[List[Callable], List[Dict[str, Any]]]:: one of callable
345
+ functions for API operations, and another of dictionaries
346
+ representing the schemas from the specifications.
347
+ """
348
+ combined_func_lst = []
349
+ combined_schemas_list = []
350
+
351
+ for api_name in OpenAPIName:
352
+ # Parse the OpenAPI specification for each API
353
+ 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'
356
+ )
357
+
358
+ openapi_spec = parse_openapi_file(spec_file_path)
359
+
360
+ # Generate and merge function schemas
361
+ openapi_functions_schemas = openapi_spec_to_openai_schemas(
362
+ api_name.value, openapi_spec
363
+ )
364
+ combined_schemas_list.extend(openapi_functions_schemas)
365
+
366
+ # Generate and merge function lists
367
+ openapi_functions_list = generate_openapi_funcs(
368
+ api_name.value, openapi_spec
369
+ )
370
+ combined_func_lst.extend(openapi_functions_list)
371
+
372
+ return combined_func_lst, combined_schemas_list
373
+
374
+
375
+ combined_funcs_lst, combined_schemas_list = combine_all_funcs_schemas()
376
+
377
+ OPENAPI_FUNCS: List[OpenAIFunction] = [
378
+ OpenAIFunction(a_func, a_schema)
379
+ for a_func, a_schema in zip(combined_funcs_lst, combined_schemas_list)
380
+ ]
@@ -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,82 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: Search API
4
+ version: v1
5
+ description: Find recommendation for courses, specializations, and degrees on Coursera.
6
+ servers:
7
+ - url: https://www.coursera.org
8
+ description: API schema for search APIs exposed to 3rd party services (e.g. OpenAI)
9
+ tags:
10
+ - name: SearchV1Controller
11
+ description: the Search V1 Controller API
12
+ paths:
13
+ /api/rest/v1/search:
14
+ post:
15
+ summary:
16
+ A public API that searches the Coursera catalog for products (e.g. courses) that
17
+ are relevant to the provided query string.
18
+ tags:
19
+ - search-v1-controller
20
+ operationId:
21
+ search
22
+ requestBody:
23
+ content:
24
+ application/json:
25
+ schema:
26
+ $ref: '#/components/schemas/SearchQuery'
27
+ required: true
28
+ responses:
29
+ "200":
30
+ description: OK
31
+ content:
32
+ application/json:
33
+ schema:
34
+ $ref: '#/components/schemas/SearchResponse'
35
+ components:
36
+ schemas:
37
+ SearchQuery:
38
+ type: object
39
+ properties:
40
+ query:
41
+ type: string
42
+ required:
43
+ - query
44
+ example:
45
+ query: machine learning
46
+ SearchResponse:
47
+ properties:
48
+ hits:
49
+ type: array
50
+ items:
51
+ $ref: '#/components/schemas/SearchHit'
52
+ SearchHit:
53
+ type: object
54
+ properties:
55
+ name:
56
+ type: string
57
+ partners:
58
+ type: array
59
+ items:
60
+ type: string
61
+ duration:
62
+ type: string
63
+ partnerLogos:
64
+ type: array
65
+ items:
66
+ type: string
67
+ productDifficultyLevel:
68
+ type: string
69
+ entityType:
70
+ type: string
71
+ avgProductRating:
72
+ type: string
73
+ skills:
74
+ type: string
75
+ imageUrl:
76
+ type: string
77
+ isCourseFree:
78
+ type: string
79
+ isPartOfCourseraPlus:
80
+ type: string
81
+ objectUrl:
82
+ 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,87 @@
1
+ ---
2
+ openapi: 3.0.1
3
+ info:
4
+ version: v0
5
+ title: Open AI Klarna product Api
6
+ description: Search and compare prices from thousands of online shops. Only available in the US.
7
+ servers:
8
+ - url: https://www.klarna.com/us/shopping
9
+ tags:
10
+ - name: open-ai-product-endpoint
11
+ description: Open AI Product Endpoint. Query for products.
12
+ paths:
13
+ "/public/openai/v0/products":
14
+ get:
15
+ tags:
16
+ - open-ai-product-endpoint
17
+ summary: API for fetching Klarna product information
18
+ operationId: productsUsingGET
19
+ parameters:
20
+ - name: q
21
+ in: query
22
+ description: A precise query that matches one very small category or product
23
+ that needs to be searched for to find the products the user is looking for.
24
+ If the user explicitly stated what they want, use that as a query. The query
25
+ is as specific as possible to the product name or category mentioned by
26
+ the user in its singular form, and don't contain any clarifiers like latest,
27
+ newest, cheapest, budget, premium, expensive or similar. The query is always
28
+ taken from the latest topic, if there is a new topic a new query is started.
29
+ required: true
30
+ schema:
31
+ type: string
32
+ - name: size
33
+ in: query
34
+ description: number of products returned
35
+ required: false
36
+ schema:
37
+ type: integer
38
+ - name: min_price
39
+ in: query
40
+ description: "(Optional) Minimum price in local currency for the product searched
41
+ for. Either explicitly stated by the user or implicitly inferred from a
42
+ combination of the user's request and the kind of product searched for."
43
+ required: false
44
+ schema:
45
+ type: integer
46
+ - name: max_price
47
+ in: query
48
+ description: "(Optional) Maximum price in local currency for the product searched
49
+ for. Either explicitly stated by the user or implicitly inferred from a
50
+ combination of the user's request and the kind of product searched for."
51
+ required: false
52
+ schema:
53
+ type: integer
54
+ responses:
55
+ '200':
56
+ description: Products found
57
+ content:
58
+ application/json:
59
+ schema:
60
+ "$ref": "#/components/schemas/ProductResponse"
61
+ '503':
62
+ description: one or more services are unavailable
63
+ deprecated: false
64
+ components:
65
+ schemas:
66
+ Product:
67
+ type: object
68
+ properties:
69
+ attributes:
70
+ type: array
71
+ items:
72
+ type: string
73
+ name:
74
+ type: string
75
+ price:
76
+ type: string
77
+ url:
78
+ type: string
79
+ title: Product
80
+ ProductResponse:
81
+ type: object
82
+ properties:
83
+ products:
84
+ type: array
85
+ items:
86
+ "$ref": "#/components/schemas/Product"
87
+ title: ProductResponse
@@ -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. ===========