From 47dcc844655ec66a0f71d4d50642d9ba97cf1026 Mon Sep 17 00:00:00 2001 From: rramakrishnan2 Date: Wed, 16 Apr 2025 20:02:13 -0700 Subject: [PATCH] feat: introducing resume run api --- client-python/.openapi-generator/FILES | 12 + client-python/README.md | 8 + client-python/ap_client/__init__.py | 6 + client-python/ap_client/api/runs_api.py | 551 ++++++++++++++++++ client-python/ap_client/models/__init__.py | 6 + client-python/ap_client/models/goto.py | 187 ++++++ client-python/ap_client/models/resume.py | 215 +++++++ client-python/ap_client/models/run_update.py | 92 +++ .../ap_client/models/run_update_command.py | 118 ++++ client-python/ap_client/models/send.py | 83 +++ client-python/ap_client/models/update.py | 158 +++++ client-python/docs/Goto.md | 31 + client-python/docs/Resume.md | 29 + client-python/docs/RunUpdate.md | 29 + client-python/docs/RunUpdateCommand.md | 31 + client-python/docs/RunsApi.md | 149 +++++ client-python/docs/Send.md | 31 + client-python/docs/Update.md | 29 + client-python/test/test_goto.py | 54 ++ client-python/test/test_resume.py | 50 ++ client-python/test/test_run_update.py | 54 ++ client-python/test/test_run_update_command.py | 53 ++ client-python/test/test_send.py | 54 ++ client-python/test/test_update.py | 50 ++ openapi.json | 245 +++++++- server/ap_server/models.py | 27 + server/ap_server/routers/runs.py | 40 +- 27 files changed, 2390 insertions(+), 2 deletions(-) create mode 100644 client-python/ap_client/models/goto.py create mode 100644 client-python/ap_client/models/resume.py create mode 100644 client-python/ap_client/models/run_update.py create mode 100644 client-python/ap_client/models/run_update_command.py create mode 100644 client-python/ap_client/models/send.py create mode 100644 client-python/ap_client/models/update.py create mode 100644 client-python/docs/Goto.md create mode 100644 client-python/docs/Resume.md create mode 100644 client-python/docs/RunUpdate.md create mode 100644 client-python/docs/RunUpdateCommand.md create mode 100644 client-python/docs/Send.md create mode 100644 client-python/docs/Update.md create mode 100644 client-python/test/test_goto.py create mode 100644 client-python/test/test_resume.py create mode 100644 client-python/test/test_run_update.py create mode 100644 client-python/test/test_run_update_command.py create mode 100644 client-python/test/test_send.py create mode 100644 client-python/test/test_update.py diff --git a/client-python/.openapi-generator/FILES b/client-python/.openapi-generator/FILES index f52fa59..0ad844a 100644 --- a/client-python/.openapi-generator/FILES +++ b/client-python/.openapi-generator/FILES @@ -22,18 +22,23 @@ ap_client/models/config.py ap_client/models/content.py ap_client/models/content_one_of_inner.py ap_client/models/error_response.py +ap_client/models/goto.py ap_client/models/input.py ap_client/models/item.py ap_client/models/message.py ap_client/models/message_any_block.py ap_client/models/message_text_block.py +ap_client/models/resume.py ap_client/models/run.py ap_client/models/run_create.py ap_client/models/run_search_request.py ap_client/models/run_status.py +ap_client/models/run_update.py +ap_client/models/run_update_command.py ap_client/models/run_wait_response.py ap_client/models/search_agents_request.py ap_client/models/search_items_response.py +ap_client/models/send.py ap_client/models/store_delete_request.py ap_client/models/store_list_namespaces_request.py ap_client/models/store_put_request.py @@ -46,6 +51,7 @@ ap_client/models/thread_patch.py ap_client/models/thread_search_request.py ap_client/models/thread_state.py ap_client/models/thread_status.py +ap_client/models/update.py ap_client/py.typed ap_client/rest.py docs/Agent.md @@ -57,19 +63,24 @@ docs/Config.md docs/Content.md docs/ContentOneOfInner.md docs/ErrorResponse.md +docs/Goto.md docs/Input.md docs/Item.md docs/Message.md docs/MessageAnyBlock.md docs/MessageTextBlock.md +docs/Resume.md docs/Run.md docs/RunCreate.md docs/RunSearchRequest.md docs/RunStatus.md +docs/RunUpdate.md +docs/RunUpdateCommand.md docs/RunWaitResponse.md docs/RunsApi.md docs/SearchAgentsRequest.md docs/SearchItemsResponse.md +docs/Send.md docs/StoreApi.md docs/StoreDeleteRequest.md docs/StoreListNamespacesRequest.md @@ -84,6 +95,7 @@ docs/ThreadSearchRequest.md docs/ThreadState.md docs/ThreadStatus.md docs/ThreadsApi.md +docs/Update.md git_push.sh pyproject.toml requirements.txt diff --git a/client-python/README.md b/client-python/README.md index f6fe063..f254da8 100644 --- a/client-python/README.md +++ b/client-python/README.md @@ -97,6 +97,8 @@ Class | Method | HTTP request | Description *BackgroundRunsApi* | [**wait_run**](docs/BackgroundRunsApi.md#wait_run) | **GET** /runs/{run_id}/wait | Wait for Run output *RunsApi* | [**create_and_stream_run**](docs/RunsApi.md#create_and_stream_run) | **POST** /runs/stream | Create Run, Stream Output *RunsApi* | [**create_and_wait_run**](docs/RunsApi.md#create_and_wait_run) | **POST** /runs/wait | Create Run, Wait for Output +*RunsApi* | [**update_and_stream_run**](docs/RunsApi.md#update_and_stream_run) | **POST** /runs/{run_id}/stream | Update Run, Stream Output +*RunsApi* | [**update_and_wait_run**](docs/RunsApi.md#update_and_wait_run) | **POST** /runs/{run_id}/wait | Update Run, Wait for Output *StoreApi* | [**delete_item**](docs/StoreApi.md#delete_item) | **DELETE** /store/items | Delete Store Item *StoreApi* | [**get_item**](docs/StoreApi.md#get_item) | **GET** /store/items | Get Store Item *StoreApi* | [**list_namespaces**](docs/StoreApi.md#list_namespaces) | **POST** /store/namespaces | List namespaces @@ -120,18 +122,23 @@ Class | Method | HTTP request | Description - [Content](docs/Content.md) - [ContentOneOfInner](docs/ContentOneOfInner.md) - [ErrorResponse](docs/ErrorResponse.md) + - [Goto](docs/Goto.md) - [Input](docs/Input.md) - [Item](docs/Item.md) - [Message](docs/Message.md) - [MessageAnyBlock](docs/MessageAnyBlock.md) - [MessageTextBlock](docs/MessageTextBlock.md) + - [Resume](docs/Resume.md) - [Run](docs/Run.md) - [RunCreate](docs/RunCreate.md) - [RunSearchRequest](docs/RunSearchRequest.md) - [RunStatus](docs/RunStatus.md) + - [RunUpdate](docs/RunUpdate.md) + - [RunUpdateCommand](docs/RunUpdateCommand.md) - [RunWaitResponse](docs/RunWaitResponse.md) - [SearchAgentsRequest](docs/SearchAgentsRequest.md) - [SearchItemsResponse](docs/SearchItemsResponse.md) + - [Send](docs/Send.md) - [StoreDeleteRequest](docs/StoreDeleteRequest.md) - [StoreListNamespacesRequest](docs/StoreListNamespacesRequest.md) - [StorePutRequest](docs/StorePutRequest.md) @@ -144,6 +151,7 @@ Class | Method | HTTP request | Description - [ThreadSearchRequest](docs/ThreadSearchRequest.md) - [ThreadState](docs/ThreadState.md) - [ThreadStatus](docs/ThreadStatus.md) + - [Update](docs/Update.md) diff --git a/client-python/ap_client/__init__.py b/client-python/ap_client/__init__.py index 1d053a6..7baadd5 100644 --- a/client-python/ap_client/__init__.py +++ b/client-python/ap_client/__init__.py @@ -41,18 +41,23 @@ from ap_client.models.content import Content from ap_client.models.content_one_of_inner import ContentOneOfInner from ap_client.models.error_response import ErrorResponse +from ap_client.models.goto import Goto from ap_client.models.input import Input from ap_client.models.item import Item from ap_client.models.message import Message from ap_client.models.message_any_block import MessageAnyBlock from ap_client.models.message_text_block import MessageTextBlock +from ap_client.models.resume import Resume from ap_client.models.run import Run from ap_client.models.run_create import RunCreate from ap_client.models.run_search_request import RunSearchRequest from ap_client.models.run_status import RunStatus +from ap_client.models.run_update import RunUpdate +from ap_client.models.run_update_command import RunUpdateCommand from ap_client.models.run_wait_response import RunWaitResponse from ap_client.models.search_agents_request import SearchAgentsRequest from ap_client.models.search_items_response import SearchItemsResponse +from ap_client.models.send import Send from ap_client.models.store_delete_request import StoreDeleteRequest from ap_client.models.store_list_namespaces_request import StoreListNamespacesRequest from ap_client.models.store_put_request import StorePutRequest @@ -65,3 +70,4 @@ from ap_client.models.thread_search_request import ThreadSearchRequest from ap_client.models.thread_state import ThreadState from ap_client.models.thread_status import ThreadStatus +from ap_client.models.update import Update diff --git a/client-python/ap_client/api/runs_api.py b/client-python/ap_client/api/runs_api.py index 5cb0617..0d73ae2 100644 --- a/client-python/ap_client/api/runs_api.py +++ b/client-python/ap_client/api/runs_api.py @@ -16,6 +16,7 @@ from typing_extensions import Annotated from ap_client.models.run_create import RunCreate +from ap_client.models.run_update import RunUpdate from ap_client.models.run_wait_response import RunWaitResponse from ap_client.api_client import ApiClient, RequestSerialized @@ -554,3 +555,553 @@ def _create_and_wait_run_serialize( _host=_host, _request_auth=_request_auth, ) + + @validate_call + def update_and_stream_run( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> str: + """Update Run, Stream Output + + Update a run, stream the output. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_stream_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "str", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def update_and_stream_run_with_http_info( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[str]: + """Update Run, Stream Output + + Update a run, stream the output. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_stream_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "str", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def update_and_stream_run_without_preload_content( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update Run, Stream Output + + Update a run, stream the output. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_stream_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "str", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _update_and_stream_run_serialize( + self, + run_id, + run_update, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if run_id is not None: + _path_params["run_id"] = run_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if run_update is not None: + _body_params = run_update + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["text/event-stream", "application/json"] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type( + ["application/json"] + ) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/runs/{run_id}/stream", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def update_and_wait_run( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RunWaitResponse: + """Update Run, Wait for Output + + Update a run in a thread. Wait for the final output and then return it. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_wait_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RunWaitResponse", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def update_and_wait_run_with_http_info( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RunWaitResponse]: + """Update Run, Wait for Output + + Update a run in a thread. Wait for the final output and then return it. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_wait_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RunWaitResponse", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def update_and_wait_run_without_preload_content( + self, + run_id: Annotated[StrictStr, Field(description="The ID of the run.")], + run_update: RunUpdate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update Run, Wait for Output + + Update a run in a thread. Wait for the final output and then return it. + + :param run_id: The ID of the run. (required) + :type run_id: str + :param run_update: (required) + :type run_update: RunUpdate + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_and_wait_run_serialize( + run_id=run_id, + run_update=run_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "RunWaitResponse", + "404": "ErrorResponse", + "409": "ErrorResponse", + "422": "ErrorResponse", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _update_and_wait_run_serialize( + self, + run_id, + run_update, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if run_id is not None: + _path_params["run_id"] = run_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if run_update is not None: + _body_params = run_update + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type( + ["application/json"] + ) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/runs/{run_id}/wait", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/client-python/ap_client/models/__init__.py b/client-python/ap_client/models/__init__.py index c7a5dc4..0ffdfc4 100644 --- a/client-python/ap_client/models/__init__.py +++ b/client-python/ap_client/models/__init__.py @@ -20,18 +20,23 @@ from ap_client.models.content import Content from ap_client.models.content_one_of_inner import ContentOneOfInner from ap_client.models.error_response import ErrorResponse +from ap_client.models.goto import Goto from ap_client.models.input import Input from ap_client.models.item import Item from ap_client.models.message import Message from ap_client.models.message_any_block import MessageAnyBlock from ap_client.models.message_text_block import MessageTextBlock +from ap_client.models.resume import Resume from ap_client.models.run import Run from ap_client.models.run_create import RunCreate from ap_client.models.run_search_request import RunSearchRequest from ap_client.models.run_status import RunStatus +from ap_client.models.run_update import RunUpdate +from ap_client.models.run_update_command import RunUpdateCommand from ap_client.models.run_wait_response import RunWaitResponse from ap_client.models.search_agents_request import SearchAgentsRequest from ap_client.models.search_items_response import SearchItemsResponse +from ap_client.models.send import Send from ap_client.models.store_delete_request import StoreDeleteRequest from ap_client.models.store_list_namespaces_request import StoreListNamespacesRequest from ap_client.models.store_put_request import StorePutRequest @@ -44,3 +49,4 @@ from ap_client.models.thread_search_request import ThreadSearchRequest from ap_client.models.thread_state import ThreadState from ap_client.models.thread_status import ThreadStatus +from ap_client.models.update import Update diff --git a/client-python/ap_client/models/goto.py b/client-python/ap_client/models/goto.py new file mode 100644 index 0000000..2aa580b --- /dev/null +++ b/client-python/ap_client/models/goto.py @@ -0,0 +1,187 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +import re # noqa: F401 +from pydantic import ( + BaseModel, + StrictStr, + ValidationError, + field_validator, +) +from typing import List, Optional +from ap_client.models.send import Send +from typing import Union, Any, Set, TYPE_CHECKING, Dict +from typing_extensions import Self + +GOTO_ANY_OF_SCHEMAS = ["List[Send]", "List[str]", "Send", "str"] + + +class Goto(BaseModel): + """ + Name of the node(s) to navigate to next or node(s) to be executed with a provided input. + """ + + # data type: str + anyof_schema_1_validator: Optional[StrictStr] = None + # data type: List[str] + anyof_schema_2_validator: Optional[List[StrictStr]] = None + # data type: Send + anyof_schema_3_validator: Optional[Send] = None + # data type: List[Send] + anyof_schema_4_validator: Optional[List[Send]] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[List[Send], List[str], Send, str]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = {"List[Send]", "List[str]", "Send", "str"} + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_anyof(cls, v): + instance = Goto.model_construct() + error_messages = [] + # validate data type: str + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[str] + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: Send + if not isinstance(v, Send): + error_messages.append(f"Error! Input type `{type(v)}` is not `Send`") + else: + return v + + # validate data type: List[Send] + try: + instance.anyof_schema_4_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError( + "No match found when setting the actual_instance in Goto with anyOf schemas: List[Send], List[str], Send, str. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + # deserialize data into str + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[str] + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # anyof_schema_3_validator: Optional[Send] = None + try: + instance.actual_instance = Send.from_json(json_str) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[Send] + try: + # validation + instance.anyof_schema_4_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_4_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError( + "No match found when deserializing the JSON string into Goto with anyOf schemas: List[Send], List[str], Send, str. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json + ): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict( + self, + ) -> Optional[Union[Dict[str, Any], List[Send], List[str], Send, str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict + ): + return self.actual_instance.to_dict() + else: + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/client-python/ap_client/models/resume.py b/client-python/ap_client/models/resume.py new file mode 100644 index 0000000..b952a69 --- /dev/null +++ b/client-python/ap_client/models/resume.py @@ -0,0 +1,215 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +import re # noqa: F401 +from pydantic import ( + BaseModel, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, + ValidationError, + field_validator, +) +from typing import Any, Dict, List, Optional, Union +from typing import Set, TYPE_CHECKING +from typing_extensions import Self + +RESUME_ANY_OF_SCHEMAS = ["List[object]", "bool", "float", "object", "str"] + + +class Resume(BaseModel): + """ + Name of the node(s) to navigate to next or node(s) to be executed with a provided input. + """ + + # data type: object + anyof_schema_1_validator: Optional[Dict[str, Any]] = None + # data type: List[object] + anyof_schema_2_validator: Optional[List[Any]] = None + # data type: str + anyof_schema_3_validator: Optional[StrictStr] = None + # data type: float + anyof_schema_4_validator: Optional[Union[StrictFloat, StrictInt]] = None + # data type: bool + anyof_schema_5_validator: Optional[StrictBool] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[List[object], bool, float, object, str]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = {"List[object]", "bool", "float", "object", "str"} + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_anyof(cls, v): + if v is None: + return v + + instance = Resume.model_construct() + error_messages = [] + # validate data type: object + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[object] + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: str + try: + instance.anyof_schema_3_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: float + try: + instance.anyof_schema_4_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: bool + try: + instance.anyof_schema_5_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError( + "No match found when setting the actual_instance in Resume with anyOf schemas: List[object], bool, float, object, str. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + # deserialize data into object + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[object] + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into str + try: + # validation + instance.anyof_schema_3_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_3_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into float + try: + # validation + instance.anyof_schema_4_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_4_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into bool + try: + # validation + instance.anyof_schema_5_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_5_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError( + "No match found when deserializing the JSON string into Resume with anyOf schemas: List[object], bool, float, object, str. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json + ): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict( + self, + ) -> Optional[Union[Dict[str, Any], List[object], bool, float, object, str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict + ): + return self.actual_instance.to_dict() + else: + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/client-python/ap_client/models/run_update.py b/client-python/ap_client/models/run_update.py new file mode 100644 index 0000000..d86c5f3 --- /dev/null +++ b/client-python/ap_client/models/run_update.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from ap_client.models.run_update_command import RunUpdateCommand +from typing import Set +from typing_extensions import Self + + +class RunUpdate(BaseModel): + """ + RunUpdate + """ # noqa: E501 + + command: Optional[RunUpdateCommand] = None + __properties: ClassVar[List[str]] = ["command"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RunUpdate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of command + if self.command: + _dict["command"] = self.command.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RunUpdate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "command": RunUpdateCommand.from_dict(obj["command"]) + if obj.get("command") is not None + else None + } + ) + return _obj diff --git a/client-python/ap_client/models/run_update_command.py b/client-python/ap_client/models/run_update_command.py new file mode 100644 index 0000000..40a6a1d --- /dev/null +++ b/client-python/ap_client/models/run_update_command.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from ap_client.models.goto import Goto +from ap_client.models.resume import Resume +from ap_client.models.update import Update +from typing import Set +from typing_extensions import Self + + +class RunUpdateCommand(BaseModel): + """ + RunUpdateCommand + """ # noqa: E501 + + update: Optional[Update] = None + resume: Optional[Resume] = None + goto: Optional[Goto] = None + __properties: ClassVar[List[str]] = ["update", "resume", "goto"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RunUpdateCommand from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of update + if self.update: + _dict["update"] = self.update.to_dict() + # override the default output from pydantic by calling `to_dict()` of resume + if self.resume: + _dict["resume"] = self.resume.to_dict() + # override the default output from pydantic by calling `to_dict()` of goto + if self.goto: + _dict["goto"] = self.goto.to_dict() + # set to None if update (nullable) is None + # and model_fields_set contains the field + if self.update is None and "update" in self.model_fields_set: + _dict["update"] = None + + # set to None if resume (nullable) is None + # and model_fields_set contains the field + if self.resume is None and "resume" in self.model_fields_set: + _dict["resume"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RunUpdateCommand from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "update": Update.from_dict(obj["update"]) + if obj.get("update") is not None + else None, + "resume": Resume.from_dict(obj["resume"]) + if obj.get("resume") is not None + else None, + "goto": Goto.from_dict(obj["goto"]) + if obj.get("goto") is not None + else None, + } + ) + return _obj diff --git a/client-python/ap_client/models/send.py b/client-python/ap_client/models/send.py new file mode 100644 index 0000000..3280dfb --- /dev/null +++ b/client-python/ap_client/models/send.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + + +class Send(BaseModel): + """ + A message or packet to send to a specific node in the graph. + """ # noqa: E501 + + node: StrictStr = Field(description="The node to send the message to.") + input: Dict[str, Any] = Field(description="The message to send.") + __properties: ClassVar[List[str]] = ["node", "input"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Send from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Send from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"node": obj.get("node"), "input": obj.get("input")}) + return _obj diff --git a/client-python/ap_client/models/update.py b/client-python/ap_client/models/update.py new file mode 100644 index 0000000..6016e85 --- /dev/null +++ b/client-python/ap_client/models/update.py @@ -0,0 +1,158 @@ +# coding: utf-8 + +""" +Agent Protocol + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 0.1.6 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +import re # noqa: F401 +from pydantic import ( + BaseModel, + ValidationError, + field_validator, +) +from typing import Any, Dict, List, Optional +from typing import Union, Set, TYPE_CHECKING +from typing_extensions import Self + +UPDATE_ANY_OF_SCHEMAS = ["List[object]", "object"] + + +class Update(BaseModel): + """ + An update to the state. + """ + + # data type: object + anyof_schema_1_validator: Optional[Dict[str, Any]] = None + # data type: List[object] + anyof_schema_2_validator: Optional[List[Any]] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[List[object], object]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = {"List[object]", "object"} + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_anyof(cls, v): + if v is None: + return v + + instance = Update.model_construct() + error_messages = [] + # validate data type: object + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[object] + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError( + "No match found when setting the actual_instance in Update with anyOf schemas: List[object], object. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + # deserialize data into object + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[object] + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError( + "No match found when deserializing the JSON string into Update with anyOf schemas: List[object], object. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json + ): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], List[object], object]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict + ): + return self.actual_instance.to_dict() + else: + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/client-python/docs/Goto.md b/client-python/docs/Goto.md new file mode 100644 index 0000000..206fa5f --- /dev/null +++ b/client-python/docs/Goto.md @@ -0,0 +1,31 @@ +# Goto + +Name of the node(s) to navigate to next or node(s) to be executed with a provided input. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**node** | **str** | The node to send the message to. | +**input** | **object** | The message to send. | + +## Example + +```python +from ap_client.models.goto import Goto + +# TODO update the JSON string below +json = "{}" +# create an instance of Goto from a JSON string +goto_instance = Goto.from_json(json) +# print the JSON string representation of the object +print(Goto.to_json()) + +# convert the object into a dict +goto_dict = goto_instance.to_dict() +# create an instance of Goto from a dict +goto_from_dict = Goto.from_dict(goto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/docs/Resume.md b/client-python/docs/Resume.md new file mode 100644 index 0000000..3aa4e6a --- /dev/null +++ b/client-python/docs/Resume.md @@ -0,0 +1,29 @@ +# Resume + +Name of the node(s) to navigate to next or node(s) to be executed with a provided input. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from ap_client.models.resume import Resume + +# TODO update the JSON string below +json = "{}" +# create an instance of Resume from a JSON string +resume_instance = Resume.from_json(json) +# print the JSON string representation of the object +print(Resume.to_json()) + +# convert the object into a dict +resume_dict = resume_instance.to_dict() +# create an instance of Resume from a dict +resume_from_dict = Resume.from_dict(resume_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/docs/RunUpdate.md b/client-python/docs/RunUpdate.md new file mode 100644 index 0000000..4627143 --- /dev/null +++ b/client-python/docs/RunUpdate.md @@ -0,0 +1,29 @@ +# RunUpdate + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**command** | [**RunUpdateCommand**](RunUpdateCommand.md) | | [optional] + +## Example + +```python +from ap_client.models.run_update import RunUpdate + +# TODO update the JSON string below +json = "{}" +# create an instance of RunUpdate from a JSON string +run_update_instance = RunUpdate.from_json(json) +# print the JSON string representation of the object +print(RunUpdate.to_json()) + +# convert the object into a dict +run_update_dict = run_update_instance.to_dict() +# create an instance of RunUpdate from a dict +run_update_from_dict = RunUpdate.from_dict(run_update_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/docs/RunUpdateCommand.md b/client-python/docs/RunUpdateCommand.md new file mode 100644 index 0000000..01bbf0a --- /dev/null +++ b/client-python/docs/RunUpdateCommand.md @@ -0,0 +1,31 @@ +# RunUpdateCommand + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**update** | [**Update**](Update.md) | | [optional] +**resume** | [**Resume**](Resume.md) | | [optional] +**goto** | [**Goto**](Goto.md) | | [optional] + +## Example + +```python +from ap_client.models.run_update_command import RunUpdateCommand + +# TODO update the JSON string below +json = "{}" +# create an instance of RunUpdateCommand from a JSON string +run_update_command_instance = RunUpdateCommand.from_json(json) +# print the JSON string representation of the object +print(RunUpdateCommand.to_json()) + +# convert the object into a dict +run_update_command_dict = run_update_command_instance.to_dict() +# create an instance of RunUpdateCommand from a dict +run_update_command_from_dict = RunUpdateCommand.from_dict(run_update_command_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/docs/RunsApi.md b/client-python/docs/RunsApi.md index ee24f4a..dc55142 100644 --- a/client-python/docs/RunsApi.md +++ b/client-python/docs/RunsApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**create_and_stream_run**](RunsApi.md#create_and_stream_run) | **POST** /runs/stream | Create Run, Stream Output [**create_and_wait_run**](RunsApi.md#create_and_wait_run) | **POST** /runs/wait | Create Run, Wait for Output +[**update_and_stream_run**](RunsApi.md#update_and_stream_run) | **POST** /runs/{run_id}/stream | Update Run, Stream Output +[**update_and_wait_run**](RunsApi.md#update_and_wait_run) | **POST** /runs/{run_id}/wait | Update Run, Wait for Output # **create_and_stream_run** @@ -151,3 +153,150 @@ 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) +# **update_and_stream_run** +> str update_and_stream_run(run_id, run_update) + +Update Run, Stream Output + +Update a run, stream the output. + +### Example + + +```python +import ap_client +from ap_client.models.run_update import RunUpdate +from ap_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 = ap_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with ap_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = ap_client.RunsApi(api_client) + run_id = 'run_id_example' # str | The ID of the run. + run_update = ap_client.RunUpdate() # RunUpdate | + + try: + # Update Run, Stream Output + api_response = api_instance.update_and_stream_run(run_id, run_update) + print("The response of RunsApi->update_and_stream_run:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RunsApi->update_and_stream_run: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **run_id** | **str**| The ID of the run. | + **run_update** | [**RunUpdate**](RunUpdate.md)| | + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/event-stream, application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | +**404** | Not Found | - | +**409** | Conflict | - | +**422** | Validation 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) + +# **update_and_wait_run** +> RunWaitResponse update_and_wait_run(run_id, run_update) + +Update Run, Wait for Output + +Update a run in a thread. Wait for the final output and then return it. + +### Example + + +```python +import ap_client +from ap_client.models.run_update import RunUpdate +from ap_client.models.run_wait_response import RunWaitResponse +from ap_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 = ap_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with ap_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = ap_client.RunsApi(api_client) + run_id = 'run_id_example' # str | The ID of the run. + run_update = ap_client.RunUpdate() # RunUpdate | + + try: + # Update Run, Wait for Output + api_response = api_instance.update_and_wait_run(run_id, run_update) + print("The response of RunsApi->update_and_wait_run:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RunsApi->update_and_wait_run: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **run_id** | **str**| The ID of the run. | + **run_update** | [**RunUpdate**](RunUpdate.md)| | + +### Return type + +[**RunWaitResponse**](RunWaitResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | +**404** | Not Found | - | +**409** | Conflict | - | +**422** | Validation 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) + diff --git a/client-python/docs/Send.md b/client-python/docs/Send.md new file mode 100644 index 0000000..8966b23 --- /dev/null +++ b/client-python/docs/Send.md @@ -0,0 +1,31 @@ +# Send + +A message or packet to send to a specific node in the graph. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**node** | **str** | The node to send the message to. | +**input** | **object** | The message to send. | + +## Example + +```python +from ap_client.models.send import Send + +# TODO update the JSON string below +json = "{}" +# create an instance of Send from a JSON string +send_instance = Send.from_json(json) +# print the JSON string representation of the object +print(Send.to_json()) + +# convert the object into a dict +send_dict = send_instance.to_dict() +# create an instance of Send from a dict +send_from_dict = Send.from_dict(send_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/docs/Update.md b/client-python/docs/Update.md new file mode 100644 index 0000000..48fbba9 --- /dev/null +++ b/client-python/docs/Update.md @@ -0,0 +1,29 @@ +# Update + +An update to the state. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from ap_client.models.update import Update + +# TODO update the JSON string below +json = "{}" +# create an instance of Update from a JSON string +update_instance = Update.from_json(json) +# print the JSON string representation of the object +print(Update.to_json()) + +# convert the object into a dict +update_dict = update_instance.to_dict() +# create an instance of Update from a dict +update_from_dict = Update.from_dict(update_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-python/test/test_goto.py b/client-python/test/test_goto.py new file mode 100644 index 0000000..3624246 --- /dev/null +++ b/client-python/test/test_goto.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.goto import Goto + +class TestGoto(unittest.TestCase): + """Goto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Goto: + """Test Goto + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Goto` + """ + model = Goto() + if include_optional: + return Goto( + node = '', + input = ap_client.models.input.Input() + ) + else: + return Goto( + node = '', + input = ap_client.models.input.Input(), + ) + """ + + def testGoto(self): + """Test Goto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/client-python/test/test_resume.py b/client-python/test/test_resume.py new file mode 100644 index 0000000..0b2ceb3 --- /dev/null +++ b/client-python/test/test_resume.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.resume import Resume + +class TestResume(unittest.TestCase): + """Resume unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Resume: + """Test Resume + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Resume` + """ + model = Resume() + if include_optional: + return Resume( + ) + else: + return Resume( + ) + """ + + def testResume(self): + """Test Resume""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/client-python/test/test_run_update.py b/client-python/test/test_run_update.py new file mode 100644 index 0000000..5c32226 --- /dev/null +++ b/client-python/test/test_run_update.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.run_update import RunUpdate + +class TestRunUpdate(unittest.TestCase): + """RunUpdate unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> RunUpdate: + """Test RunUpdate + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RunUpdate` + """ + model = RunUpdate() + if include_optional: + return RunUpdate( + command = ap_client.models.run_update_command.RunUpdate_command( + update = null, + resume = null, + goto = null, ) + ) + else: + return RunUpdate( + ) + """ + + def testRunUpdate(self): + """Test RunUpdate""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/client-python/test/test_run_update_command.py b/client-python/test/test_run_update_command.py new file mode 100644 index 0000000..5ddf269 --- /dev/null +++ b/client-python/test/test_run_update_command.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.run_update_command import RunUpdateCommand + +class TestRunUpdateCommand(unittest.TestCase): + """RunUpdateCommand unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> RunUpdateCommand: + """Test RunUpdateCommand + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RunUpdateCommand` + """ + model = RunUpdateCommand() + if include_optional: + return RunUpdateCommand( + update = None, + resume = None, + goto = None + ) + else: + return RunUpdateCommand( + ) + """ + + def testRunUpdateCommand(self): + """Test RunUpdateCommand""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/client-python/test/test_send.py b/client-python/test/test_send.py new file mode 100644 index 0000000..fcca3af --- /dev/null +++ b/client-python/test/test_send.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.send import Send + +class TestSend(unittest.TestCase): + """Send unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Send: + """Test Send + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Send` + """ + model = Send() + if include_optional: + return Send( + node = '', + input = ap_client.models.input.Input() + ) + else: + return Send( + node = '', + input = ap_client.models.input.Input(), + ) + """ + + def testSend(self): + """Test Send""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/client-python/test/test_update.py b/client-python/test/test_update.py new file mode 100644 index 0000000..7b49290 --- /dev/null +++ b/client-python/test/test_update.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + Agent Protocol + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 0.1.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from ap_client.models.update import Update + +class TestUpdate(unittest.TestCase): + """Update unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Update: + """Test Update + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Update` + """ + model = Update() + if include_optional: + return Update( + ) + else: + return Update( + ) + """ + + def testUpdate(self): + """Test Update""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/openapi.json b/openapi.json index 715077a..5668ff2 100644 --- a/openapi.json +++ b/openapi.json @@ -819,6 +819,80 @@ } } } + }, + "post": { + "tags": [ + "Runs" + ], + "summary": "Update Run, Wait for Output", + "description": "Update a run in a thread. Wait for the final output and then return it.", + "operationId": "update_and_wait_run", + "parameters": [ + { + "description": "The ID of the run.", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Run Id", + "description": "The ID of the run." + }, + "name": "run_id", + "in": "path" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunWaitResponse" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } } }, "/runs/{run_id}/stream": { @@ -873,6 +947,81 @@ } } } + }, + "post": { + "tags": [ + "Runs" + ], + "summary": "Update Run, Stream Output", + "description": "Update a run, stream the output.", + "operationId": "update_and_stream_run", + "parameters": [ + { + "description": "The ID of the run.", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Run Id", + "description": "The ID of the run." + }, + "name": "run_id", + "in": "path" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/event-stream": { + "schema": { + "type": "string", + "description": "The server will send a stream of events in SSE format.\n\n**Example event**:\n\nid: 1\n\nevent: message\n\ndata: {}" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } } }, "/runs/{run_id}/cancel": { @@ -1632,6 +1781,79 @@ "title": "RunCreate", "description": "Payload for creating a run." }, + "RunUpdate": { + "properties": { + "command": { + "type": "object", + "properties": { + "update": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Update", + "description": "An update to the state." + }, + "resume": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "array" + }, + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Resume", + "description": "Name of the node(s) to navigate to next or node(s) to be executed with a provided input." + }, + "goto": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "$ref": "#/components/schemas/Send" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/Send" + } + } + ], + "title": "Goto", + "description": "Name of the node(s) to navigate to next or node(s) to be executed with a provided input." + } + }, + "required": [] + } + } + }, "Run": { "allOf": [ { @@ -2211,6 +2433,27 @@ "description": "A dictionary of additional information about the error." } } + }, + "Send": { + "type": "object", + "properties": { + "node": { + "type": "string", + "title": "Node", + "description": "The node to send the message to." + }, + "input": { + "type": "object", + "title": "Input", + "description": "The message to send." + } + }, + "title": "Send", + "description": "A message or packet to send to a specific node in the graph.", + "required": [ + "node", + "input" + ] } }, "responses": { @@ -2264,4 +2507,4 @@ } } } -} +} \ No newline at end of file diff --git a/server/ap_server/models.py b/server/ap_server/models.py index 780d25f..1c94e20 100644 --- a/server/ap_server/models.py +++ b/server/ap_server/models.py @@ -324,6 +324,13 @@ class ErrorResponse(BaseModel): ) +class Send(BaseModel): + node: str = Field(..., description="The node to send the message to.", title="Node") + input: Dict[str, Any] = Field( + ..., description="The message to send.", title="Input" + ) + + class AgentsSearchPostRequest(BaseModel): name: Optional[str] = Field(None, description="Name of the agent to search.") metadata: Optional[Dict[str, Any]] = Field( @@ -398,6 +405,26 @@ class RunCreate(BaseModel): ) +class Command(BaseModel): + update: Optional[Union[Dict[str, Any], List]] = Field( + None, description="An update to the state.", title="Update" + ) + resume: Optional[Union[Dict[str, Any], List, str, float, bool]] = Field( + None, + description="Name of the node(s) to navigate to next or node(s) to be executed with a provided input.", + title="Resume", + ) + goto: Optional[Union[str, List[str], Send, List[Send]]] = Field( + None, + description="Name of the node(s) to navigate to next or node(s) to be executed with a provided input.", + title="Goto", + ) + + +class RunUpdate(BaseModel): + command: Optional[Command] = None + + class Run(RunCreate): run_id: UUID = Field(..., description="The ID of the run.", title="Run Id") created_at: AwareDatetime = Field( diff --git a/server/ap_server/routers/runs.py b/server/ap_server/routers/runs.py index 9c6c98d..e95adf6 100644 --- a/server/ap_server/routers/runs.py +++ b/server/ap_server/routers/runs.py @@ -5,7 +5,7 @@ from fastapi import APIRouter -from ..models import ErrorResponse, RunCreate, RunWaitResponse, Union +from ..models import ErrorResponse, RunCreate, RunUpdate, RunWaitResponse, UUID, Union router = APIRouter(tags=["Runs"]) @@ -42,3 +42,41 @@ def create_and_wait_run(body: RunCreate) -> Union[RunWaitResponse, ErrorResponse Create Run, Wait for Output """ pass + + +@router.post( + "/runs/{run_id}/stream", + response_model=str, + responses={ + "404": {"model": ErrorResponse}, + "409": {"model": ErrorResponse}, + "422": {"model": ErrorResponse}, + }, + tags=["Runs"], +) +def update_and_stream_run( + run_id: UUID, body: RunUpdate = ... +) -> Union[str, ErrorResponse]: + """ + Update Run, Stream Output + """ + pass + + +@router.post( + "/runs/{run_id}/wait", + response_model=RunWaitResponse, + responses={ + "404": {"model": ErrorResponse}, + "409": {"model": ErrorResponse}, + "422": {"model": ErrorResponse}, + }, + tags=["Runs"], +) +def update_and_wait_run( + run_id: UUID, body: RunUpdate = ... +) -> Union[RunWaitResponse, ErrorResponse]: + """ + Update Run, Wait for Output + """ + pass