From 8232790c2bc6ba5d06e79c2590e2eceaa14699e0 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Tue, 8 Aug 2023 11:25:52 +0200 Subject: [PATCH] Python Agent Communication Protocol SDK Client v0.2.0 --- agent_client/python/.openapi-generator/FILES | 2 +- .../python/agent_protocol_client/__init__.py | 4 +- .../agent_protocol_client/api/agent_api.py | 354 +++++++++++++++++- .../agent_protocol_client/api_client.py | 2 +- .../agent_protocol_client/configuration.py | 4 +- .../agent_protocol_client/docs/AgentApi.md | 159 +++++++- .../agent_protocol_client/exceptions.py | 2 +- .../agent_protocol_client/models/__init__.py | 4 +- .../agent_protocol_client/models/step.py | 79 +++- .../models/step_all_of.py | 69 +++- .../models/step_request_body.py | 19 +- .../agent_protocol_client/models/task.py | 32 +- .../models/task_all_of.py | 25 +- .../models/task_request_body.py | 19 +- .../python/agent_protocol_client/rest.py | 2 +- agent_client/python/pyproject.toml | 2 +- 16 files changed, 700 insertions(+), 78 deletions(-) diff --git a/agent_client/python/.openapi-generator/FILES b/agent_client/python/.openapi-generator/FILES index 84245be..9e5548e 100644 --- a/agent_client/python/.openapi-generator/FILES +++ b/agent_client/python/.openapi-generator/FILES @@ -7,10 +7,10 @@ agent_protocol_client/configuration.py agent_protocol_client/docs/AgentApi.md agent_protocol_client/exceptions.py agent_protocol_client/models/__init__.py +agent_protocol_client/models/artifact.py agent_protocol_client/models/step.py agent_protocol_client/models/step_all_of.py agent_protocol_client/models/step_request_body.py -agent_protocol_client/models/step_result.py agent_protocol_client/models/task.py agent_protocol_client/models/task_all_of.py agent_protocol_client/models/task_request_body.py diff --git a/agent_client/python/agent_protocol_client/__init__.py b/agent_client/python/agent_protocol_client/__init__.py index f3418be..3b6967f 100644 --- a/agent_client/python/agent_protocol_client/__init__.py +++ b/agent_client/python/agent_protocol_client/__init__.py @@ -7,7 +7,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -31,10 +31,10 @@ from agent_protocol_client.exceptions import ApiException # 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.step_result import StepResult 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 diff --git a/agent_client/python/agent_protocol_client/api/agent_api.py b/agent_client/python/agent_protocol_client/api/agent_api.py index 5fe6ffe..b6223ab 100644 --- a/agent_client/python/agent_protocol_client/api/agent_api.py +++ b/agent_client/python/agent_protocol_client/api/agent_api.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -22,8 +22,9 @@ from pydantic import Field, StrictStr -from typing import List, Optional +from typing import List, Optional, Union +from agent_protocol_client.models.artifact import Artifact from agent_protocol_client.models.step import Step from agent_protocol_client.models.step_request_body import StepRequestBody from agent_protocol_client.models.task import Task @@ -220,6 +221,186 @@ def create_agent_task_with_http_info( _request_auth=_params.get("_request_auth"), ) + @overload + async def download_agent_task_artifact( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + artifact_id: Annotated[StrictStr, Field(..., description="ID of the artifact")], + **kwargs + ) -> bytearray: # noqa: E501 + ... + + @overload + def download_agent_task_artifact( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + artifact_id: Annotated[StrictStr, Field(..., description="ID of the artifact")], + async_req: Optional[bool] = True, + **kwargs + ) -> bytearray: # noqa: E501 + ... + + @validate_arguments + def download_agent_task_artifact( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + artifact_id: Annotated[StrictStr, Field(..., description="ID of the artifact")], + async_req: Optional[bool] = None, + **kwargs + ) -> Union[bytearray, Awaitable[bytearray]]: # noqa: E501 + """Download a specified artifact. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.download_agent_task_artifact(task_id, artifact_id, async_req=True) + >>> result = thread.get() + + :param task_id: ID of the task (required) + :type task_id: str + :param artifact_id: ID of the artifact (required) + :type artifact_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: bytearray + """ + kwargs["_return_http_data_only"] = True + if "_preload_content" in kwargs: + raise ValueError( + "Error! Please call the download_agent_task_artifact_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" + ) + if async_req is not None: + kwargs["async_req"] = async_req + return self.download_agent_task_artifact_with_http_info( + task_id, artifact_id, **kwargs + ) # noqa: E501 + + @validate_arguments + def download_agent_task_artifact_with_http_info( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + artifact_id: Annotated[StrictStr, Field(..., description="ID of the artifact")], + **kwargs + ) -> ApiResponse: # noqa: E501 + """Download a specified artifact. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.download_agent_task_artifact_with_http_info(task_id, artifact_id, async_req=True) + >>> result = thread.get() + + :param task_id: ID of the task (required) + :type task_id: str + :param artifact_id: ID of the artifact (required) + :type artifact_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(bytearray, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = ["task_id", "artifact_id"] + _all_params.extend( + [ + "async_req", + "_return_http_data_only", + "_preload_content", + "_request_timeout", + "_request_auth", + "_content_type", + "_headers", + ] + ) + + # validate the arguments + for _key, _val in _params["kwargs"].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method download_agent_task_artifact" % _key + ) + _params[_key] = _val + del _params["kwargs"] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params["task_id"]: + _path_params["task_id"] = _params["task_id"] + + if _params["artifact_id"]: + _path_params["artifact_id"] = _params["artifact_id"] + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get("_headers", {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/octet-stream"] + ) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + "200": "bytearray", + } + + return self.api_client.call_api( + "/agent/tasks/{task_id}/artifacts/{artifact_id}", + "GET", + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get("async_req"), + _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 + _preload_content=_params.get("_preload_content", True), + _request_timeout=_params.get("_request_timeout"), + collection_formats=_collection_formats, + _request_auth=_params.get("_request_auth"), + ) + @overload async def execute_agent_task_step( self, @@ -755,6 +936,175 @@ def get_agent_task_step_with_http_info( _request_auth=_params.get("_request_auth"), ) + @overload + async def list_agent_task_artifacts( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + **kwargs + ) -> List[Artifact]: # noqa: E501 + ... + + @overload + def list_agent_task_artifacts( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + async_req: Optional[bool] = True, + **kwargs + ) -> List[Artifact]: # noqa: E501 + ... + + @validate_arguments + def list_agent_task_artifacts( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + async_req: Optional[bool] = None, + **kwargs + ) -> Union[List[Artifact], Awaitable[List[Artifact]]]: # noqa: E501 + """List all artifacts that have been created for the given task. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.list_agent_task_artifacts(task_id, async_req=True) + >>> result = thread.get() + + :param task_id: ID of the task (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Artifact] + """ + kwargs["_return_http_data_only"] = True + if "_preload_content" in kwargs: + raise ValueError( + "Error! Please call the list_agent_task_artifacts_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" + ) + if async_req is not None: + kwargs["async_req"] = async_req + return self.list_agent_task_artifacts_with_http_info( + task_id, **kwargs + ) # noqa: E501 + + @validate_arguments + def list_agent_task_artifacts_with_http_info( + self, + task_id: Annotated[StrictStr, Field(..., description="ID of the task")], + **kwargs + ) -> ApiResponse: # noqa: E501 + """List all artifacts that have been created for the given task. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.list_agent_task_artifacts_with_http_info(task_id, async_req=True) + >>> result = thread.get() + + :param task_id: ID of the task (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Artifact], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = ["task_id"] + _all_params.extend( + [ + "async_req", + "_return_http_data_only", + "_preload_content", + "_request_timeout", + "_request_auth", + "_content_type", + "_headers", + ] + ) + + # validate the arguments + for _key, _val in _params["kwargs"].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method list_agent_task_artifacts" % _key + ) + _params[_key] = _val + del _params["kwargs"] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params["task_id"]: + _path_params["task_id"] = _params["task_id"] + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get("_headers", {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + "200": "List[Artifact]", + } + + return self.api_client.call_api( + "/agent/tasks/{task_id}/artifacts", + "GET", + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get("async_req"), + _return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501 + _preload_content=_params.get("_preload_content", True), + _request_timeout=_params.get("_request_timeout"), + collection_formats=_collection_formats, + _request_auth=_params.get("_request_auth"), + ) + @overload async def list_agent_task_steps( self, diff --git a/agent_client/python/agent_protocol_client/api_client.py b/agent_client/python/agent_protocol_client/api_client.py index 11cffb4..34001a1 100644 --- a/agent_client/python/agent_protocol_client/api_client.py +++ b/agent_client/python/agent_protocol_client/api_client.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. diff --git a/agent_client/python/agent_protocol_client/configuration.py b/agent_client/python/agent_protocol_client/configuration.py index 472aa59..bcf359a 100644 --- a/agent_client/python/agent_protocol_client/configuration.py +++ b/agent_client/python/agent_protocol_client/configuration.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -379,7 +379,7 @@ def to_debug_report(self): "Python SDK Debug Report:\n" "OS: {env}\n" "Python Version: {pyversion}\n" - "Version of the API: v1\n" + "Version of the API: v0.2\n" "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) ) diff --git a/agent_client/python/agent_protocol_client/docs/AgentApi.md b/agent_client/python/agent_protocol_client/docs/AgentApi.md index b652e1e..0c8d6c7 100644 --- a/agent_client/python/agent_protocol_client/docs/AgentApi.md +++ b/agent_client/python/agent_protocol_client/docs/AgentApi.md @@ -2,14 +2,16 @@ 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. | -| [**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_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. | +| 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. | # **create_agent_task** @@ -71,10 +73,77 @@ No authorization required ### HTTP response details -| Status code | Description | Response headers | -| ----------- | ----------------------------------------- | ---------------- | -| **200** | A new agent task was successfuly created. | - | -| **0** | Internal Server Error | - | +| 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) @@ -281,6 +350,72 @@ No authorization required [[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) diff --git a/agent_client/python/agent_protocol_client/exceptions.py b/agent_client/python/agent_protocol_client/exceptions.py index 5b41edf..bd26eac 100644 --- a/agent_client/python/agent_protocol_client/exceptions.py +++ b/agent_client/python/agent_protocol_client/exceptions.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. diff --git a/agent_client/python/agent_protocol_client/models/__init__.py b/agent_client/python/agent_protocol_client/models/__init__.py index 2e74cb4..bca1797 100644 --- a/agent_client/python/agent_protocol_client/models/__init__.py +++ b/agent_client/python/agent_protocol_client/models/__init__.py @@ -6,7 +6,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -14,10 +14,10 @@ # import models into model 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.step_result import StepResult 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 diff --git a/agent_client/python/agent_protocol_client/models/step.py b/agent_client/python/agent_protocol_client/models/step.py index 1bb7840..e121b8e 100644 --- a/agent_client/python/agent_protocol_client/models/step.py +++ b/agent_client/python/agent_protocol_client/models/step.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -19,7 +19,8 @@ from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist +from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, validator +from agent_protocol_client.models.artifact import Artifact class Step(BaseModel): @@ -27,24 +28,46 @@ class Step(BaseModel): Step """ - input: Optional[Any] = Field( + 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." ) - output: Optional[Any] = Field( + 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(Any) = Field( + 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." ) - 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.") - __properties = ["input", "output", "artifacts", "is_last", "task_id", "step_id"] + __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""" @@ -68,15 +91,25 @@ def from_json(cls, json_str: str) -> Step: 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 input (nullable) is None + # 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.input is None and "input" in self.__fields_set__: - _dict["input"] = None + if self.additional_input is None and "additional_input" in self.__fields_set__: + _dict["additional_input"] = None - # set to None if output (nullable) is None + # set to None if additional_output (nullable) is None # and __fields_set__ contains the field - if self.output is None and "output" in self.__fields_set__: - _dict["output"] = None + if ( + self.additional_output is None + and "additional_output" in self.__fields_set__ + ): + _dict["additional_output"] = None return _dict @@ -92,13 +125,21 @@ def from_dict(cls, obj: dict) -> Step: _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"), - "artifacts": obj.get("artifacts"), + "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, - "task_id": obj.get("task_id"), - "step_id": obj.get("step_id"), } ) return _obj diff --git a/agent_client/python/agent_protocol_client/models/step_all_of.py b/agent_client/python/agent_protocol_client/models/step_all_of.py index d81d1aa..eb81a36 100644 --- a/agent_client/python/agent_protocol_client/models/step_all_of.py +++ b/agent_client/python/agent_protocol_client/models/step_all_of.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -18,7 +18,9 @@ import json -from pydantic import BaseModel, Field, StrictStr +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): @@ -30,7 +32,36 @@ class StepAllOf(BaseModel): ..., description="The ID of the task this step belongs to." ) step_id: StrictStr = Field(..., description="The ID of the task step.") - __properties = ["task_id", "step_id"] + 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""" @@ -54,6 +85,21 @@ def from_json(cls, json_str: str) -> StepAllOf: 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 @@ -66,6 +112,21 @@ def from_dict(cls, obj: dict) -> StepAllOf: return StepAllOf.parse_obj(obj) _obj = StepAllOf.parse_obj( - {"task_id": obj.get("task_id"), "step_id": obj.get("step_id")} + { + "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 diff --git a/agent_client/python/agent_protocol_client/models/step_request_body.py b/agent_client/python/agent_protocol_client/models/step_request_body.py index 4112cce..5c7c28d 100644 --- a/agent_client/python/agent_protocol_client/models/step_request_body.py +++ b/agent_client/python/agent_protocol_client/models/step_request_body.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -19,7 +19,7 @@ from typing import Any, Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, StrictStr class StepRequestBody(BaseModel): @@ -27,10 +27,11 @@ class StepRequestBody(BaseModel): Body of the task request. """ - input: Optional[Any] = Field( + 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"] + __properties = ["input", "additional_input"] class Config: """Pydantic configuration""" @@ -54,10 +55,10 @@ def from_json(cls, json_str: str) -> StepRequestBody: 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 input (nullable) is None + # set to None if additional_input (nullable) is None # and __fields_set__ contains the field - if self.input is None and "input" in self.__fields_set__: - _dict["input"] = None + if self.additional_input is None and "additional_input" in self.__fields_set__: + _dict["additional_input"] = None return _dict @@ -70,5 +71,7 @@ def from_dict(cls, obj: dict) -> StepRequestBody: if not isinstance(obj, dict): return StepRequestBody.parse_obj(obj) - _obj = StepRequestBody.parse_obj({"input": obj.get("input")}) + _obj = StepRequestBody.parse_obj( + {"input": obj.get("input"), "additional_input": obj.get("additional_input")} + ) return _obj diff --git a/agent_client/python/agent_protocol_client/models/task.py b/agent_client/python/agent_protocol_client/models/task.py index 6003ad8..0d5d395 100644 --- a/agent_client/python/agent_protocol_client/models/task.py +++ b/agent_client/python/agent_protocol_client/models/task.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -20,6 +20,7 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, conlist +from agent_protocol_client.models.artifact import Artifact class Task(BaseModel): @@ -27,14 +28,15 @@ class Task(BaseModel): Task """ - input: Optional[Any] = Field( + 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: Optional[conlist(Any)] = Field( - None, description="A list of artifacts that the task has produced." + artifacts: conlist(Artifact) = Field( + ..., description="A list of artifacts that the task has produced." ) - __properties = ["input", "task_id", "artifacts"] + __properties = ["input", "additional_input", "task_id", "artifacts"] class Config: """Pydantic configuration""" @@ -58,10 +60,17 @@ def from_json(cls, json_str: str) -> Task: 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 input (nullable) is None + # 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.input is None and "input" in self.__fields_set__: - _dict["input"] = None + if self.additional_input is None and "additional_input" in self.__fields_set__: + _dict["additional_input"] = None return _dict @@ -77,8 +86,13 @@ def from_dict(cls, obj: dict) -> Task: _obj = Task.parse_obj( { "input": obj.get("input"), + "additional_input": obj.get("additional_input"), "task_id": obj.get("task_id"), - "artifacts": obj.get("artifacts"), + "artifacts": [ + Artifact.from_dict(_item) for _item in obj.get("artifacts") + ] + if obj.get("artifacts") is not None + else None, } ) return _obj diff --git a/agent_client/python/agent_protocol_client/models/task_all_of.py b/agent_client/python/agent_protocol_client/models/task_all_of.py index bdfd334..e62d08d 100644 --- a/agent_client/python/agent_protocol_client/models/task_all_of.py +++ b/agent_client/python/agent_protocol_client/models/task_all_of.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -18,8 +18,9 @@ import json -from typing import Any, List, Optional +from typing import List from pydantic import BaseModel, Field, StrictStr, conlist +from agent_protocol_client.models.artifact import Artifact class TaskAllOf(BaseModel): @@ -28,8 +29,8 @@ class TaskAllOf(BaseModel): """ task_id: StrictStr = Field(..., description="The ID of the task.") - artifacts: Optional[conlist(Any)] = Field( - None, description="A list of artifacts that the task has produced." + artifacts: conlist(Artifact) = Field( + ..., description="A list of artifacts that the task has produced." ) __properties = ["task_id", "artifacts"] @@ -55,6 +56,13 @@ def from_json(cls, json_str: str) -> TaskAllOf: 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 @@ -67,6 +75,13 @@ def from_dict(cls, obj: dict) -> TaskAllOf: return TaskAllOf.parse_obj(obj) _obj = TaskAllOf.parse_obj( - {"task_id": obj.get("task_id"), "artifacts": obj.get("artifacts")} + { + "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 diff --git a/agent_client/python/agent_protocol_client/models/task_request_body.py b/agent_client/python/agent_protocol_client/models/task_request_body.py index 0cf68d6..8cf810b 100644 --- a/agent_client/python/agent_protocol_client/models/task_request_body.py +++ b/agent_client/python/agent_protocol_client/models/task_request_body.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -19,7 +19,7 @@ from typing import Any, Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, StrictStr class TaskRequestBody(BaseModel): @@ -27,10 +27,11 @@ class TaskRequestBody(BaseModel): Body of the task request. """ - input: Optional[Any] = Field( + 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"] + __properties = ["input", "additional_input"] class Config: """Pydantic configuration""" @@ -54,10 +55,10 @@ def from_json(cls, json_str: str) -> TaskRequestBody: 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 input (nullable) is None + # set to None if additional_input (nullable) is None # and __fields_set__ contains the field - if self.input is None and "input" in self.__fields_set__: - _dict["input"] = None + if self.additional_input is None and "additional_input" in self.__fields_set__: + _dict["additional_input"] = None return _dict @@ -70,5 +71,7 @@ def from_dict(cls, obj: dict) -> TaskRequestBody: if not isinstance(obj, dict): return TaskRequestBody.parse_obj(obj) - _obj = TaskRequestBody.parse_obj({"input": obj.get("input")}) + _obj = TaskRequestBody.parse_obj( + {"input": obj.get("input"), "additional_input": obj.get("additional_input")} + ) return _obj diff --git a/agent_client/python/agent_protocol_client/rest.py b/agent_client/python/agent_protocol_client/rest.py index 00cc789..05b01ff 100644 --- a/agent_client/python/agent_protocol_client/rest.py +++ b/agent_client/python/agent_protocol_client/rest.py @@ -5,7 +5,7 @@ Specification of the API protocol for communication with an agent. # noqa: E501 - The version of the OpenAPI document: v1 + The version of the OpenAPI document: v0.2 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. diff --git a/agent_client/python/pyproject.toml b/agent_client/python/pyproject.toml index 0bb712f..ed13391 100644 --- a/agent_client/python/pyproject.toml +++ b/agent_client/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "agent-protocol-client" -version = "0.0.1" +version = "0.2.0" description = "Agent Communication Protocol Client" authors = ["e2b "] license = "MIT"