mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-18 02:32:04 -05:00
add benchmark endpoints mock (#5221)
Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
This commit is contained in:
15
benchmark/agent_protocol_client/README.md
Normal file
15
benchmark/agent_protocol_client/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Agent Communication Protocol - Python Client
|
||||
|
||||
Python client for Agent Communication Protocol. This client simplifies the communication with the agent.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install agent-protocol-client
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
You can find simple usage in the example [here](./examples/minimal.py).
|
||||
|
||||
For more functionalities look at the [API docs](./docs/AgentApi.md).
|
||||
@@ -0,0 +1,42 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
__version__ = "1.0.0"
|
||||
|
||||
# import apis into sdk package
|
||||
from agent_protocol_client.api.agent_api import AgentApi
|
||||
from agent_protocol_client.api_client import ApiClient
|
||||
|
||||
# import ApiClient
|
||||
from agent_protocol_client.api_response import ApiResponse
|
||||
from agent_protocol_client.configuration import Configuration
|
||||
from agent_protocol_client.exceptions import (
|
||||
ApiAttributeError,
|
||||
ApiException,
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
OpenApiException,
|
||||
)
|
||||
|
||||
# import models into sdk package
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
from agent_protocol_client.models.step import Step
|
||||
from agent_protocol_client.models.step_all_of import StepAllOf
|
||||
from agent_protocol_client.models.step_request_body import StepRequestBody
|
||||
from agent_protocol_client.models.task import Task
|
||||
from agent_protocol_client.models.task_all_of import TaskAllOf
|
||||
from agent_protocol_client.models.task_request_body import TaskRequestBody
|
||||
@@ -0,0 +1,4 @@
|
||||
# flake8: noqa
|
||||
|
||||
# import apis into api package
|
||||
from agent_protocol_client.api.agent_api import AgentApi
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,838 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
from multiprocessing.pool import ThreadPool
|
||||
from urllib.parse import quote
|
||||
|
||||
from dateutil.parser import parse
|
||||
|
||||
import agent_protocol_client.models
|
||||
from agent_protocol_client import rest
|
||||
from agent_protocol_client.api_response import ApiResponse
|
||||
from agent_protocol_client.configuration import Configuration
|
||||
from agent_protocol_client.exceptions import ApiException, ApiValueError
|
||||
|
||||
|
||||
class ApiClient(object):
|
||||
"""Generic API client for OpenAPI client library builds.
|
||||
|
||||
OpenAPI generic API client. This client handles the client-
|
||||
server communication, and is invariant across implementations. Specifics of
|
||||
the methods and models for each application are generated from the OpenAPI
|
||||
templates.
|
||||
|
||||
:param configuration: .Configuration object for this client
|
||||
:param header_name: a header to pass when making calls to the API.
|
||||
:param header_value: a header value to pass when making calls to
|
||||
the API.
|
||||
:param cookie: a cookie to include in the header when making calls
|
||||
to the API
|
||||
:param pool_threads: The number of threads to use for async requests
|
||||
to the API. More threads means more concurrent API requests.
|
||||
"""
|
||||
|
||||
PRIMITIVE_TYPES = (float, bool, bytes, str, int)
|
||||
NATIVE_TYPES_MAPPING = {
|
||||
"int": int,
|
||||
"long": int, # TODO remove as only py3 is supported?
|
||||
"float": float,
|
||||
"str": str,
|
||||
"bool": bool,
|
||||
"date": datetime.date,
|
||||
"datetime": datetime.datetime,
|
||||
"object": object,
|
||||
}
|
||||
_pool = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
configuration=None,
|
||||
header_name=None,
|
||||
header_value=None,
|
||||
cookie=None,
|
||||
pool_threads=1,
|
||||
):
|
||||
# use default configuration if none is provided
|
||||
if configuration is None:
|
||||
configuration = Configuration.get_default()
|
||||
self.configuration = configuration
|
||||
self.pool_threads = pool_threads
|
||||
|
||||
self.rest_client = rest.RESTClientObject(configuration)
|
||||
self.default_headers = {}
|
||||
if header_name is not None:
|
||||
self.default_headers[header_name] = header_value
|
||||
self.cookie = cookie
|
||||
# Set default User-Agent.
|
||||
self.user_agent = "OpenAPI-Generator/1.0.0/python"
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, exc_type, exc_value, traceback):
|
||||
await self.close()
|
||||
|
||||
async def close(self):
|
||||
await self.rest_client.close()
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, "unregister"):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
"""Create thread pool on first request
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
@property
|
||||
def user_agent(self):
|
||||
"""User agent for this API client"""
|
||||
return self.default_headers["User-Agent"]
|
||||
|
||||
@user_agent.setter
|
||||
def user_agent(self, value):
|
||||
self.default_headers["User-Agent"] = value
|
||||
|
||||
def set_default_header(self, header_name, header_value):
|
||||
self.default_headers[header_name] = header_value
|
||||
|
||||
_default = None
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
"""Return new instance of ApiClient.
|
||||
|
||||
This method returns newly created, based on default constructor,
|
||||
object of ApiClient class or returns a copy of default
|
||||
ApiClient.
|
||||
|
||||
:return: The ApiClient object.
|
||||
"""
|
||||
if cls._default is None:
|
||||
cls._default = ApiClient()
|
||||
return cls._default
|
||||
|
||||
@classmethod
|
||||
def set_default(cls, default):
|
||||
"""Set default instance of ApiClient.
|
||||
|
||||
It stores default ApiClient.
|
||||
|
||||
:param default: object of ApiClient.
|
||||
"""
|
||||
cls._default = default
|
||||
|
||||
async def __call_api(
|
||||
self,
|
||||
resource_path,
|
||||
method,
|
||||
path_params=None,
|
||||
query_params=None,
|
||||
header_params=None,
|
||||
body=None,
|
||||
post_params=None,
|
||||
files=None,
|
||||
response_types_map=None,
|
||||
auth_settings=None,
|
||||
_return_http_data_only=None,
|
||||
collection_formats=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
_host=None,
|
||||
_request_auth=None,
|
||||
):
|
||||
config = self.configuration
|
||||
|
||||
# header parameters
|
||||
header_params = header_params or {}
|
||||
header_params.update(self.default_headers)
|
||||
if self.cookie:
|
||||
header_params["Cookie"] = self.cookie
|
||||
if header_params:
|
||||
header_params = self.sanitize_for_serialization(header_params)
|
||||
header_params = dict(
|
||||
self.parameters_to_tuples(header_params, collection_formats)
|
||||
)
|
||||
|
||||
# path parameters
|
||||
if path_params:
|
||||
path_params = self.sanitize_for_serialization(path_params)
|
||||
path_params = self.parameters_to_tuples(path_params, collection_formats)
|
||||
for k, v in path_params:
|
||||
# specified safe chars, encode everything
|
||||
resource_path = resource_path.replace(
|
||||
"{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)
|
||||
)
|
||||
|
||||
# post parameters
|
||||
if post_params or files:
|
||||
post_params = post_params if post_params else []
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
post_params = self.parameters_to_tuples(post_params, collection_formats)
|
||||
post_params.extend(self.files_parameters(files))
|
||||
|
||||
# auth setting
|
||||
self.update_params_for_auth(
|
||||
header_params,
|
||||
query_params,
|
||||
auth_settings,
|
||||
resource_path,
|
||||
method,
|
||||
body,
|
||||
request_auth=_request_auth,
|
||||
)
|
||||
|
||||
# body
|
||||
if body:
|
||||
body = self.sanitize_for_serialization(body)
|
||||
|
||||
# request url
|
||||
if _host is None:
|
||||
url = self.configuration.host + resource_path
|
||||
else:
|
||||
# use server/host defined in path or operation instead
|
||||
url = _host + resource_path
|
||||
|
||||
# query parameters
|
||||
if query_params:
|
||||
query_params = self.sanitize_for_serialization(query_params)
|
||||
url_query = self.parameters_to_url_query(query_params, collection_formats)
|
||||
url += "?" + url_query
|
||||
|
||||
try:
|
||||
# perform request and return response
|
||||
response_data = await self.request(
|
||||
method,
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=header_params,
|
||||
post_params=post_params,
|
||||
body=body,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
)
|
||||
except ApiException as e:
|
||||
if e.body:
|
||||
e.body = e.body.decode("utf-8")
|
||||
raise e
|
||||
|
||||
self.last_response = response_data
|
||||
|
||||
return_data = None # assuming derialization is not needed
|
||||
# data needs deserialization or returns HTTP data (deserialized) only
|
||||
if _preload_content or _return_http_data_only:
|
||||
response_type = response_types_map.get(str(response_data.status), None)
|
||||
|
||||
if response_type == "bytearray":
|
||||
response_data.data = response_data.data
|
||||
else:
|
||||
match = None
|
||||
content_type = response_data.getheader("content-type")
|
||||
if content_type is not None:
|
||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
||||
encoding = match.group(1) if match else "utf-8"
|
||||
response_data.data = response_data.data.decode(encoding)
|
||||
|
||||
# deserialize response data
|
||||
if response_type == "bytearray":
|
||||
return_data = response_data.data
|
||||
elif response_type:
|
||||
return_data = self.deserialize(response_data, response_type)
|
||||
else:
|
||||
return_data = None
|
||||
|
||||
if _return_http_data_only:
|
||||
return return_data
|
||||
else:
|
||||
return ApiResponse(
|
||||
status_code=response_data.status,
|
||||
data=return_data,
|
||||
headers=response_data.getheaders(),
|
||||
raw_data=response_data.data,
|
||||
)
|
||||
|
||||
def sanitize_for_serialization(self, obj):
|
||||
"""Builds a JSON POST object.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is str, int, long, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
If obj is list, sanitize each element in the list.
|
||||
If obj is dict, return the dict.
|
||||
If obj is OpenAPI model, return the properties dict.
|
||||
|
||||
:param obj: The data to serialize.
|
||||
:return: The serialized form of data.
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
|
||||
elif isinstance(obj, tuple):
|
||||
return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
|
||||
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
||||
return obj.isoformat()
|
||||
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
else:
|
||||
# Convert model obj to dict except
|
||||
# attributes `openapi_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = obj.to_dict()
|
||||
|
||||
return {
|
||||
key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
|
||||
}
|
||||
|
||||
def deserialize(self, response, response_type):
|
||||
"""Deserializes response into an object.
|
||||
|
||||
:param response: RESTResponse object to be deserialized.
|
||||
:param response_type: class literal for
|
||||
deserialized object, or string of class name.
|
||||
|
||||
:return: deserialized object.
|
||||
"""
|
||||
# handle file downloading
|
||||
# save response body into a tmp file and return the instance
|
||||
if response_type == "file":
|
||||
return self.__deserialize_file(response)
|
||||
|
||||
# fetch data from response object
|
||||
try:
|
||||
data = json.loads(response.data)
|
||||
except ValueError:
|
||||
data = response.data
|
||||
|
||||
return self.__deserialize(data, response_type)
|
||||
|
||||
def __deserialize(self, data, klass):
|
||||
"""Deserializes dict, list, str into an object.
|
||||
|
||||
:param data: dict, list or str.
|
||||
:param klass: class literal, or string of class name.
|
||||
|
||||
:return: object.
|
||||
"""
|
||||
if data is None:
|
||||
return None
|
||||
|
||||
if type(klass) == str:
|
||||
if klass.startswith("List["):
|
||||
sub_kls = re.match(r"List\[(.*)]", klass).group(1)
|
||||
return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
|
||||
|
||||
if klass.startswith("Dict["):
|
||||
sub_kls = re.match(r"Dict\[([^,]*), (.*)]", klass).group(2)
|
||||
return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}
|
||||
|
||||
# convert str to class
|
||||
if klass in self.NATIVE_TYPES_MAPPING:
|
||||
klass = self.NATIVE_TYPES_MAPPING[klass]
|
||||
else:
|
||||
klass = getattr(agent_protocol_client.models, klass)
|
||||
|
||||
if klass in self.PRIMITIVE_TYPES:
|
||||
return self.__deserialize_primitive(data, klass)
|
||||
elif klass == object:
|
||||
return self.__deserialize_object(data)
|
||||
elif klass == datetime.date:
|
||||
return self.__deserialize_date(data)
|
||||
elif klass == datetime.datetime:
|
||||
return self.__deserialize_datetime(data)
|
||||
else:
|
||||
return self.__deserialize_model(data, klass)
|
||||
|
||||
def call_api(
|
||||
self,
|
||||
resource_path,
|
||||
method,
|
||||
path_params=None,
|
||||
query_params=None,
|
||||
header_params=None,
|
||||
body=None,
|
||||
post_params=None,
|
||||
files=None,
|
||||
response_types_map=None,
|
||||
auth_settings=None,
|
||||
async_req=None,
|
||||
_return_http_data_only=None,
|
||||
collection_formats=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
_host=None,
|
||||
_request_auth=None,
|
||||
):
|
||||
"""Makes the HTTP request (synchronous) and returns deserialized data.
|
||||
|
||||
To make an async_req request, set the async_req parameter.
|
||||
|
||||
:param resource_path: Path to method endpoint.
|
||||
:param method: Method to call.
|
||||
:param path_params: Path parameters in the url.
|
||||
:param query_params: Query parameters in the url.
|
||||
:param header_params: Header parameters to be
|
||||
placed in the request header.
|
||||
:param body: Request body.
|
||||
:param post_params dict: Request post form parameters,
|
||||
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
||||
:param auth_settings list: Auth Settings names for the request.
|
||||
:param response: Response data type.
|
||||
:param files dict: key -> filename, value -> filepath,
|
||||
for `multipart/form-data`.
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param _return_http_data_only: response data instead of ApiResponse
|
||||
object with status code, headers, etc
|
||||
:param _preload_content: if False, the ApiResponse.data will
|
||||
be set to none and raw_data will store the
|
||||
HTTP response body without reading/decoding.
|
||||
Default is True.
|
||||
:param collection_formats: dict of collection formats for path, query,
|
||||
header, and post parameters.
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:param _request_auth: set to override the auth_settings for an a single
|
||||
request; this effectively ignores the authentication
|
||||
in the spec for a single request.
|
||||
:type _request_token: dict, optional
|
||||
:return:
|
||||
If async_req parameter is True,
|
||||
the request will be called asynchronously.
|
||||
The method will return the request thread.
|
||||
If parameter async_req is False or missing,
|
||||
then the method will return the response directly.
|
||||
"""
|
||||
if not async_req:
|
||||
return self.__call_api(
|
||||
resource_path,
|
||||
method,
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body,
|
||||
post_params,
|
||||
files,
|
||||
response_types_map,
|
||||
auth_settings,
|
||||
_return_http_data_only,
|
||||
collection_formats,
|
||||
_preload_content,
|
||||
_request_timeout,
|
||||
_host,
|
||||
_request_auth,
|
||||
)
|
||||
|
||||
return self.pool.apply_async(
|
||||
self.__call_api,
|
||||
(
|
||||
resource_path,
|
||||
method,
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body,
|
||||
post_params,
|
||||
files,
|
||||
response_types_map,
|
||||
auth_settings,
|
||||
_return_http_data_only,
|
||||
collection_formats,
|
||||
_preload_content,
|
||||
_request_timeout,
|
||||
_host,
|
||||
_request_auth,
|
||||
),
|
||||
)
|
||||
|
||||
def request(
|
||||
self,
|
||||
method,
|
||||
url,
|
||||
query_params=None,
|
||||
headers=None,
|
||||
post_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
"""Makes the HTTP request using RESTClient."""
|
||||
if method == "GET":
|
||||
return self.rest_client.get_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
headers=headers,
|
||||
)
|
||||
elif method == "HEAD":
|
||||
return self.rest_client.head_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
headers=headers,
|
||||
)
|
||||
elif method == "OPTIONS":
|
||||
return self.rest_client.options_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
)
|
||||
elif method == "POST":
|
||||
return self.rest_client.post_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
elif method == "PUT":
|
||||
return self.rest_client.put_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
elif method == "PATCH":
|
||||
return self.rest_client.patch_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
elif method == "DELETE":
|
||||
return self.rest_client.delete_request(
|
||||
url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
else:
|
||||
raise ApiValueError(
|
||||
"http method must be `GET`, `HEAD`, `OPTIONS`,"
|
||||
" `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
)
|
||||
|
||||
def parameters_to_tuples(self, params, collection_formats):
|
||||
"""Get parameters as list of tuples, formatting collections.
|
||||
|
||||
:param params: Parameters as dict or list of two-tuples
|
||||
:param dict collection_formats: Parameter collection formats
|
||||
:return: Parameters as list of tuples, collections formatted
|
||||
"""
|
||||
new_params = []
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in (
|
||||
params.items() if isinstance(params, dict) else params
|
||||
): # noqa: E501
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == "multi":
|
||||
new_params.extend((k, value) for value in v)
|
||||
else:
|
||||
if collection_format == "ssv":
|
||||
delimiter = " "
|
||||
elif collection_format == "tsv":
|
||||
delimiter = "\t"
|
||||
elif collection_format == "pipes":
|
||||
delimiter = "|"
|
||||
else: # csv is the default
|
||||
delimiter = ","
|
||||
new_params.append((k, delimiter.join(str(value) for value in v)))
|
||||
else:
|
||||
new_params.append((k, v))
|
||||
return new_params
|
||||
|
||||
def parameters_to_url_query(self, params, collection_formats):
|
||||
"""Get parameters as list of tuples, formatting collections.
|
||||
|
||||
:param params: Parameters as dict or list of two-tuples
|
||||
:param dict collection_formats: Parameter collection formats
|
||||
:return: URL query string (e.g. a=Hello%20World&b=123)
|
||||
"""
|
||||
new_params = []
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in (
|
||||
params.items() if isinstance(params, dict) else params
|
||||
): # noqa: E501
|
||||
if isinstance(v, (int, float)):
|
||||
v = str(v)
|
||||
if isinstance(v, bool):
|
||||
v = str(v).lower()
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == "multi":
|
||||
new_params.extend((k, value) for value in v)
|
||||
else:
|
||||
if collection_format == "ssv":
|
||||
delimiter = " "
|
||||
elif collection_format == "tsv":
|
||||
delimiter = "\t"
|
||||
elif collection_format == "pipes":
|
||||
delimiter = "|"
|
||||
else: # csv is the default
|
||||
delimiter = ","
|
||||
new_params.append(
|
||||
(k, delimiter.join(quote(str(value)) for value in v))
|
||||
)
|
||||
else:
|
||||
new_params.append((k, quote(str(v))))
|
||||
|
||||
return "&".join(["=".join(item) for item in new_params])
|
||||
|
||||
def files_parameters(self, files=None):
|
||||
"""Builds form parameters.
|
||||
|
||||
:param files: File parameters.
|
||||
:return: Form parameters with files.
|
||||
"""
|
||||
params = []
|
||||
|
||||
if files:
|
||||
for k, v in files.items():
|
||||
if not v:
|
||||
continue
|
||||
file_names = v if type(v) is list else [v]
|
||||
for n in file_names:
|
||||
with open(n, "rb") as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = (
|
||||
mimetypes.guess_type(filename)[0]
|
||||
or "application/octet-stream"
|
||||
)
|
||||
params.append(tuple([k, tuple([filename, filedata, mimetype])]))
|
||||
|
||||
return params
|
||||
|
||||
def select_header_accept(self, accepts):
|
||||
"""Returns `Accept` based on an array of accepts provided.
|
||||
|
||||
:param accepts: List of headers.
|
||||
:return: Accept (e.g. application/json).
|
||||
"""
|
||||
if not accepts:
|
||||
return
|
||||
|
||||
for accept in accepts:
|
||||
if re.search("json", accept, re.IGNORECASE):
|
||||
return accept
|
||||
|
||||
return accepts[0]
|
||||
|
||||
def select_header_content_type(self, content_types):
|
||||
"""Returns `Content-Type` based on an array of content_types provided.
|
||||
|
||||
:param content_types: List of content-types.
|
||||
:return: Content-Type (e.g. application/json).
|
||||
"""
|
||||
if not content_types:
|
||||
return None
|
||||
|
||||
for content_type in content_types:
|
||||
if re.search("json", content_type, re.IGNORECASE):
|
||||
return content_type
|
||||
|
||||
return content_types[0]
|
||||
|
||||
def update_params_for_auth(
|
||||
self,
|
||||
headers,
|
||||
queries,
|
||||
auth_settings,
|
||||
resource_path,
|
||||
method,
|
||||
body,
|
||||
request_auth=None,
|
||||
):
|
||||
"""Updates header and query params based on authentication setting.
|
||||
|
||||
:param headers: Header parameters dict to be updated.
|
||||
:param queries: Query parameters tuple list to be updated.
|
||||
:param auth_settings: Authentication setting identifiers list.
|
||||
:resource_path: A string representation of the HTTP request resource path.
|
||||
:method: A string representation of the HTTP request method.
|
||||
:body: A object representing the body of the HTTP request.
|
||||
The object type is the return value of sanitize_for_serialization().
|
||||
:param request_auth: if set, the provided settings will
|
||||
override the token in the configuration.
|
||||
"""
|
||||
if not auth_settings:
|
||||
return
|
||||
|
||||
if request_auth:
|
||||
self._apply_auth_params(
|
||||
headers, queries, resource_path, method, body, request_auth
|
||||
)
|
||||
return
|
||||
|
||||
for auth in auth_settings:
|
||||
auth_setting = self.configuration.auth_settings().get(auth)
|
||||
if auth_setting:
|
||||
self._apply_auth_params(
|
||||
headers, queries, resource_path, method, body, auth_setting
|
||||
)
|
||||
|
||||
def _apply_auth_params(
|
||||
self, headers, queries, resource_path, method, body, auth_setting
|
||||
):
|
||||
"""Updates the request parameters based on a single auth_setting
|
||||
|
||||
:param headers: Header parameters dict to be updated.
|
||||
:param queries: Query parameters tuple list to be updated.
|
||||
:resource_path: A string representation of the HTTP request resource path.
|
||||
:method: A string representation of the HTTP request method.
|
||||
:body: A object representing the body of the HTTP request.
|
||||
The object type is the return value of sanitize_for_serialization().
|
||||
:param auth_setting: auth settings for the endpoint
|
||||
"""
|
||||
if auth_setting["in"] == "cookie":
|
||||
headers["Cookie"] = auth_setting["value"]
|
||||
elif auth_setting["in"] == "header":
|
||||
if auth_setting["type"] != "http-signature":
|
||||
headers[auth_setting["key"]] = auth_setting["value"]
|
||||
elif auth_setting["in"] == "query":
|
||||
queries.append((auth_setting["key"], auth_setting["value"]))
|
||||
else:
|
||||
raise ApiValueError("Authentication token must be in `query` or `header`")
|
||||
|
||||
def __deserialize_file(self, response):
|
||||
"""Deserializes body to file
|
||||
|
||||
Saves response body into a file in a temporary folder,
|
||||
using the filename from the `Content-Disposition` header if provided.
|
||||
|
||||
:param response: RESTResponse.
|
||||
:return: file path.
|
||||
"""
|
||||
fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
|
||||
os.close(fd)
|
||||
os.remove(path)
|
||||
|
||||
content_disposition = response.getheader("Content-Disposition")
|
||||
if content_disposition:
|
||||
filename = re.search(
|
||||
r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition
|
||||
).group(1)
|
||||
path = os.path.join(os.path.dirname(path), filename)
|
||||
|
||||
with open(path, "wb") as f:
|
||||
f.write(response.data)
|
||||
|
||||
return path
|
||||
|
||||
def __deserialize_primitive(self, data, klass):
|
||||
"""Deserializes string to primitive type.
|
||||
|
||||
:param data: str.
|
||||
:param klass: class literal.
|
||||
|
||||
:return: int, long, float, str, bool.
|
||||
"""
|
||||
try:
|
||||
return klass(data)
|
||||
except UnicodeEncodeError:
|
||||
return str(data)
|
||||
except TypeError:
|
||||
return data
|
||||
|
||||
def __deserialize_object(self, value):
|
||||
"""Return an original value.
|
||||
|
||||
:return: object.
|
||||
"""
|
||||
return value
|
||||
|
||||
def __deserialize_date(self, string):
|
||||
"""Deserializes string to date.
|
||||
|
||||
:param string: str.
|
||||
:return: date.
|
||||
"""
|
||||
try:
|
||||
return parse(string).date()
|
||||
except ImportError:
|
||||
return string
|
||||
except ValueError:
|
||||
raise rest.ApiException(
|
||||
status=0, reason="Failed to parse `{0}` as date object".format(string)
|
||||
)
|
||||
|
||||
def __deserialize_datetime(self, string):
|
||||
"""Deserializes string to datetime.
|
||||
|
||||
The string should be in iso8601 datetime format.
|
||||
|
||||
:param string: str.
|
||||
:return: datetime.
|
||||
"""
|
||||
try:
|
||||
return parse(string)
|
||||
except ImportError:
|
||||
return string
|
||||
except ValueError:
|
||||
raise rest.ApiException(
|
||||
status=0,
|
||||
reason=("Failed to parse `{0}` as datetime object".format(string)),
|
||||
)
|
||||
|
||||
def __deserialize_model(self, data, klass):
|
||||
"""Deserializes list or dict to model.
|
||||
|
||||
:param data: dict, list.
|
||||
:param klass: class literal.
|
||||
:return: model object.
|
||||
"""
|
||||
|
||||
return klass.from_dict(data)
|
||||
@@ -0,0 +1,28 @@
|
||||
"""API response object."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from pydantic import Field, StrictInt, StrictStr
|
||||
|
||||
|
||||
class ApiResponse:
|
||||
"""
|
||||
API response object
|
||||
"""
|
||||
|
||||
status_code: Optional[StrictInt] = Field(None, description="HTTP status code")
|
||||
headers: Optional[Dict[StrictStr, StrictStr]] = Field(
|
||||
None, description="HTTP headers"
|
||||
)
|
||||
data: Optional[Any] = Field(
|
||||
None, description="Deserialized data given the data type"
|
||||
)
|
||||
raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)")
|
||||
|
||||
def __init__(self, status_code=None, headers=None, data=None, raw_data=None):
|
||||
self.status_code = status_code
|
||||
self.headers = headers
|
||||
self.data = data
|
||||
self.raw_data = raw_data
|
||||
@@ -0,0 +1,449 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import copy
|
||||
import http.client as httplib
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import urllib3
|
||||
|
||||
from agent_protocol_client.exceptions import ApiValueError
|
||||
|
||||
JSON_SCHEMA_VALIDATION_KEYWORDS = {
|
||||
"multipleOf",
|
||||
"maximum",
|
||||
"exclusiveMaximum",
|
||||
"minimum",
|
||||
"exclusiveMinimum",
|
||||
"maxLength",
|
||||
"minLength",
|
||||
"pattern",
|
||||
"maxItems",
|
||||
"minItems",
|
||||
}
|
||||
|
||||
|
||||
class Configuration(object):
|
||||
"""This class contains various settings of the API client.
|
||||
|
||||
:param host: Base url.
|
||||
:param api_key: Dict to store API key(s).
|
||||
Each entry in the dict specifies an API key.
|
||||
The dict key is the name of the security scheme in the OAS specification.
|
||||
The dict value is the API key secret.
|
||||
:param api_key_prefix: Dict to store API prefix (e.g. Bearer).
|
||||
The dict key is the name of the security scheme in the OAS specification.
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication.
|
||||
:param password: Password for HTTP basic authentication.
|
||||
:param access_token: Access token.
|
||||
:param server_index: Index to servers configuration.
|
||||
:param server_variables: Mapping with string values to replace variables in
|
||||
templated server configuration. The validation of enums is performed for
|
||||
variables with defined enum values before.
|
||||
:param server_operation_index: Mapping from operation ID to an index to server
|
||||
configuration.
|
||||
:param server_operation_variables: Mapping from operation ID to a mapping with
|
||||
string values to replace variables in templated server configuration.
|
||||
The validation of enums is performed for variables with defined enum values before.
|
||||
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
||||
in PEM format.
|
||||
|
||||
"""
|
||||
|
||||
_default = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
host=None,
|
||||
api_key=None,
|
||||
api_key_prefix=None,
|
||||
username=None,
|
||||
password=None,
|
||||
access_token=None,
|
||||
server_index=None,
|
||||
server_variables=None,
|
||||
server_operation_index=None,
|
||||
server_operation_variables=None,
|
||||
ssl_ca_cert=None,
|
||||
):
|
||||
"""Constructor"""
|
||||
self._base_path = "http://localhost" if host is None else host
|
||||
"""Default Base url
|
||||
"""
|
||||
self.server_index = 0 if server_index is None and host is None else server_index
|
||||
self.server_operation_index = server_operation_index or {}
|
||||
"""Default server index
|
||||
"""
|
||||
self.server_variables = server_variables or {}
|
||||
self.server_operation_variables = server_operation_variables or {}
|
||||
"""Default server variables
|
||||
"""
|
||||
self.temp_folder_path = None
|
||||
"""Temp file folder for downloading files
|
||||
"""
|
||||
# Authentication Settings
|
||||
self.api_key = {}
|
||||
if api_key:
|
||||
self.api_key = api_key
|
||||
"""dict to store API key(s)
|
||||
"""
|
||||
self.api_key_prefix = {}
|
||||
if api_key_prefix:
|
||||
self.api_key_prefix = api_key_prefix
|
||||
"""dict to store API prefix (e.g. Bearer)
|
||||
"""
|
||||
self.refresh_api_key_hook = None
|
||||
"""function hook to refresh API key if expired
|
||||
"""
|
||||
self.username = username
|
||||
"""Username for HTTP basic authentication
|
||||
"""
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.access_token = access_token
|
||||
"""Access token
|
||||
"""
|
||||
self.logger = {}
|
||||
"""Logging Settings
|
||||
"""
|
||||
self.logger["package_logger"] = logging.getLogger("agent_protocol_client")
|
||||
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
||||
self.logger_format = "%(asctime)s %(levelname)s %(message)s"
|
||||
"""Log format
|
||||
"""
|
||||
self.logger_stream_handler = None
|
||||
"""Log stream handler
|
||||
"""
|
||||
self.logger_file_handler = None
|
||||
"""Log file handler
|
||||
"""
|
||||
self.logger_file = None
|
||||
"""Debug file location
|
||||
"""
|
||||
self.debug = False
|
||||
"""Debug switch
|
||||
"""
|
||||
|
||||
self.verify_ssl = True
|
||||
"""SSL/TLS verification
|
||||
Set this to false to skip verifying SSL certificate when calling API
|
||||
from https server.
|
||||
"""
|
||||
self.ssl_ca_cert = ssl_ca_cert
|
||||
"""Set this to customize the certificate file to verify the peer.
|
||||
"""
|
||||
self.cert_file = None
|
||||
"""client certificate file
|
||||
"""
|
||||
self.key_file = None
|
||||
"""client key file
|
||||
"""
|
||||
self.assert_hostname = None
|
||||
"""Set this to True/False to enable/disable SSL hostname verification.
|
||||
"""
|
||||
self.tls_server_name = None
|
||||
"""SSL/TLS Server Name Indication (SNI)
|
||||
Set this to the SNI value expected by the server.
|
||||
"""
|
||||
|
||||
self.connection_pool_maxsize = 100
|
||||
"""This value is passed to the aiohttp to limit simultaneous connections.
|
||||
Default values is 100, None means no-limit.
|
||||
"""
|
||||
|
||||
self.proxy = None
|
||||
"""Proxy URL
|
||||
"""
|
||||
self.proxy_headers = None
|
||||
"""Proxy headers
|
||||
"""
|
||||
self.safe_chars_for_path_param = ""
|
||||
"""Safe chars for path_param
|
||||
"""
|
||||
self.retries = None
|
||||
"""Adding retries to override urllib3 default value 3
|
||||
"""
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
self.socket_options = None
|
||||
"""Options to pass down to the underlying urllib3 socket
|
||||
"""
|
||||
|
||||
self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
|
||||
"""datetime format
|
||||
"""
|
||||
|
||||
self.date_format = "%Y-%m-%d"
|
||||
"""date format
|
||||
"""
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
memo[id(self)] = result
|
||||
for k, v in self.__dict__.items():
|
||||
if k not in ("logger", "logger_file_handler"):
|
||||
setattr(result, k, copy.deepcopy(v, memo))
|
||||
# shallow copy of loggers
|
||||
result.logger = copy.copy(self.logger)
|
||||
# use setters to configure loggers
|
||||
result.logger_file = self.logger_file
|
||||
result.debug = self.debug
|
||||
return result
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
object.__setattr__(self, name, value)
|
||||
|
||||
@classmethod
|
||||
def set_default(cls, default):
|
||||
"""Set default instance of configuration.
|
||||
|
||||
It stores default configuration, which can be
|
||||
returned by get_default_copy method.
|
||||
|
||||
:param default: object of Configuration
|
||||
"""
|
||||
cls._default = default
|
||||
|
||||
@classmethod
|
||||
def get_default_copy(cls):
|
||||
"""Deprecated. Please use `get_default` instead.
|
||||
|
||||
Deprecated. Please use `get_default` instead.
|
||||
|
||||
:return: The configuration object.
|
||||
"""
|
||||
return cls.get_default()
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
"""Return the default configuration.
|
||||
|
||||
This method returns newly created, based on default constructor,
|
||||
object of Configuration class or returns a copy of default
|
||||
configuration.
|
||||
|
||||
:return: The configuration object.
|
||||
"""
|
||||
if cls._default is None:
|
||||
cls._default = Configuration()
|
||||
return cls._default
|
||||
|
||||
@property
|
||||
def logger_file(self):
|
||||
"""The logger file.
|
||||
|
||||
If the logger_file is None, then add stream handler and remove file
|
||||
handler. Otherwise, add file handler and remove stream handler.
|
||||
|
||||
:param value: The logger_file path.
|
||||
:type: str
|
||||
"""
|
||||
return self.__logger_file
|
||||
|
||||
@logger_file.setter
|
||||
def logger_file(self, value):
|
||||
"""The logger file.
|
||||
|
||||
If the logger_file is None, then add stream handler and remove file
|
||||
handler. Otherwise, add file handler and remove stream handler.
|
||||
|
||||
:param value: The logger_file path.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_file = value
|
||||
if self.__logger_file:
|
||||
# If set logging file,
|
||||
# then add file handler and remove stream handler.
|
||||
self.logger_file_handler = logging.FileHandler(self.__logger_file)
|
||||
self.logger_file_handler.setFormatter(self.logger_formatter)
|
||||
for _, logger in self.logger.items():
|
||||
logger.addHandler(self.logger_file_handler)
|
||||
|
||||
@property
|
||||
def debug(self):
|
||||
"""Debug status
|
||||
|
||||
:param value: The debug status, True or False.
|
||||
:type: bool
|
||||
"""
|
||||
return self.__debug
|
||||
|
||||
@debug.setter
|
||||
def debug(self, value):
|
||||
"""Debug status
|
||||
|
||||
:param value: The debug status, True or False.
|
||||
:type: bool
|
||||
"""
|
||||
self.__debug = value
|
||||
if self.__debug:
|
||||
# if debug status is True, turn on debug logging
|
||||
for _, logger in self.logger.items():
|
||||
logger.setLevel(logging.DEBUG)
|
||||
# turn on httplib debug
|
||||
httplib.HTTPConnection.debuglevel = 1
|
||||
else:
|
||||
# if debug status is False, turn off debug logging,
|
||||
# setting log level to default `logging.WARNING`
|
||||
for _, logger in self.logger.items():
|
||||
logger.setLevel(logging.WARNING)
|
||||
# turn off httplib debug
|
||||
httplib.HTTPConnection.debuglevel = 0
|
||||
|
||||
@property
|
||||
def logger_format(self):
|
||||
"""The logger format.
|
||||
|
||||
The logger_formatter will be updated when sets logger_format.
|
||||
|
||||
:param value: The format string.
|
||||
:type: str
|
||||
"""
|
||||
return self.__logger_format
|
||||
|
||||
@logger_format.setter
|
||||
def logger_format(self, value):
|
||||
"""The logger format.
|
||||
|
||||
The logger_formatter will be updated when sets logger_format.
|
||||
|
||||
:param value: The format string.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_format = value
|
||||
self.logger_formatter = logging.Formatter(self.__logger_format)
|
||||
|
||||
def get_api_key_with_prefix(self, identifier, alias=None):
|
||||
"""Gets API key (with prefix if set).
|
||||
|
||||
:param identifier: The identifier of apiKey.
|
||||
:param alias: The alternative identifier of apiKey.
|
||||
:return: The token for api key authentication.
|
||||
"""
|
||||
if self.refresh_api_key_hook is not None:
|
||||
self.refresh_api_key_hook(self)
|
||||
key = self.api_key.get(
|
||||
identifier, self.api_key.get(alias) if alias is not None else None
|
||||
)
|
||||
if key:
|
||||
prefix = self.api_key_prefix.get(identifier)
|
||||
if prefix:
|
||||
return "%s %s" % (prefix, key)
|
||||
else:
|
||||
return key
|
||||
|
||||
def get_basic_auth_token(self):
|
||||
"""Gets HTTP basic authentication header (string).
|
||||
|
||||
:return: The token for basic HTTP authentication.
|
||||
"""
|
||||
username = ""
|
||||
if self.username is not None:
|
||||
username = self.username
|
||||
password = ""
|
||||
if self.password is not None:
|
||||
password = self.password
|
||||
return urllib3.util.make_headers(basic_auth=username + ":" + password).get(
|
||||
"authorization"
|
||||
)
|
||||
|
||||
def auth_settings(self):
|
||||
"""Gets Auth Settings dict for api client.
|
||||
|
||||
:return: The Auth Settings information dict.
|
||||
"""
|
||||
auth = {}
|
||||
return auth
|
||||
|
||||
def to_debug_report(self):
|
||||
"""Gets the essential information for debugging.
|
||||
|
||||
:return: The report for debugging.
|
||||
"""
|
||||
return (
|
||||
"Python SDK Debug Report:\n"
|
||||
"OS: {env}\n"
|
||||
"Python Version: {pyversion}\n"
|
||||
"Version of the API: v0.2\n"
|
||||
"SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
|
||||
)
|
||||
|
||||
def get_host_settings(self):
|
||||
"""Gets an array of host settings
|
||||
|
||||
:return: An array of host settings
|
||||
"""
|
||||
return [
|
||||
{
|
||||
"url": "",
|
||||
"description": "No description provided",
|
||||
}
|
||||
]
|
||||
|
||||
def get_host_from_settings(self, index, variables=None, servers=None):
|
||||
"""Gets host URL based on the index and variables
|
||||
:param index: array index of the host settings
|
||||
:param variables: hash of variable and the corresponding value
|
||||
:param servers: an array of host settings or None
|
||||
:return: URL based on host settings
|
||||
"""
|
||||
if index is None:
|
||||
return self._base_path
|
||||
|
||||
variables = {} if variables is None else variables
|
||||
servers = self.get_host_settings() if servers is None else servers
|
||||
|
||||
try:
|
||||
server = servers[index]
|
||||
except IndexError:
|
||||
raise ValueError(
|
||||
"Invalid index {0} when selecting the host settings. "
|
||||
"Must be less than {1}".format(index, len(servers))
|
||||
)
|
||||
|
||||
url = server["url"]
|
||||
|
||||
# go through variables and replace placeholders
|
||||
for variable_name, variable in server.get("variables", {}).items():
|
||||
used_value = variables.get(variable_name, variable["default_value"])
|
||||
|
||||
if "enum_values" in variable and used_value not in variable["enum_values"]:
|
||||
raise ValueError(
|
||||
"The variable `{0}` in the host URL has invalid value "
|
||||
"{1}. Must be {2}.".format(
|
||||
variable_name, variables[variable_name], variable["enum_values"]
|
||||
)
|
||||
)
|
||||
|
||||
url = url.replace("{" + variable_name + "}", used_value)
|
||||
|
||||
return url
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""Return generated host."""
|
||||
return self.get_host_from_settings(
|
||||
self.server_index, variables=self.server_variables
|
||||
)
|
||||
|
||||
@host.setter
|
||||
def host(self, value):
|
||||
"""Fix base path."""
|
||||
self._base_path = value
|
||||
self.server_index = None
|
||||
@@ -0,0 +1,615 @@
|
||||
# agent_protocol_client.AgentApi
|
||||
|
||||
All URIs are relative to _http://localhost_
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ---------------------------------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------- |
|
||||
| [**create_agent_task**](AgentApi.md#create_agent_task) | **POST** /agent/tasks | Creates a task for the agent. |
|
||||
| [**download_agent_task_artifact**](AgentApi.md#download_agent_task_artifact) | **GET** /agent/tasks/{task_id}/artifacts/{artifact_id} | Download a specified artifact. |
|
||||
| [**execute_agent_task_step**](AgentApi.md#execute_agent_task_step) | **POST** /agent/tasks/{task_id}/steps | Execute a step in the specified agent task. |
|
||||
| [**get_agent_task**](AgentApi.md#get_agent_task) | **GET** /agent/tasks/{task_id} | Get details about a specified agent task. |
|
||||
| [**get_agent_task_step**](AgentApi.md#get_agent_task_step) | **GET** /agent/tasks/{task_id}/steps/{step_id} | Get details about a specified task step. |
|
||||
| [**list_agent_task_artifacts**](AgentApi.md#list_agent_task_artifacts) | **GET** /agent/tasks/{task_id}/artifacts | List all artifacts that have been created for the given task. |
|
||||
| [**list_agent_task_steps**](AgentApi.md#list_agent_task_steps) | **GET** /agent/tasks/{task_id}/steps | List all steps for the specified task. |
|
||||
| [**list_agent_tasks_ids**](AgentApi.md#list_agent_tasks_ids) | **GET** /agent/tasks | List all tasks that have been created for the agent. |
|
||||
| [**upload_agent_task_artifacts**](AgentApi.md#upload_agent_task_artifacts) | **POST** /agent/tasks/{task_id}/artifacts | Upload an artifact for the specified task. |
|
||||
|
||||
# **create_agent_task**
|
||||
|
||||
> Task create_agent_task(task_request_body=task_request_body)
|
||||
|
||||
Creates a task for the agent.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.task import Task
|
||||
from agent_protocol_client.models.task_request_body import TaskRequestBody
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_request_body = agent_protocol_client.TaskRequestBody() # TaskRequestBody | (optional)
|
||||
|
||||
try:
|
||||
# Creates a task for the agent.
|
||||
api_response = await api_instance.create_agent_task(task_request_body=task_request_body)
|
||||
print("The response of AgentApi->create_agent_task:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->create_agent_task: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| --------------------- | ----------------------------------------- | ----------- | ---------- |
|
||||
| **task_request_body** | [**TaskRequestBody**](TaskRequestBody.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Task**](Task.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------------ | ---------------- |
|
||||
| **200** | A new agent task was successfully created. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **download_agent_task_artifact**
|
||||
|
||||
> bytearray download_agent_task_artifact(task_id, artifact_id)
|
||||
|
||||
Download a specified artifact.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
artifact_id = 'artifact_id_example' # str | ID of the artifact
|
||||
|
||||
try:
|
||||
# Download a specified artifact.
|
||||
api_response = await api_instance.download_agent_task_artifact(task_id, artifact_id)
|
||||
print("The response of AgentApi->download_agent_task_artifact:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->download_agent_task_artifact: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| --------------- | ------- | ------------------ | ----- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
| **artifact_id** | **str** | ID of the artifact |
|
||||
|
||||
### Return type
|
||||
|
||||
**bytearray**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/octet-stream
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------- | ---------------- |
|
||||
| **200** | Returned the content of the artifact. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **execute_agent_task_step**
|
||||
|
||||
> Step execute_agent_task_step(task_id, step_request_body=step_request_body)
|
||||
|
||||
Execute a step in the specified agent task.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.step import Step
|
||||
from agent_protocol_client.models.step_request_body import StepRequestBody
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
step_request_body = agent_protocol_client.StepRequestBody() # StepRequestBody | (optional)
|
||||
|
||||
try:
|
||||
# Execute a step in the specified agent task.
|
||||
api_response = await api_instance.execute_agent_task_step(task_id, step_request_body=step_request_body)
|
||||
print("The response of AgentApi->execute_agent_task_step:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->execute_agent_task_step: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| --------------------- | ----------------------------------------- | -------------- | ---------- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
| **step_request_body** | [**StepRequestBody**](StepRequestBody.md) | | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Step**](Step.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | --------------------------------- | ---------------- |
|
||||
| **200** | Executed step for the agent task. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **get_agent_task**
|
||||
|
||||
> Task get_agent_task(task_id)
|
||||
|
||||
Get details about a specified agent task.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.task import Task
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
|
||||
try:
|
||||
# Get details about a specified agent task.
|
||||
api_response = await api_instance.get_agent_task(task_id)
|
||||
print("The response of AgentApi->get_agent_task:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->get_agent_task: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ----------- | ------- | -------------- | ----- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Task**](Task.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------- | ---------------- |
|
||||
| **200** | Returned details about an agent task. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **get_agent_task_step**
|
||||
|
||||
> Step get_agent_task_step(task_id, step_id)
|
||||
|
||||
Get details about a specified task step.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.step import Step
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
step_id = 'step_id_example' # str | ID of the step
|
||||
|
||||
try:
|
||||
# Get details about a specified task step.
|
||||
api_response = await api_instance.get_agent_task_step(task_id, step_id)
|
||||
print("The response of AgentApi->get_agent_task_step:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->get_agent_task_step: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ----------- | ------- | -------------- | ----- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
| **step_id** | **str** | ID of the step |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Step**](Step.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------------ | ---------------- |
|
||||
| **200** | Returned details about an agent task step. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **list_agent_task_artifacts**
|
||||
|
||||
> List[Artifact] list_agent_task_artifacts(task_id)
|
||||
|
||||
List all artifacts that have been created for the given task.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
|
||||
try:
|
||||
# List all artifacts that have been created for the given task.
|
||||
api_response = await api_instance.list_agent_task_artifacts(task_id)
|
||||
print("The response of AgentApi->list_agent_task_artifacts:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->list_agent_task_artifacts: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ----------- | ------- | -------------- | ----- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
|
||||
### Return type
|
||||
|
||||
[**List[Artifact]**](Artifact.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------- | ---------------- |
|
||||
| **200** | Returned the content of the artifact. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **list_agent_task_steps**
|
||||
|
||||
> List[str] list_agent_task_steps(task_id)
|
||||
|
||||
List all steps for the specified task.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
|
||||
try:
|
||||
# List all steps for the specified task.
|
||||
api_response = await api_instance.list_agent_task_steps(task_id)
|
||||
print("The response of AgentApi->list_agent_task_steps:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->list_agent_task_steps: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ----------- | ------- | -------------- | ----- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
|
||||
### Return type
|
||||
|
||||
**List[str]**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------------------------------- | ---------------- |
|
||||
| **200** | Returned list of agent's step IDs for the specified task. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **list_agent_tasks_ids**
|
||||
|
||||
> List[str] list_agent_tasks_ids()
|
||||
|
||||
List all tasks that have been created for the agent.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
|
||||
try:
|
||||
# List all tasks that have been created for the agent.
|
||||
api_response = await api_instance.list_agent_tasks_ids()
|
||||
print("The response of AgentApi->list_agent_tasks_ids:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->list_agent_tasks_ids: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**List[str]**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | -------------------------------------- | ---------------- |
|
||||
| **200** | Returned list of agent's task IDs. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **upload_agent_task_artifacts**
|
||||
|
||||
> Artifact upload_agent_task_artifacts(task_id, file, relative_path=relative_path)
|
||||
|
||||
Upload an artifact for the specified task.
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import time
|
||||
import os
|
||||
import agent_protocol_client
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
from agent_protocol_client.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Defining the host is optional and defaults to http://localhost
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = agent_protocol_client.Configuration(
|
||||
host = "http://localhost"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with agent_protocol_client.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = agent_protocol_client.AgentApi(api_client)
|
||||
task_id = 'task_id_example' # str | ID of the task
|
||||
file = None # bytearray | File to upload.
|
||||
relative_path = 'relative_path_example' # str | Relative path of the artifact in the agent's workspace. (optional)
|
||||
|
||||
try:
|
||||
# Upload an artifact for the specified task.
|
||||
api_response = await api_instance.upload_agent_task_artifacts(task_id, file, relative_path=relative_path)
|
||||
print("The response of AgentApi->upload_agent_task_artifacts:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling AgentApi->upload_agent_task_artifacts: %s\n" % e)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
| ----------------- | ------------- | ----------------------------------------------------------- | ---------- |
|
||||
| **task_id** | **str** | ID of the task |
|
||||
| **file** | **bytearray** | File to upload. |
|
||||
| **relative_path** | **str** | Relative path of the artifact in the agent's workspace. | [optional] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Artifact**](Artifact.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
|
||||
| Status code | Description | Response headers |
|
||||
| ----------- | ------------------------------------- | ---------------- |
|
||||
| **200** | Returned the content of the artifact. | - |
|
||||
| **0** | Internal Server Error | - |
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
@@ -0,0 +1,154 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
class OpenApiException(Exception):
|
||||
"""The base exception class for all OpenAPIExceptions"""
|
||||
|
||||
|
||||
class ApiTypeError(OpenApiException, TypeError):
|
||||
def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
|
||||
"""Raises an exception for TypeErrors
|
||||
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (list): a list of keys an indices to get to the
|
||||
current_item
|
||||
None if unset
|
||||
valid_classes (tuple): the primitive classes that current item
|
||||
should be an instance of
|
||||
None if unset
|
||||
key_type (bool): False if our value is a value in a dict
|
||||
True if it is a key in a dict
|
||||
False if our item is an item in a list
|
||||
None if unset
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
self.valid_classes = valid_classes
|
||||
self.key_type = key_type
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiTypeError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiValueError(OpenApiException, ValueError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (list) the path to the exception in the
|
||||
received_data dict. None if unset
|
||||
"""
|
||||
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiValueError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiAttributeError(OpenApiException, AttributeError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Raised when an attribute reference or assignment fails.
|
||||
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (None/list) the path to the exception in the
|
||||
received_data dict
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiAttributeError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiKeyError(OpenApiException, KeyError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (None/list) the path to the exception in the
|
||||
received_data dict
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiKeyError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiException(OpenApiException):
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
if http_resp:
|
||||
self.status = http_resp.status
|
||||
self.reason = http_resp.reason
|
||||
self.body = http_resp.data
|
||||
self.headers = http_resp.getheaders()
|
||||
else:
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.body = None
|
||||
self.headers = None
|
||||
|
||||
def __str__(self):
|
||||
"""Custom error messages for exception"""
|
||||
error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
|
||||
if self.headers:
|
||||
error_message += "HTTP response headers: {0}\n".format(self.headers)
|
||||
|
||||
if self.body:
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
|
||||
return error_message
|
||||
|
||||
|
||||
class NotFoundException(ApiException):
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
super(NotFoundException, self).__init__(status, reason, http_resp)
|
||||
|
||||
|
||||
class UnauthorizedException(ApiException):
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
super(UnauthorizedException, self).__init__(status, reason, http_resp)
|
||||
|
||||
|
||||
class ForbiddenException(ApiException):
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
super(ForbiddenException, self).__init__(status, reason, http_resp)
|
||||
|
||||
|
||||
class ServiceException(ApiException):
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
super(ServiceException, self).__init__(status, reason, http_resp)
|
||||
|
||||
|
||||
def render_path(path_to_item):
|
||||
"""Returns a string representation of a path"""
|
||||
result = ""
|
||||
for pth in path_to_item:
|
||||
if isinstance(pth, int):
|
||||
result += "[{0}]".format(pth)
|
||||
else:
|
||||
result += "['{0}']".format(pth)
|
||||
return result
|
||||
@@ -0,0 +1,26 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
# import models into model package
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
from agent_protocol_client.models.artifacts import Artifacts
|
||||
from agent_protocol_client.models.pagination import Pagination
|
||||
|
||||
from agent_protocol_client.models.step import Step
|
||||
from agent_protocol_client.models.step_all_of import StepAllOf
|
||||
from agent_protocol_client.models.step_request_body import StepRequestBody
|
||||
from agent_protocol_client.models.task import Task
|
||||
from agent_protocol_client.models.task_all_of import TaskAllOf
|
||||
from agent_protocol_client.models.task_request_body import TaskRequestBody
|
||||
@@ -0,0 +1,83 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
|
||||
|
||||
class Artifact(BaseModel):
|
||||
"""
|
||||
Artifact that the task has produced.
|
||||
"""
|
||||
|
||||
artifact_id: StrictStr = Field(..., description="ID of the artifact.")
|
||||
file_name: StrictStr = Field(..., description="Filename of the artifact.")
|
||||
relative_path: Optional[StrictStr] = Field(
|
||||
None, description="Relative path of the artifact in the agent's workspace."
|
||||
)
|
||||
__properties = ["artifact_id", "file_name", "relative_path"]
|
||||
created_at: StrictStr = Field(..., description="Creation date of the artifact.")
|
||||
# modified_at: StrictStr = Field(..., description="Modification date of the artifact.")
|
||||
agent_created: bool = Field( ..., description="True if created by the agent")
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Artifact:
|
||||
"""Create an instance of Artifact from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> Artifact:
|
||||
"""Create an instance of Artifact from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return Artifact.parse_obj(obj)
|
||||
|
||||
_obj = Artifact.parse_obj(
|
||||
{
|
||||
"artifact_id": obj.get("artifact_id"),
|
||||
"file_name": obj.get("file_name"),
|
||||
"relative_path": obj.get("relative_path"),
|
||||
"created_at": obj.get("created_at"),
|
||||
"modifed_at": obj.get("modifed_at"),
|
||||
"agent_created": obj.get("agent_created"),
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,76 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
|
||||
from agent_protocol_client.models.pagination import Pagination
|
||||
|
||||
class Artifacts(BaseModel):
|
||||
"""
|
||||
Artifacts that the task has produced.
|
||||
"""
|
||||
|
||||
artifacts: list[Artifact]
|
||||
pagination: Pagination
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Artifacts:
|
||||
"""Create an instance of Artifacts from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> Artifacts:
|
||||
"""Create an instance of Artifacts from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return Artifacts.parse_obj(obj)
|
||||
|
||||
_obj = Artifacts.parse_obj(
|
||||
{
|
||||
"artifacts": obj.get("artifacts"),
|
||||
"pagination": obj.get("pagination"),
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
|
||||
Artifacts.update_forward_refs()
|
||||
@@ -0,0 +1,76 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
|
||||
|
||||
class Pagination(BaseModel):
|
||||
"""
|
||||
Pagination that the task has produced.
|
||||
"""
|
||||
total_items: int
|
||||
total_pages: int
|
||||
current_page: int
|
||||
page_size: int
|
||||
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Pagination:
|
||||
"""Create an instance of Pagination from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> Pagination:
|
||||
"""Create an instance of Pagination from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return Pagination.parse_obj(obj)
|
||||
|
||||
_obj = Pagination.parse_obj(
|
||||
{
|
||||
"total_items": obj.get("total_items"),
|
||||
"total_pages": obj.get("total_pages"),
|
||||
"current_page": obj.get("current_page"),
|
||||
"page_size": obj.get("page_size"),
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,146 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, validator
|
||||
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
|
||||
|
||||
class Step(BaseModel):
|
||||
"""
|
||||
Step
|
||||
"""
|
||||
|
||||
input: Optional[StrictStr] = Field(None, description="Input prompt for the step.")
|
||||
additional_input: Optional[Any] = Field(
|
||||
None, description="Input parameters for the task step. Any value is allowed."
|
||||
)
|
||||
task_id: StrictStr = Field(
|
||||
..., description="The ID of the task this step belongs to."
|
||||
)
|
||||
step_id: StrictStr = Field(..., description="The ID of the task step.")
|
||||
name: Optional[StrictStr] = Field(None, description="The name of the task step.")
|
||||
status: StrictStr = Field(..., description="The status of the task step.")
|
||||
output: Optional[StrictStr] = Field(None, description="Output of the task step.")
|
||||
additional_output: Optional[Any] = Field(
|
||||
None,
|
||||
description="Output that the task step has produced. Any value is allowed.",
|
||||
)
|
||||
artifacts: conlist(Artifact) = Field(
|
||||
..., description="A list of artifacts that the step has produced."
|
||||
)
|
||||
is_last: Optional[StrictBool] = Field(
|
||||
False, description="Whether this is the last step in the task."
|
||||
)
|
||||
__properties = [
|
||||
"input",
|
||||
"additional_input",
|
||||
"task_id",
|
||||
"step_id",
|
||||
"name",
|
||||
"status",
|
||||
"output",
|
||||
"additional_output",
|
||||
"artifacts",
|
||||
"is_last",
|
||||
]
|
||||
|
||||
@validator("status")
|
||||
def status_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value not in ("created", "completed"):
|
||||
raise ValueError("must be one of enum values ('created', 'completed')")
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Step:
|
||||
"""Create an instance of Step from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in artifacts (list)
|
||||
_items = []
|
||||
if self.artifacts:
|
||||
for _item in self.artifacts:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict["artifacts"] = _items
|
||||
# set to None if additional_input (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.additional_input is None and "additional_input" in self.__fields_set__:
|
||||
_dict["additional_input"] = None
|
||||
|
||||
# set to None if additional_output (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if (
|
||||
self.additional_output is None
|
||||
and "additional_output" in self.__fields_set__
|
||||
):
|
||||
_dict["additional_output"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> Step:
|
||||
"""Create an instance of Step from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return Step.parse_obj(obj)
|
||||
|
||||
_obj = Step.parse_obj(
|
||||
{
|
||||
"input": obj.get("input"),
|
||||
"additional_input": obj.get("additional_input"),
|
||||
"task_id": obj.get("task_id"),
|
||||
"step_id": obj.get("step_id"),
|
||||
"name": obj.get("name"),
|
||||
"status": obj.get("status"),
|
||||
"output": obj.get("output"),
|
||||
"additional_output": obj.get("additional_output"),
|
||||
"artifacts": [
|
||||
Artifact.from_dict(_item) for _item in obj.get("artifacts")
|
||||
]
|
||||
if obj.get("artifacts") is not None
|
||||
else None,
|
||||
"is_last": obj.get("is_last")
|
||||
if obj.get("is_last") is not None
|
||||
else False,
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,133 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, validator
|
||||
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
|
||||
|
||||
class StepAllOf(BaseModel):
|
||||
"""
|
||||
StepAllOf
|
||||
"""
|
||||
|
||||
task_id: StrictStr = Field(
|
||||
..., description="The ID of the task this step belongs to."
|
||||
)
|
||||
step_id: StrictStr = Field(..., description="The ID of the task step.")
|
||||
name: Optional[StrictStr] = Field(None, description="The name of the task step.")
|
||||
status: StrictStr = Field(..., description="The status of the task step.")
|
||||
output: Optional[StrictStr] = Field(None, description="Output of the task step.")
|
||||
additional_output: Optional[Any] = Field(
|
||||
None,
|
||||
description="Output that the task step has produced. Any value is allowed.",
|
||||
)
|
||||
artifacts: conlist(Artifact) = Field(
|
||||
..., description="A list of artifacts that the step has produced."
|
||||
)
|
||||
is_last: Optional[StrictBool] = Field(
|
||||
False, description="Whether this is the last step in the task."
|
||||
)
|
||||
__properties = [
|
||||
"task_id",
|
||||
"step_id",
|
||||
"name",
|
||||
"status",
|
||||
"output",
|
||||
"additional_output",
|
||||
"artifacts",
|
||||
"is_last",
|
||||
]
|
||||
|
||||
@validator("status")
|
||||
def status_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value not in ("created", "completed"):
|
||||
raise ValueError("must be one of enum values ('created', 'completed')")
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> StepAllOf:
|
||||
"""Create an instance of StepAllOf from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in artifacts (list)
|
||||
_items = []
|
||||
if self.artifacts:
|
||||
for _item in self.artifacts:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict["artifacts"] = _items
|
||||
# set to None if additional_output (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if (
|
||||
self.additional_output is None
|
||||
and "additional_output" in self.__fields_set__
|
||||
):
|
||||
_dict["additional_output"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> StepAllOf:
|
||||
"""Create an instance of StepAllOf from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return StepAllOf.parse_obj(obj)
|
||||
|
||||
_obj = StepAllOf.parse_obj(
|
||||
{
|
||||
"task_id": obj.get("task_id"),
|
||||
"step_id": obj.get("step_id"),
|
||||
"name": obj.get("name"),
|
||||
"status": obj.get("status"),
|
||||
"output": obj.get("output"),
|
||||
"additional_output": obj.get("additional_output"),
|
||||
"artifacts": [
|
||||
Artifact.from_dict(_item) for _item in obj.get("artifacts")
|
||||
]
|
||||
if obj.get("artifacts") is not None
|
||||
else None,
|
||||
"is_last": obj.get("is_last")
|
||||
if obj.get("is_last") is not None
|
||||
else False,
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,77 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
|
||||
|
||||
class StepRequestBody(BaseModel):
|
||||
"""
|
||||
Body of the task request.
|
||||
"""
|
||||
|
||||
input: Optional[StrictStr] = Field(None, description="Input prompt for the step.")
|
||||
additional_input: Optional[Any] = Field(
|
||||
None, description="Input parameters for the task step. Any value is allowed."
|
||||
)
|
||||
__properties = ["input", "additional_input"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> StepRequestBody:
|
||||
"""Create an instance of StepRequestBody from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# set to None if additional_input (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.additional_input is None and "additional_input" in self.__fields_set__:
|
||||
_dict["additional_input"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> StepRequestBody:
|
||||
"""Create an instance of StepRequestBody from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return StepRequestBody.parse_obj(obj)
|
||||
|
||||
_obj = StepRequestBody.parse_obj(
|
||||
{"input": obj.get("input"), "additional_input": obj.get("additional_input")}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,89 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v1
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictBool, conlist
|
||||
|
||||
|
||||
class StepResult(BaseModel):
|
||||
"""
|
||||
Result of the task step.
|
||||
"""
|
||||
|
||||
output: Optional[Any] = Field(
|
||||
None,
|
||||
description="Output that the task step has produced. Any value is allowed.",
|
||||
)
|
||||
artifacts: conlist(Any) = Field(
|
||||
..., description="A list of artifacts that the step has produced."
|
||||
)
|
||||
is_last: Optional[StrictBool] = Field(
|
||||
False, description="Whether this is the last step in the task."
|
||||
)
|
||||
__properties = ["output", "artifacts", "is_last"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> StepResult:
|
||||
"""Create an instance of StepResult from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# set to None if output (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.output is None and "output" in self.__fields_set__:
|
||||
_dict["output"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> StepResult:
|
||||
"""Create an instance of StepResult from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return StepResult.parse_obj(obj)
|
||||
|
||||
_obj = StepResult.parse_obj(
|
||||
{
|
||||
"output": obj.get("output"),
|
||||
"artifacts": obj.get("artifacts"),
|
||||
"is_last": obj.get("is_last")
|
||||
if obj.get("is_last") is not None
|
||||
else False,
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr, conlist
|
||||
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
|
||||
|
||||
class Task(BaseModel):
|
||||
"""
|
||||
Task
|
||||
"""
|
||||
|
||||
input: Optional[StrictStr] = Field(None, description="Input prompt for the task.")
|
||||
additional_input: Optional[Any] = Field(
|
||||
None, description="Input parameters for the task. Any value is allowed."
|
||||
)
|
||||
task_id: StrictStr = Field(..., description="The ID of the task.")
|
||||
artifacts: conlist(Artifact) = Field(
|
||||
..., description="A list of artifacts that the task has produced."
|
||||
)
|
||||
__properties = ["input", "additional_input", "task_id", "artifacts"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Task:
|
||||
"""Create an instance of Task from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in artifacts (list)
|
||||
_items = []
|
||||
if self.artifacts:
|
||||
for _item in self.artifacts:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict["artifacts"] = _items
|
||||
# set to None if additional_input (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.additional_input is None and "additional_input" in self.__fields_set__:
|
||||
_dict["additional_input"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> Task:
|
||||
"""Create an instance of Task from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return Task.parse_obj(obj)
|
||||
|
||||
_obj = Task.parse_obj(
|
||||
{
|
||||
"input": obj.get("input"),
|
||||
"additional_input": obj.get("additional_input"),
|
||||
"task_id": obj.get("task_id"),
|
||||
"artifacts": [
|
||||
Artifact.from_dict(_item) for _item in obj.get("artifacts")
|
||||
]
|
||||
if obj.get("artifacts") is not None
|
||||
else None,
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,88 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr, conlist
|
||||
|
||||
from agent_protocol_client.models.artifact import Artifact
|
||||
|
||||
|
||||
class TaskAllOf(BaseModel):
|
||||
"""
|
||||
Definition of an agent task.
|
||||
"""
|
||||
|
||||
task_id: StrictStr = Field(..., description="The ID of the task.")
|
||||
artifacts: conlist(Artifact) = Field(
|
||||
..., description="A list of artifacts that the task has produced."
|
||||
)
|
||||
__properties = ["task_id", "artifacts"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TaskAllOf:
|
||||
"""Create an instance of TaskAllOf from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in artifacts (list)
|
||||
_items = []
|
||||
if self.artifacts:
|
||||
for _item in self.artifacts:
|
||||
if _item:
|
||||
_items.append(_item.to_dict())
|
||||
_dict["artifacts"] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> TaskAllOf:
|
||||
"""Create an instance of TaskAllOf from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return TaskAllOf.parse_obj(obj)
|
||||
|
||||
_obj = TaskAllOf.parse_obj(
|
||||
{
|
||||
"task_id": obj.get("task_id"),
|
||||
"artifacts": [
|
||||
Artifact.from_dict(_item) for _item in obj.get("artifacts")
|
||||
]
|
||||
if obj.get("artifacts") is not None
|
||||
else None,
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,77 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
|
||||
|
||||
class TaskRequestBody(BaseModel):
|
||||
"""
|
||||
Body of the task request.
|
||||
"""
|
||||
|
||||
input: Optional[StrictStr] = Field(None, description="Input prompt for the task.")
|
||||
additional_input: Optional[Any] = Field(
|
||||
None, description="Input parameters for the task. Any value is allowed."
|
||||
)
|
||||
__properties = ["input", "additional_input"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TaskRequestBody:
|
||||
"""Create an instance of TaskRequestBody from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
||||
# set to None if additional_input (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.additional_input is None and "additional_input" in self.__fields_set__:
|
||||
_dict["additional_input"] = None
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> TaskRequestBody:
|
||||
"""Create an instance of TaskRequestBody from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return TaskRequestBody.parse_obj(obj)
|
||||
|
||||
_obj = TaskRequestBody.parse_obj(
|
||||
{"input": obj.get("input"), "additional_input": obj.get("additional_input")}
|
||||
)
|
||||
return _obj
|
||||
311
benchmark/agent_protocol_client/agent_protocol_client/rest.py
Normal file
311
benchmark/agent_protocol_client/agent_protocol_client/rest.py
Normal file
@@ -0,0 +1,311 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Agent Communication Protocol
|
||||
|
||||
Specification of the API protocol for communication with an agent. # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: v0.2
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import ssl
|
||||
from urllib.parse import quote_plus, urlencode
|
||||
|
||||
import aiohttp
|
||||
|
||||
from agent_protocol_client.exceptions import ApiException, ApiValueError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
def __init__(self, resp, data):
|
||||
self.aiohttp_response = resp
|
||||
self.status = resp.status
|
||||
self.reason = resp.reason
|
||||
self.data = data
|
||||
|
||||
def getheaders(self):
|
||||
"""Returns a CIMultiDictProxy of the response headers."""
|
||||
return self.aiohttp_response.headers
|
||||
|
||||
def getheader(self, name, default=None):
|
||||
"""Returns a given response header."""
|
||||
return self.aiohttp_response.headers.get(name, default)
|
||||
|
||||
|
||||
class RESTClientObject(object):
|
||||
def __init__(self, configuration, pools_size=4, maxsize=None):
|
||||
# maxsize is number of requests to host that are allowed in parallel
|
||||
if maxsize is None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
|
||||
ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert)
|
||||
if configuration.cert_file:
|
||||
ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
|
||||
if not configuration.verify_ssl:
|
||||
ssl_context.check_hostname = False
|
||||
ssl_context.verify_mode = ssl.CERT_NONE
|
||||
|
||||
connector = aiohttp.TCPConnector(limit=maxsize, ssl=ssl_context)
|
||||
|
||||
self.proxy = configuration.proxy
|
||||
self.proxy_headers = configuration.proxy_headers
|
||||
|
||||
# https pool manager
|
||||
self.pool_manager = aiohttp.ClientSession(connector=connector, trust_env=True)
|
||||
|
||||
async def close(self):
|
||||
await self.pool_manager.close()
|
||||
|
||||
async def request(
|
||||
self,
|
||||
method,
|
||||
url,
|
||||
query_params=None,
|
||||
headers=None,
|
||||
body=None,
|
||||
post_params=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
"""Execute request
|
||||
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param query_params: query parameters in the url
|
||||
:param headers: http request headers
|
||||
:param body: request json body, for `application/json`
|
||||
:param post_params: request post parameters,
|
||||
`application/x-www-form-urlencoded`
|
||||
and `multipart/form-data`
|
||||
:param _preload_content: this is a non-applicable field for
|
||||
the AiohttpClient.
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]
|
||||
|
||||
if post_params and body:
|
||||
raise ApiValueError(
|
||||
"body parameter cannot be used with post_params parameter."
|
||||
)
|
||||
|
||||
post_params = post_params or {}
|
||||
headers = headers or {}
|
||||
# url already contains the URL query string
|
||||
# so reset query_params to empty dict
|
||||
query_params = {}
|
||||
timeout = _request_timeout or 5 * 60
|
||||
|
||||
if "Content-Type" not in headers:
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
args = {"method": method, "url": url, "timeout": timeout, "headers": headers}
|
||||
|
||||
if self.proxy:
|
||||
args["proxy"] = self.proxy
|
||||
if self.proxy_headers:
|
||||
args["proxy_headers"] = self.proxy_headers
|
||||
|
||||
if query_params:
|
||||
args["url"] += "?" + urlencode(query_params)
|
||||
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
||||
if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
|
||||
if re.search("json", headers["Content-Type"], re.IGNORECASE):
|
||||
if body is not None:
|
||||
body = json.dumps(body)
|
||||
args["data"] = body
|
||||
elif (
|
||||
headers["Content-Type"] == "application/x-www-form-urlencoded"
|
||||
): # noqa: E501
|
||||
args["data"] = aiohttp.FormData(post_params)
|
||||
elif headers["Content-Type"] == "multipart/form-data":
|
||||
# must del headers['Content-Type'], or the correct
|
||||
# Content-Type which generated by aiohttp
|
||||
del headers["Content-Type"]
|
||||
data = aiohttp.FormData()
|
||||
for param in post_params:
|
||||
k, v = param
|
||||
if isinstance(v, tuple) and len(v) == 3:
|
||||
data.add_field(k, value=v[1], filename=v[0], content_type=v[2])
|
||||
else:
|
||||
data.add_field(k, v)
|
||||
args["data"] = data
|
||||
|
||||
# Pass a `bytes` parameter directly in the body to support
|
||||
# other content types than Json when `body` argument is provided
|
||||
# in serialized form
|
||||
elif isinstance(body, bytes):
|
||||
args["data"] = body
|
||||
else:
|
||||
# Cannot generate the request from given parameters
|
||||
msg = """Cannot prepare a request message for provided
|
||||
arguments. Please check that your arguments match
|
||||
declared content type."""
|
||||
raise ApiException(status=0, reason=msg)
|
||||
|
||||
r = await self.pool_manager.request(**args)
|
||||
if _preload_content:
|
||||
data = await r.read()
|
||||
r = RESTResponse(r, data)
|
||||
|
||||
# log response body
|
||||
logger.debug("response body: %s", r.data)
|
||||
|
||||
if not 200 <= r.status <= 299:
|
||||
raise ApiException(http_resp=r)
|
||||
|
||||
return r
|
||||
|
||||
async def get_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"GET",
|
||||
url,
|
||||
headers=headers,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
query_params=query_params,
|
||||
)
|
||||
|
||||
async def head_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"HEAD",
|
||||
url,
|
||||
headers=headers,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
query_params=query_params,
|
||||
)
|
||||
|
||||
async def options_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
post_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"OPTIONS",
|
||||
url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
|
||||
async def delete_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"DELETE",
|
||||
url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
|
||||
async def post_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
post_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"POST",
|
||||
url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
|
||||
async def put_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
post_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"PUT",
|
||||
url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
|
||||
async def patch_request(
|
||||
self,
|
||||
url,
|
||||
headers=None,
|
||||
query_params=None,
|
||||
post_params=None,
|
||||
body=None,
|
||||
_preload_content=True,
|
||||
_request_timeout=None,
|
||||
):
|
||||
return await self.request(
|
||||
"PATCH",
|
||||
url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
_preload_content=_preload_content,
|
||||
_request_timeout=_request_timeout,
|
||||
body=body,
|
||||
)
|
||||
29
benchmark/agent_protocol_client/pyproject.toml
Normal file
29
benchmark/agent_protocol_client/pyproject.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
[tool.poetry]
|
||||
name = "agent-protocol-client"
|
||||
version = "0.2.2"
|
||||
description = "Agent Communication Protocol Client"
|
||||
authors = ["e2b <hello@e2b.dev>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
homepage = "https://e2b.dev/"
|
||||
repository = "https://github.com/e2b-dev/sdk/tree/main/agent_client/python/"
|
||||
packages = [{ include = "agent_protocol_client" }]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
|
||||
urllib3 = ">= 1.25.3"
|
||||
python-dateutil = ">=2.8.2"
|
||||
aiohttp = ">= 3.8.4"
|
||||
pydantic = "^1.10.5, <2"
|
||||
aenum = ">=3.1.11"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.7.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry.urls]
|
||||
"Bug Tracker" = "https://github.com/e2b-dev/agent-protocol/issues"
|
||||
Reference in New Issue
Block a user