phenoml 0.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phenoml/__init__.py +30 -0
- phenoml/agent/__init__.py +56 -0
- phenoml/agent/client.py +939 -0
- phenoml/agent/errors/__init__.py +11 -0
- phenoml/agent/errors/bad_request_error.py +10 -0
- phenoml/agent/errors/forbidden_error.py +10 -0
- phenoml/agent/errors/internal_server_error.py +10 -0
- phenoml/agent/errors/not_found_error.py +10 -0
- phenoml/agent/errors/unauthorized_error.py +10 -0
- phenoml/agent/prompts/__init__.py +7 -0
- phenoml/agent/prompts/client.py +707 -0
- phenoml/agent/prompts/raw_client.py +1345 -0
- phenoml/agent/prompts/types/__init__.py +8 -0
- phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
- phenoml/agent/prompts/types/prompts_list_response.py +22 -0
- phenoml/agent/raw_client.py +1668 -0
- phenoml/agent/types/__init__.py +43 -0
- phenoml/agent/types/agent_chat_response.py +33 -0
- phenoml/agent/types/agent_create_request.py +53 -0
- phenoml/agent/types/agent_create_request_provider.py +5 -0
- phenoml/agent/types/agent_delete_response.py +20 -0
- phenoml/agent/types/agent_get_chat_messages_request_order.py +5 -0
- phenoml/agent/types/agent_get_chat_messages_response.py +22 -0
- phenoml/agent/types/agent_list_response.py +22 -0
- phenoml/agent/types/agent_prompts_response.py +22 -0
- phenoml/agent/types/agent_response.py +22 -0
- phenoml/agent/types/agent_template.py +58 -0
- phenoml/agent/types/agent_template_provider.py +5 -0
- phenoml/agent/types/chat_message_template.py +72 -0
- phenoml/agent/types/chat_session_template.py +67 -0
- phenoml/agent/types/json_patch.py +7 -0
- phenoml/agent/types/json_patch_operation.py +40 -0
- phenoml/agent/types/json_patch_operation_op.py +5 -0
- phenoml/agent/types/prompt_template.py +52 -0
- phenoml/agent/types/success_response.py +20 -0
- phenoml/authtoken/__init__.py +17 -0
- phenoml/authtoken/auth/__init__.py +7 -0
- phenoml/authtoken/auth/client.py +129 -0
- phenoml/authtoken/auth/raw_client.py +173 -0
- phenoml/authtoken/auth/types/__init__.py +7 -0
- phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
- phenoml/authtoken/client.py +39 -0
- phenoml/authtoken/errors/__init__.py +8 -0
- phenoml/authtoken/errors/bad_request_error.py +10 -0
- phenoml/authtoken/errors/unauthorized_error.py +10 -0
- phenoml/authtoken/raw_client.py +13 -0
- phenoml/authtoken/types/__init__.py +8 -0
- phenoml/authtoken/types/bad_request_error_body.py +21 -0
- phenoml/authtoken/types/unauthorized_error_body.py +21 -0
- phenoml/client.py +177 -0
- phenoml/cohort/__init__.py +8 -0
- phenoml/cohort/client.py +113 -0
- phenoml/cohort/errors/__init__.py +9 -0
- phenoml/cohort/errors/bad_request_error.py +10 -0
- phenoml/cohort/errors/internal_server_error.py +10 -0
- phenoml/cohort/errors/unauthorized_error.py +10 -0
- phenoml/cohort/raw_client.py +185 -0
- phenoml/cohort/types/__init__.py +8 -0
- phenoml/cohort/types/cohort_response.py +33 -0
- phenoml/cohort/types/search_concept.py +37 -0
- phenoml/construe/__init__.py +45 -0
- phenoml/construe/client.py +399 -0
- phenoml/construe/errors/__init__.py +11 -0
- phenoml/construe/errors/bad_request_error.py +10 -0
- phenoml/construe/errors/conflict_error.py +10 -0
- phenoml/construe/errors/failed_dependency_error.py +10 -0
- phenoml/construe/errors/internal_server_error.py +10 -0
- phenoml/construe/errors/unauthorized_error.py +10 -0
- phenoml/construe/raw_client.py +706 -0
- phenoml/construe/types/__init__.py +41 -0
- phenoml/construe/types/bad_request_error_body.py +27 -0
- phenoml/construe/types/construe_cohort_request_config.py +37 -0
- phenoml/construe/types/construe_cohort_response.py +33 -0
- phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
- phenoml/construe/types/construe_upload_code_system_response.py +19 -0
- phenoml/construe/types/extract_codes_result.py +22 -0
- phenoml/construe/types/extract_request_config.py +23 -0
- phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
- phenoml/construe/types/extract_request_system.py +37 -0
- phenoml/construe/types/extracted_code_result.py +41 -0
- phenoml/construe/types/internal_server_error_body.py +27 -0
- phenoml/construe/types/unauthorized_error_body.py +27 -0
- phenoml/construe/types/upload_request_format.py +5 -0
- phenoml/core/__init__.py +52 -0
- phenoml/core/api_error.py +23 -0
- phenoml/core/client_wrapper.py +87 -0
- phenoml/core/datetime_utils.py +28 -0
- phenoml/core/file.py +67 -0
- phenoml/core/force_multipart.py +16 -0
- phenoml/core/http_client.py +543 -0
- phenoml/core/http_response.py +55 -0
- phenoml/core/jsonable_encoder.py +100 -0
- phenoml/core/pydantic_utilities.py +255 -0
- phenoml/core/query_encoder.py +58 -0
- phenoml/core/remove_none_from_dict.py +11 -0
- phenoml/core/request_options.py +35 -0
- phenoml/core/serialization.py +276 -0
- phenoml/environment.py +7 -0
- phenoml/fhir/__init__.py +36 -0
- phenoml/fhir/client.py +970 -0
- phenoml/fhir/errors/__init__.py +10 -0
- phenoml/fhir/errors/bad_request_error.py +10 -0
- phenoml/fhir/errors/internal_server_error.py +10 -0
- phenoml/fhir/errors/not_found_error.py +10 -0
- phenoml/fhir/errors/unauthorized_error.py +10 -0
- phenoml/fhir/raw_client.py +1385 -0
- phenoml/fhir/types/__init__.py +29 -0
- phenoml/fhir/types/error_response.py +36 -0
- phenoml/fhir/types/fhir_bundle.py +43 -0
- phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
- phenoml/fhir/types/fhir_bundle_entry_item_response.py +24 -0
- phenoml/fhir/types/fhir_patch_request_body_item.py +40 -0
- phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
- phenoml/fhir/types/fhir_resource.py +40 -0
- phenoml/fhir/types/fhir_resource_meta.py +28 -0
- phenoml/fhir/types/fhir_search_response.py +8 -0
- phenoml/fhir_provider/__init__.py +43 -0
- phenoml/fhir_provider/client.py +731 -0
- phenoml/fhir_provider/errors/__init__.py +11 -0
- phenoml/fhir_provider/errors/bad_request_error.py +10 -0
- phenoml/fhir_provider/errors/forbidden_error.py +10 -0
- phenoml/fhir_provider/errors/internal_server_error.py +10 -0
- phenoml/fhir_provider/errors/not_found_error.py +10 -0
- phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
- phenoml/fhir_provider/raw_client.py +1445 -0
- phenoml/fhir_provider/types/__init__.py +35 -0
- phenoml/fhir_provider/types/auth_method.py +7 -0
- phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
- phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
- phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
- phenoml/fhir_provider/types/fhir_query_response.py +27 -0
- phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
- phenoml/fhir_provider/types/json_web_key.py +51 -0
- phenoml/fhir_provider/types/provider.py +8 -0
- phenoml/fhir_provider/types/service_account_key.py +35 -0
- phenoml/fhir_provider/types/smart_configuration.py +46 -0
- phenoml/lang2fhir/__init__.py +27 -0
- phenoml/lang2fhir/client.py +430 -0
- phenoml/lang2fhir/errors/__init__.py +11 -0
- phenoml/lang2fhir/errors/bad_request_error.py +10 -0
- phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
- phenoml/lang2fhir/errors/forbidden_error.py +10 -0
- phenoml/lang2fhir/errors/internal_server_error.py +10 -0
- phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
- phenoml/lang2fhir/raw_client.py +788 -0
- phenoml/lang2fhir/types/__init__.py +19 -0
- phenoml/lang2fhir/types/create_request_resource.py +25 -0
- phenoml/lang2fhir/types/document_request_file_type.py +7 -0
- phenoml/lang2fhir/types/document_request_resource.py +5 -0
- phenoml/lang2fhir/types/fhir_resource.py +5 -0
- phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
- phenoml/lang2fhir/types/search_response.py +33 -0
- phenoml/py.typed +0 -0
- phenoml/tools/__init__.py +37 -0
- phenoml/tools/client.py +359 -0
- phenoml/tools/errors/__init__.py +11 -0
- phenoml/tools/errors/bad_request_error.py +10 -0
- phenoml/tools/errors/failed_dependency_error.py +10 -0
- phenoml/tools/errors/forbidden_error.py +10 -0
- phenoml/tools/errors/internal_server_error.py +10 -0
- phenoml/tools/errors/unauthorized_error.py +10 -0
- phenoml/tools/mcp_server/__init__.py +7 -0
- phenoml/tools/mcp_server/client.py +336 -0
- phenoml/tools/mcp_server/raw_client.py +641 -0
- phenoml/tools/mcp_server/tools/__init__.py +4 -0
- phenoml/tools/mcp_server/tools/client.py +358 -0
- phenoml/tools/mcp_server/tools/raw_client.py +656 -0
- phenoml/tools/raw_client.py +696 -0
- phenoml/tools/types/__init__.py +27 -0
- phenoml/tools/types/cohort_response.py +49 -0
- phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
- phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
- phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
- phenoml/tools/types/mcp_server_response.py +33 -0
- phenoml/tools/types/mcp_server_response_data.py +51 -0
- phenoml/tools/types/mcp_server_tool_call_response.py +37 -0
- phenoml/tools/types/mcp_server_tool_response.py +33 -0
- phenoml/tools/types/mcp_server_tool_response_data.py +61 -0
- phenoml/tools/types/search_concept.py +41 -0
- phenoml/types/__init__.py +21 -0
- phenoml/types/cohort_response.py +5 -0
- phenoml/types/lang2fhir_and_create_response.py +5 -0
- phenoml/types/lang2fhir_and_search_response.py +5 -0
- phenoml/types/mcp_server_response.py +5 -0
- phenoml/types/mcp_server_tool_call_response.py +5 -0
- phenoml/types/mcp_server_tool_response.py +5 -0
- phenoml/types/search_concept.py +5 -0
- phenoml/version.py +3 -0
- phenoml/workflows/__init__.py +66 -0
- phenoml/workflows/client.py +210 -0
- phenoml/workflows/errors/__init__.py +11 -0
- phenoml/workflows/errors/bad_request_error.py +10 -0
- phenoml/workflows/errors/forbidden_error.py +10 -0
- phenoml/workflows/errors/internal_server_error.py +10 -0
- phenoml/workflows/errors/not_found_error.py +10 -0
- phenoml/workflows/errors/unauthorized_error.py +10 -0
- phenoml/workflows/mcp_server/__init__.py +7 -0
- phenoml/workflows/mcp_server/client.py +274 -0
- phenoml/workflows/mcp_server/raw_client.py +226 -0
- phenoml/workflows/mcp_server/tools/__init__.py +4 -0
- phenoml/workflows/mcp_server/tools/client.py +287 -0
- phenoml/workflows/mcp_server/tools/raw_client.py +244 -0
- phenoml/workflows/raw_client.py +169 -0
- phenoml/workflows/types/__init__.py +43 -0
- phenoml/workflows/types/create_workflow_response.py +44 -0
- phenoml/workflows/types/decision_node_definition.py +32 -0
- phenoml/workflows/types/execute_workflow_response.py +30 -0
- phenoml/workflows/types/execute_workflow_response_results.py +22 -0
- phenoml/workflows/types/lang2fhir_create_definition.py +37 -0
- phenoml/workflows/types/lang2fhir_search_definition.py +42 -0
- phenoml/workflows/types/list_workflows_response.py +39 -0
- phenoml/workflows/types/step_operation.py +26 -0
- phenoml/workflows/types/sub_workflow_definition.py +32 -0
- phenoml/workflows/types/workflow_config.py +27 -0
- phenoml/workflows/types/workflow_definition.py +57 -0
- phenoml/workflows/types/workflow_graph.py +23 -0
- phenoml/workflows/types/workflow_response.py +61 -0
- phenoml/workflows/types/workflow_response_graph.py +23 -0
- phenoml/workflows/types/workflow_step.py +55 -0
- phenoml/workflows/types/workflow_step_summary.py +47 -0
- phenoml/workflows/types/workflow_step_summary_type.py +5 -0
- phenoml/workflows/types/workflow_step_type.py +5 -0
- phenoml/workflows/workflows/__init__.py +19 -0
- phenoml/workflows/workflows/client.py +694 -0
- phenoml/workflows/workflows/raw_client.py +1266 -0
- phenoml/workflows/workflows/types/__init__.py +17 -0
- phenoml/workflows/workflows/types/create_workflow_request_fhir_provider_id.py +5 -0
- phenoml/workflows/workflows/types/update_workflow_request_fhir_provider_id.py +5 -0
- phenoml/workflows/workflows/types/workflows_delete_response.py +20 -0
- phenoml/workflows/workflows/types/workflows_get_response.py +26 -0
- phenoml/workflows/workflows/types/workflows_update_response.py +31 -0
- phenoml/wrapper_client.py +123 -0
- phenoml-0.0.6.dist-info/LICENSE +21 -0
- phenoml-0.0.6.dist-info/METADATA +192 -0
- phenoml-0.0.6.dist-info/RECORD +244 -0
- phenoml-0.0.6.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,1668 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
13
|
+
from .errors.bad_request_error import BadRequestError
|
|
14
|
+
from .errors.forbidden_error import ForbiddenError
|
|
15
|
+
from .errors.internal_server_error import InternalServerError
|
|
16
|
+
from .errors.not_found_error import NotFoundError
|
|
17
|
+
from .errors.unauthorized_error import UnauthorizedError
|
|
18
|
+
from .types.agent_chat_response import AgentChatResponse
|
|
19
|
+
from .types.agent_create_request_provider import AgentCreateRequestProvider
|
|
20
|
+
from .types.agent_delete_response import AgentDeleteResponse
|
|
21
|
+
from .types.agent_get_chat_messages_request_order import AgentGetChatMessagesRequestOrder
|
|
22
|
+
from .types.agent_get_chat_messages_response import AgentGetChatMessagesResponse
|
|
23
|
+
from .types.agent_list_response import AgentListResponse
|
|
24
|
+
from .types.agent_response import AgentResponse
|
|
25
|
+
from .types.json_patch import JsonPatch
|
|
26
|
+
|
|
27
|
+
# this is used as the default value for optional parameters
|
|
28
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RawAgentClient:
|
|
32
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
33
|
+
self._client_wrapper = client_wrapper
|
|
34
|
+
|
|
35
|
+
def create(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
name: str,
|
|
39
|
+
prompts: typing.Sequence[str],
|
|
40
|
+
is_active: bool,
|
|
41
|
+
description: typing.Optional[str] = OMIT,
|
|
42
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
43
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
44
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
45
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
46
|
+
) -> HttpResponse[AgentResponse]:
|
|
47
|
+
"""
|
|
48
|
+
Creates a new PhenoAgent with specified configuration
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
name : str
|
|
53
|
+
Agent name
|
|
54
|
+
|
|
55
|
+
prompts : typing.Sequence[str]
|
|
56
|
+
Array of prompt IDs to use for this agent
|
|
57
|
+
|
|
58
|
+
is_active : bool
|
|
59
|
+
Whether the agent is active
|
|
60
|
+
|
|
61
|
+
description : typing.Optional[str]
|
|
62
|
+
Agent description
|
|
63
|
+
|
|
64
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
65
|
+
Array of MCP server tool IDs to use for this agent
|
|
66
|
+
|
|
67
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
68
|
+
Tags for categorizing the agent
|
|
69
|
+
|
|
70
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
71
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
72
|
+
|
|
73
|
+
request_options : typing.Optional[RequestOptions]
|
|
74
|
+
Request-specific configuration.
|
|
75
|
+
|
|
76
|
+
Returns
|
|
77
|
+
-------
|
|
78
|
+
HttpResponse[AgentResponse]
|
|
79
|
+
Agent created successfully
|
|
80
|
+
"""
|
|
81
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
82
|
+
"agent/create",
|
|
83
|
+
method="POST",
|
|
84
|
+
json={
|
|
85
|
+
"name": name,
|
|
86
|
+
"description": description,
|
|
87
|
+
"prompts": prompts,
|
|
88
|
+
"tools": tools,
|
|
89
|
+
"is_active": is_active,
|
|
90
|
+
"tags": tags,
|
|
91
|
+
"provider": convert_and_respect_annotation_metadata(
|
|
92
|
+
object_=provider, annotation=AgentCreateRequestProvider, direction="write"
|
|
93
|
+
),
|
|
94
|
+
},
|
|
95
|
+
headers={
|
|
96
|
+
"content-type": "application/json",
|
|
97
|
+
},
|
|
98
|
+
request_options=request_options,
|
|
99
|
+
omit=OMIT,
|
|
100
|
+
)
|
|
101
|
+
try:
|
|
102
|
+
if 200 <= _response.status_code < 300:
|
|
103
|
+
_data = typing.cast(
|
|
104
|
+
AgentResponse,
|
|
105
|
+
parse_obj_as(
|
|
106
|
+
type_=AgentResponse, # type: ignore
|
|
107
|
+
object_=_response.json(),
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
return HttpResponse(response=_response, data=_data)
|
|
111
|
+
if _response.status_code == 400:
|
|
112
|
+
raise BadRequestError(
|
|
113
|
+
headers=dict(_response.headers),
|
|
114
|
+
body=typing.cast(
|
|
115
|
+
typing.Optional[typing.Any],
|
|
116
|
+
parse_obj_as(
|
|
117
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
118
|
+
object_=_response.json(),
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
)
|
|
122
|
+
if _response.status_code == 401:
|
|
123
|
+
raise UnauthorizedError(
|
|
124
|
+
headers=dict(_response.headers),
|
|
125
|
+
body=typing.cast(
|
|
126
|
+
typing.Optional[typing.Any],
|
|
127
|
+
parse_obj_as(
|
|
128
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
129
|
+
object_=_response.json(),
|
|
130
|
+
),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
if _response.status_code == 403:
|
|
134
|
+
raise ForbiddenError(
|
|
135
|
+
headers=dict(_response.headers),
|
|
136
|
+
body=typing.cast(
|
|
137
|
+
typing.Optional[typing.Any],
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
if _response.status_code == 500:
|
|
145
|
+
raise InternalServerError(
|
|
146
|
+
headers=dict(_response.headers),
|
|
147
|
+
body=typing.cast(
|
|
148
|
+
typing.Optional[typing.Any],
|
|
149
|
+
parse_obj_as(
|
|
150
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
151
|
+
object_=_response.json(),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
_response_json = _response.json()
|
|
156
|
+
except JSONDecodeError:
|
|
157
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
158
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
159
|
+
|
|
160
|
+
def list(
|
|
161
|
+
self,
|
|
162
|
+
*,
|
|
163
|
+
is_active: typing.Optional[bool] = None,
|
|
164
|
+
tags: typing.Optional[str] = None,
|
|
165
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
166
|
+
) -> HttpResponse[AgentListResponse]:
|
|
167
|
+
"""
|
|
168
|
+
Retrieves a list of PhenoAgents belonging to the authenticated user
|
|
169
|
+
|
|
170
|
+
Parameters
|
|
171
|
+
----------
|
|
172
|
+
is_active : typing.Optional[bool]
|
|
173
|
+
Filter by active status
|
|
174
|
+
|
|
175
|
+
tags : typing.Optional[str]
|
|
176
|
+
Filter by tags
|
|
177
|
+
|
|
178
|
+
request_options : typing.Optional[RequestOptions]
|
|
179
|
+
Request-specific configuration.
|
|
180
|
+
|
|
181
|
+
Returns
|
|
182
|
+
-------
|
|
183
|
+
HttpResponse[AgentListResponse]
|
|
184
|
+
Agents retrieved successfully
|
|
185
|
+
"""
|
|
186
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
187
|
+
"agent/list",
|
|
188
|
+
method="GET",
|
|
189
|
+
params={
|
|
190
|
+
"is_active": is_active,
|
|
191
|
+
"tags": tags,
|
|
192
|
+
},
|
|
193
|
+
request_options=request_options,
|
|
194
|
+
)
|
|
195
|
+
try:
|
|
196
|
+
if 200 <= _response.status_code < 300:
|
|
197
|
+
_data = typing.cast(
|
|
198
|
+
AgentListResponse,
|
|
199
|
+
parse_obj_as(
|
|
200
|
+
type_=AgentListResponse, # type: ignore
|
|
201
|
+
object_=_response.json(),
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
return HttpResponse(response=_response, data=_data)
|
|
205
|
+
if _response.status_code == 401:
|
|
206
|
+
raise UnauthorizedError(
|
|
207
|
+
headers=dict(_response.headers),
|
|
208
|
+
body=typing.cast(
|
|
209
|
+
typing.Optional[typing.Any],
|
|
210
|
+
parse_obj_as(
|
|
211
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
212
|
+
object_=_response.json(),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
if _response.status_code == 403:
|
|
217
|
+
raise ForbiddenError(
|
|
218
|
+
headers=dict(_response.headers),
|
|
219
|
+
body=typing.cast(
|
|
220
|
+
typing.Optional[typing.Any],
|
|
221
|
+
parse_obj_as(
|
|
222
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
223
|
+
object_=_response.json(),
|
|
224
|
+
),
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
if _response.status_code == 500:
|
|
228
|
+
raise InternalServerError(
|
|
229
|
+
headers=dict(_response.headers),
|
|
230
|
+
body=typing.cast(
|
|
231
|
+
typing.Optional[typing.Any],
|
|
232
|
+
parse_obj_as(
|
|
233
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
234
|
+
object_=_response.json(),
|
|
235
|
+
),
|
|
236
|
+
),
|
|
237
|
+
)
|
|
238
|
+
_response_json = _response.json()
|
|
239
|
+
except JSONDecodeError:
|
|
240
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
241
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
242
|
+
|
|
243
|
+
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[AgentResponse]:
|
|
244
|
+
"""
|
|
245
|
+
Retrieves a specific agent by its ID
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
id : str
|
|
250
|
+
Agent ID
|
|
251
|
+
|
|
252
|
+
request_options : typing.Optional[RequestOptions]
|
|
253
|
+
Request-specific configuration.
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
HttpResponse[AgentResponse]
|
|
258
|
+
Agent retrieved successfully
|
|
259
|
+
"""
|
|
260
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
261
|
+
f"agent/{jsonable_encoder(id)}",
|
|
262
|
+
method="GET",
|
|
263
|
+
request_options=request_options,
|
|
264
|
+
)
|
|
265
|
+
try:
|
|
266
|
+
if 200 <= _response.status_code < 300:
|
|
267
|
+
_data = typing.cast(
|
|
268
|
+
AgentResponse,
|
|
269
|
+
parse_obj_as(
|
|
270
|
+
type_=AgentResponse, # type: ignore
|
|
271
|
+
object_=_response.json(),
|
|
272
|
+
),
|
|
273
|
+
)
|
|
274
|
+
return HttpResponse(response=_response, data=_data)
|
|
275
|
+
if _response.status_code == 401:
|
|
276
|
+
raise UnauthorizedError(
|
|
277
|
+
headers=dict(_response.headers),
|
|
278
|
+
body=typing.cast(
|
|
279
|
+
typing.Optional[typing.Any],
|
|
280
|
+
parse_obj_as(
|
|
281
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
282
|
+
object_=_response.json(),
|
|
283
|
+
),
|
|
284
|
+
),
|
|
285
|
+
)
|
|
286
|
+
if _response.status_code == 403:
|
|
287
|
+
raise ForbiddenError(
|
|
288
|
+
headers=dict(_response.headers),
|
|
289
|
+
body=typing.cast(
|
|
290
|
+
typing.Optional[typing.Any],
|
|
291
|
+
parse_obj_as(
|
|
292
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
293
|
+
object_=_response.json(),
|
|
294
|
+
),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
if _response.status_code == 404:
|
|
298
|
+
raise NotFoundError(
|
|
299
|
+
headers=dict(_response.headers),
|
|
300
|
+
body=typing.cast(
|
|
301
|
+
typing.Optional[typing.Any],
|
|
302
|
+
parse_obj_as(
|
|
303
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
304
|
+
object_=_response.json(),
|
|
305
|
+
),
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
if _response.status_code == 500:
|
|
309
|
+
raise InternalServerError(
|
|
310
|
+
headers=dict(_response.headers),
|
|
311
|
+
body=typing.cast(
|
|
312
|
+
typing.Optional[typing.Any],
|
|
313
|
+
parse_obj_as(
|
|
314
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
315
|
+
object_=_response.json(),
|
|
316
|
+
),
|
|
317
|
+
),
|
|
318
|
+
)
|
|
319
|
+
_response_json = _response.json()
|
|
320
|
+
except JSONDecodeError:
|
|
321
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
322
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
323
|
+
|
|
324
|
+
def update(
|
|
325
|
+
self,
|
|
326
|
+
id: str,
|
|
327
|
+
*,
|
|
328
|
+
name: str,
|
|
329
|
+
prompts: typing.Sequence[str],
|
|
330
|
+
is_active: bool,
|
|
331
|
+
description: typing.Optional[str] = OMIT,
|
|
332
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
333
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
334
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
335
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
336
|
+
) -> HttpResponse[AgentResponse]:
|
|
337
|
+
"""
|
|
338
|
+
Updates an existing agent's configuration
|
|
339
|
+
|
|
340
|
+
Parameters
|
|
341
|
+
----------
|
|
342
|
+
id : str
|
|
343
|
+
Agent ID
|
|
344
|
+
|
|
345
|
+
name : str
|
|
346
|
+
Agent name
|
|
347
|
+
|
|
348
|
+
prompts : typing.Sequence[str]
|
|
349
|
+
Array of prompt IDs to use for this agent
|
|
350
|
+
|
|
351
|
+
is_active : bool
|
|
352
|
+
Whether the agent is active
|
|
353
|
+
|
|
354
|
+
description : typing.Optional[str]
|
|
355
|
+
Agent description
|
|
356
|
+
|
|
357
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
358
|
+
Array of MCP server tool IDs to use for this agent
|
|
359
|
+
|
|
360
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
361
|
+
Tags for categorizing the agent
|
|
362
|
+
|
|
363
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
364
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
365
|
+
|
|
366
|
+
request_options : typing.Optional[RequestOptions]
|
|
367
|
+
Request-specific configuration.
|
|
368
|
+
|
|
369
|
+
Returns
|
|
370
|
+
-------
|
|
371
|
+
HttpResponse[AgentResponse]
|
|
372
|
+
Agent updated successfully
|
|
373
|
+
"""
|
|
374
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
375
|
+
f"agent/{jsonable_encoder(id)}",
|
|
376
|
+
method="PUT",
|
|
377
|
+
json={
|
|
378
|
+
"name": name,
|
|
379
|
+
"description": description,
|
|
380
|
+
"prompts": prompts,
|
|
381
|
+
"tools": tools,
|
|
382
|
+
"is_active": is_active,
|
|
383
|
+
"tags": tags,
|
|
384
|
+
"provider": convert_and_respect_annotation_metadata(
|
|
385
|
+
object_=provider, annotation=AgentCreateRequestProvider, direction="write"
|
|
386
|
+
),
|
|
387
|
+
},
|
|
388
|
+
headers={
|
|
389
|
+
"content-type": "application/json",
|
|
390
|
+
},
|
|
391
|
+
request_options=request_options,
|
|
392
|
+
omit=OMIT,
|
|
393
|
+
)
|
|
394
|
+
try:
|
|
395
|
+
if 200 <= _response.status_code < 300:
|
|
396
|
+
_data = typing.cast(
|
|
397
|
+
AgentResponse,
|
|
398
|
+
parse_obj_as(
|
|
399
|
+
type_=AgentResponse, # type: ignore
|
|
400
|
+
object_=_response.json(),
|
|
401
|
+
),
|
|
402
|
+
)
|
|
403
|
+
return HttpResponse(response=_response, data=_data)
|
|
404
|
+
if _response.status_code == 400:
|
|
405
|
+
raise BadRequestError(
|
|
406
|
+
headers=dict(_response.headers),
|
|
407
|
+
body=typing.cast(
|
|
408
|
+
typing.Optional[typing.Any],
|
|
409
|
+
parse_obj_as(
|
|
410
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
411
|
+
object_=_response.json(),
|
|
412
|
+
),
|
|
413
|
+
),
|
|
414
|
+
)
|
|
415
|
+
if _response.status_code == 401:
|
|
416
|
+
raise UnauthorizedError(
|
|
417
|
+
headers=dict(_response.headers),
|
|
418
|
+
body=typing.cast(
|
|
419
|
+
typing.Optional[typing.Any],
|
|
420
|
+
parse_obj_as(
|
|
421
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
422
|
+
object_=_response.json(),
|
|
423
|
+
),
|
|
424
|
+
),
|
|
425
|
+
)
|
|
426
|
+
if _response.status_code == 403:
|
|
427
|
+
raise ForbiddenError(
|
|
428
|
+
headers=dict(_response.headers),
|
|
429
|
+
body=typing.cast(
|
|
430
|
+
typing.Optional[typing.Any],
|
|
431
|
+
parse_obj_as(
|
|
432
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
433
|
+
object_=_response.json(),
|
|
434
|
+
),
|
|
435
|
+
),
|
|
436
|
+
)
|
|
437
|
+
if _response.status_code == 404:
|
|
438
|
+
raise NotFoundError(
|
|
439
|
+
headers=dict(_response.headers),
|
|
440
|
+
body=typing.cast(
|
|
441
|
+
typing.Optional[typing.Any],
|
|
442
|
+
parse_obj_as(
|
|
443
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
444
|
+
object_=_response.json(),
|
|
445
|
+
),
|
|
446
|
+
),
|
|
447
|
+
)
|
|
448
|
+
if _response.status_code == 500:
|
|
449
|
+
raise InternalServerError(
|
|
450
|
+
headers=dict(_response.headers),
|
|
451
|
+
body=typing.cast(
|
|
452
|
+
typing.Optional[typing.Any],
|
|
453
|
+
parse_obj_as(
|
|
454
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
455
|
+
object_=_response.json(),
|
|
456
|
+
),
|
|
457
|
+
),
|
|
458
|
+
)
|
|
459
|
+
_response_json = _response.json()
|
|
460
|
+
except JSONDecodeError:
|
|
461
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
462
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
463
|
+
|
|
464
|
+
def delete(
|
|
465
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
466
|
+
) -> HttpResponse[AgentDeleteResponse]:
|
|
467
|
+
"""
|
|
468
|
+
Deletes an existing agent
|
|
469
|
+
|
|
470
|
+
Parameters
|
|
471
|
+
----------
|
|
472
|
+
id : str
|
|
473
|
+
Agent ID
|
|
474
|
+
|
|
475
|
+
request_options : typing.Optional[RequestOptions]
|
|
476
|
+
Request-specific configuration.
|
|
477
|
+
|
|
478
|
+
Returns
|
|
479
|
+
-------
|
|
480
|
+
HttpResponse[AgentDeleteResponse]
|
|
481
|
+
Agent deleted successfully
|
|
482
|
+
"""
|
|
483
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
484
|
+
f"agent/{jsonable_encoder(id)}",
|
|
485
|
+
method="DELETE",
|
|
486
|
+
request_options=request_options,
|
|
487
|
+
)
|
|
488
|
+
try:
|
|
489
|
+
if 200 <= _response.status_code < 300:
|
|
490
|
+
_data = typing.cast(
|
|
491
|
+
AgentDeleteResponse,
|
|
492
|
+
parse_obj_as(
|
|
493
|
+
type_=AgentDeleteResponse, # type: ignore
|
|
494
|
+
object_=_response.json(),
|
|
495
|
+
),
|
|
496
|
+
)
|
|
497
|
+
return HttpResponse(response=_response, data=_data)
|
|
498
|
+
if _response.status_code == 401:
|
|
499
|
+
raise UnauthorizedError(
|
|
500
|
+
headers=dict(_response.headers),
|
|
501
|
+
body=typing.cast(
|
|
502
|
+
typing.Optional[typing.Any],
|
|
503
|
+
parse_obj_as(
|
|
504
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
505
|
+
object_=_response.json(),
|
|
506
|
+
),
|
|
507
|
+
),
|
|
508
|
+
)
|
|
509
|
+
if _response.status_code == 403:
|
|
510
|
+
raise ForbiddenError(
|
|
511
|
+
headers=dict(_response.headers),
|
|
512
|
+
body=typing.cast(
|
|
513
|
+
typing.Optional[typing.Any],
|
|
514
|
+
parse_obj_as(
|
|
515
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
516
|
+
object_=_response.json(),
|
|
517
|
+
),
|
|
518
|
+
),
|
|
519
|
+
)
|
|
520
|
+
if _response.status_code == 404:
|
|
521
|
+
raise NotFoundError(
|
|
522
|
+
headers=dict(_response.headers),
|
|
523
|
+
body=typing.cast(
|
|
524
|
+
typing.Optional[typing.Any],
|
|
525
|
+
parse_obj_as(
|
|
526
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
527
|
+
object_=_response.json(),
|
|
528
|
+
),
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
if _response.status_code == 500:
|
|
532
|
+
raise InternalServerError(
|
|
533
|
+
headers=dict(_response.headers),
|
|
534
|
+
body=typing.cast(
|
|
535
|
+
typing.Optional[typing.Any],
|
|
536
|
+
parse_obj_as(
|
|
537
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
538
|
+
object_=_response.json(),
|
|
539
|
+
),
|
|
540
|
+
),
|
|
541
|
+
)
|
|
542
|
+
_response_json = _response.json()
|
|
543
|
+
except JSONDecodeError:
|
|
544
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
545
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
546
|
+
|
|
547
|
+
def patch(
|
|
548
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
549
|
+
) -> HttpResponse[AgentResponse]:
|
|
550
|
+
"""
|
|
551
|
+
Patches an existing agent's configuration
|
|
552
|
+
|
|
553
|
+
Parameters
|
|
554
|
+
----------
|
|
555
|
+
id : str
|
|
556
|
+
Agent ID
|
|
557
|
+
|
|
558
|
+
request : JsonPatch
|
|
559
|
+
|
|
560
|
+
request_options : typing.Optional[RequestOptions]
|
|
561
|
+
Request-specific configuration.
|
|
562
|
+
|
|
563
|
+
Returns
|
|
564
|
+
-------
|
|
565
|
+
HttpResponse[AgentResponse]
|
|
566
|
+
Agent patched successfully
|
|
567
|
+
"""
|
|
568
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
569
|
+
f"agent/{jsonable_encoder(id)}",
|
|
570
|
+
method="PATCH",
|
|
571
|
+
json=convert_and_respect_annotation_metadata(object_=request, annotation=JsonPatch, direction="write"),
|
|
572
|
+
headers={
|
|
573
|
+
"content-type": "application/json+patch",
|
|
574
|
+
},
|
|
575
|
+
request_options=request_options,
|
|
576
|
+
omit=OMIT,
|
|
577
|
+
)
|
|
578
|
+
try:
|
|
579
|
+
if 200 <= _response.status_code < 300:
|
|
580
|
+
_data = typing.cast(
|
|
581
|
+
AgentResponse,
|
|
582
|
+
parse_obj_as(
|
|
583
|
+
type_=AgentResponse, # type: ignore
|
|
584
|
+
object_=_response.json(),
|
|
585
|
+
),
|
|
586
|
+
)
|
|
587
|
+
return HttpResponse(response=_response, data=_data)
|
|
588
|
+
if _response.status_code == 400:
|
|
589
|
+
raise BadRequestError(
|
|
590
|
+
headers=dict(_response.headers),
|
|
591
|
+
body=typing.cast(
|
|
592
|
+
typing.Optional[typing.Any],
|
|
593
|
+
parse_obj_as(
|
|
594
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
),
|
|
598
|
+
)
|
|
599
|
+
if _response.status_code == 401:
|
|
600
|
+
raise UnauthorizedError(
|
|
601
|
+
headers=dict(_response.headers),
|
|
602
|
+
body=typing.cast(
|
|
603
|
+
typing.Optional[typing.Any],
|
|
604
|
+
parse_obj_as(
|
|
605
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
606
|
+
object_=_response.json(),
|
|
607
|
+
),
|
|
608
|
+
),
|
|
609
|
+
)
|
|
610
|
+
if _response.status_code == 403:
|
|
611
|
+
raise ForbiddenError(
|
|
612
|
+
headers=dict(_response.headers),
|
|
613
|
+
body=typing.cast(
|
|
614
|
+
typing.Optional[typing.Any],
|
|
615
|
+
parse_obj_as(
|
|
616
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
617
|
+
object_=_response.json(),
|
|
618
|
+
),
|
|
619
|
+
),
|
|
620
|
+
)
|
|
621
|
+
if _response.status_code == 404:
|
|
622
|
+
raise NotFoundError(
|
|
623
|
+
headers=dict(_response.headers),
|
|
624
|
+
body=typing.cast(
|
|
625
|
+
typing.Optional[typing.Any],
|
|
626
|
+
parse_obj_as(
|
|
627
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
628
|
+
object_=_response.json(),
|
|
629
|
+
),
|
|
630
|
+
),
|
|
631
|
+
)
|
|
632
|
+
if _response.status_code == 500:
|
|
633
|
+
raise InternalServerError(
|
|
634
|
+
headers=dict(_response.headers),
|
|
635
|
+
body=typing.cast(
|
|
636
|
+
typing.Optional[typing.Any],
|
|
637
|
+
parse_obj_as(
|
|
638
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
639
|
+
object_=_response.json(),
|
|
640
|
+
),
|
|
641
|
+
),
|
|
642
|
+
)
|
|
643
|
+
_response_json = _response.json()
|
|
644
|
+
except JSONDecodeError:
|
|
645
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
646
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
647
|
+
|
|
648
|
+
def chat(
|
|
649
|
+
self,
|
|
650
|
+
*,
|
|
651
|
+
message: str,
|
|
652
|
+
agent_id: str,
|
|
653
|
+
context: typing.Optional[str] = OMIT,
|
|
654
|
+
session_id: typing.Optional[str] = OMIT,
|
|
655
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
656
|
+
) -> HttpResponse[AgentChatResponse]:
|
|
657
|
+
"""
|
|
658
|
+
Send a message to an agent and receive a response
|
|
659
|
+
|
|
660
|
+
Parameters
|
|
661
|
+
----------
|
|
662
|
+
message : str
|
|
663
|
+
The message to send to the agent
|
|
664
|
+
|
|
665
|
+
agent_id : str
|
|
666
|
+
The ID of the agent to chat with
|
|
667
|
+
|
|
668
|
+
context : typing.Optional[str]
|
|
669
|
+
Optional context for the conversation
|
|
670
|
+
|
|
671
|
+
session_id : typing.Optional[str]
|
|
672
|
+
Optional session ID for conversation continuity
|
|
673
|
+
|
|
674
|
+
request_options : typing.Optional[RequestOptions]
|
|
675
|
+
Request-specific configuration.
|
|
676
|
+
|
|
677
|
+
Returns
|
|
678
|
+
-------
|
|
679
|
+
HttpResponse[AgentChatResponse]
|
|
680
|
+
Chat response received successfully
|
|
681
|
+
"""
|
|
682
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
683
|
+
"agent/chat",
|
|
684
|
+
method="POST",
|
|
685
|
+
json={
|
|
686
|
+
"message": message,
|
|
687
|
+
"context": context,
|
|
688
|
+
"session_id": session_id,
|
|
689
|
+
"agent_id": agent_id,
|
|
690
|
+
},
|
|
691
|
+
headers={
|
|
692
|
+
"content-type": "application/json",
|
|
693
|
+
},
|
|
694
|
+
request_options=request_options,
|
|
695
|
+
omit=OMIT,
|
|
696
|
+
)
|
|
697
|
+
try:
|
|
698
|
+
if 200 <= _response.status_code < 300:
|
|
699
|
+
_data = typing.cast(
|
|
700
|
+
AgentChatResponse,
|
|
701
|
+
parse_obj_as(
|
|
702
|
+
type_=AgentChatResponse, # type: ignore
|
|
703
|
+
object_=_response.json(),
|
|
704
|
+
),
|
|
705
|
+
)
|
|
706
|
+
return HttpResponse(response=_response, data=_data)
|
|
707
|
+
if _response.status_code == 400:
|
|
708
|
+
raise BadRequestError(
|
|
709
|
+
headers=dict(_response.headers),
|
|
710
|
+
body=typing.cast(
|
|
711
|
+
typing.Optional[typing.Any],
|
|
712
|
+
parse_obj_as(
|
|
713
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
714
|
+
object_=_response.json(),
|
|
715
|
+
),
|
|
716
|
+
),
|
|
717
|
+
)
|
|
718
|
+
if _response.status_code == 401:
|
|
719
|
+
raise UnauthorizedError(
|
|
720
|
+
headers=dict(_response.headers),
|
|
721
|
+
body=typing.cast(
|
|
722
|
+
typing.Optional[typing.Any],
|
|
723
|
+
parse_obj_as(
|
|
724
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
725
|
+
object_=_response.json(),
|
|
726
|
+
),
|
|
727
|
+
),
|
|
728
|
+
)
|
|
729
|
+
if _response.status_code == 403:
|
|
730
|
+
raise ForbiddenError(
|
|
731
|
+
headers=dict(_response.headers),
|
|
732
|
+
body=typing.cast(
|
|
733
|
+
typing.Optional[typing.Any],
|
|
734
|
+
parse_obj_as(
|
|
735
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
736
|
+
object_=_response.json(),
|
|
737
|
+
),
|
|
738
|
+
),
|
|
739
|
+
)
|
|
740
|
+
if _response.status_code == 500:
|
|
741
|
+
raise InternalServerError(
|
|
742
|
+
headers=dict(_response.headers),
|
|
743
|
+
body=typing.cast(
|
|
744
|
+
typing.Optional[typing.Any],
|
|
745
|
+
parse_obj_as(
|
|
746
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
747
|
+
object_=_response.json(),
|
|
748
|
+
),
|
|
749
|
+
),
|
|
750
|
+
)
|
|
751
|
+
_response_json = _response.json()
|
|
752
|
+
except JSONDecodeError:
|
|
753
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
754
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
755
|
+
|
|
756
|
+
def get_chat_messages(
|
|
757
|
+
self,
|
|
758
|
+
*,
|
|
759
|
+
chat_session_id: str,
|
|
760
|
+
num_messages: typing.Optional[int] = None,
|
|
761
|
+
role: typing.Optional[str] = None,
|
|
762
|
+
order: typing.Optional[AgentGetChatMessagesRequestOrder] = None,
|
|
763
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
764
|
+
) -> HttpResponse[AgentGetChatMessagesResponse]:
|
|
765
|
+
"""
|
|
766
|
+
Retrieves a list of chat messages for a given chat session
|
|
767
|
+
|
|
768
|
+
Parameters
|
|
769
|
+
----------
|
|
770
|
+
chat_session_id : str
|
|
771
|
+
Chat session ID
|
|
772
|
+
|
|
773
|
+
num_messages : typing.Optional[int]
|
|
774
|
+
Number of messages to return
|
|
775
|
+
|
|
776
|
+
role : typing.Optional[str]
|
|
777
|
+
Filter by role
|
|
778
|
+
|
|
779
|
+
order : typing.Optional[AgentGetChatMessagesRequestOrder]
|
|
780
|
+
Order of messages
|
|
781
|
+
|
|
782
|
+
request_options : typing.Optional[RequestOptions]
|
|
783
|
+
Request-specific configuration.
|
|
784
|
+
|
|
785
|
+
Returns
|
|
786
|
+
-------
|
|
787
|
+
HttpResponse[AgentGetChatMessagesResponse]
|
|
788
|
+
Chat messages retrieved successfully
|
|
789
|
+
"""
|
|
790
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
791
|
+
"agent/chat/messages",
|
|
792
|
+
method="GET",
|
|
793
|
+
params={
|
|
794
|
+
"chat_session_id": chat_session_id,
|
|
795
|
+
"num_messages": num_messages,
|
|
796
|
+
"role": role,
|
|
797
|
+
"order": order,
|
|
798
|
+
},
|
|
799
|
+
request_options=request_options,
|
|
800
|
+
)
|
|
801
|
+
try:
|
|
802
|
+
if 200 <= _response.status_code < 300:
|
|
803
|
+
_data = typing.cast(
|
|
804
|
+
AgentGetChatMessagesResponse,
|
|
805
|
+
parse_obj_as(
|
|
806
|
+
type_=AgentGetChatMessagesResponse, # type: ignore
|
|
807
|
+
object_=_response.json(),
|
|
808
|
+
),
|
|
809
|
+
)
|
|
810
|
+
return HttpResponse(response=_response, data=_data)
|
|
811
|
+
if _response.status_code == 401:
|
|
812
|
+
raise UnauthorizedError(
|
|
813
|
+
headers=dict(_response.headers),
|
|
814
|
+
body=typing.cast(
|
|
815
|
+
typing.Optional[typing.Any],
|
|
816
|
+
parse_obj_as(
|
|
817
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
818
|
+
object_=_response.json(),
|
|
819
|
+
),
|
|
820
|
+
),
|
|
821
|
+
)
|
|
822
|
+
if _response.status_code == 403:
|
|
823
|
+
raise ForbiddenError(
|
|
824
|
+
headers=dict(_response.headers),
|
|
825
|
+
body=typing.cast(
|
|
826
|
+
typing.Optional[typing.Any],
|
|
827
|
+
parse_obj_as(
|
|
828
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
829
|
+
object_=_response.json(),
|
|
830
|
+
),
|
|
831
|
+
),
|
|
832
|
+
)
|
|
833
|
+
if _response.status_code == 500:
|
|
834
|
+
raise InternalServerError(
|
|
835
|
+
headers=dict(_response.headers),
|
|
836
|
+
body=typing.cast(
|
|
837
|
+
typing.Optional[typing.Any],
|
|
838
|
+
parse_obj_as(
|
|
839
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
840
|
+
object_=_response.json(),
|
|
841
|
+
),
|
|
842
|
+
),
|
|
843
|
+
)
|
|
844
|
+
_response_json = _response.json()
|
|
845
|
+
except JSONDecodeError:
|
|
846
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
847
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
class AsyncRawAgentClient:
|
|
851
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
852
|
+
self._client_wrapper = client_wrapper
|
|
853
|
+
|
|
854
|
+
async def create(
|
|
855
|
+
self,
|
|
856
|
+
*,
|
|
857
|
+
name: str,
|
|
858
|
+
prompts: typing.Sequence[str],
|
|
859
|
+
is_active: bool,
|
|
860
|
+
description: typing.Optional[str] = OMIT,
|
|
861
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
862
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
863
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
864
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
865
|
+
) -> AsyncHttpResponse[AgentResponse]:
|
|
866
|
+
"""
|
|
867
|
+
Creates a new PhenoAgent with specified configuration
|
|
868
|
+
|
|
869
|
+
Parameters
|
|
870
|
+
----------
|
|
871
|
+
name : str
|
|
872
|
+
Agent name
|
|
873
|
+
|
|
874
|
+
prompts : typing.Sequence[str]
|
|
875
|
+
Array of prompt IDs to use for this agent
|
|
876
|
+
|
|
877
|
+
is_active : bool
|
|
878
|
+
Whether the agent is active
|
|
879
|
+
|
|
880
|
+
description : typing.Optional[str]
|
|
881
|
+
Agent description
|
|
882
|
+
|
|
883
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
884
|
+
Array of MCP server tool IDs to use for this agent
|
|
885
|
+
|
|
886
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
887
|
+
Tags for categorizing the agent
|
|
888
|
+
|
|
889
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
890
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
891
|
+
|
|
892
|
+
request_options : typing.Optional[RequestOptions]
|
|
893
|
+
Request-specific configuration.
|
|
894
|
+
|
|
895
|
+
Returns
|
|
896
|
+
-------
|
|
897
|
+
AsyncHttpResponse[AgentResponse]
|
|
898
|
+
Agent created successfully
|
|
899
|
+
"""
|
|
900
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
901
|
+
"agent/create",
|
|
902
|
+
method="POST",
|
|
903
|
+
json={
|
|
904
|
+
"name": name,
|
|
905
|
+
"description": description,
|
|
906
|
+
"prompts": prompts,
|
|
907
|
+
"tools": tools,
|
|
908
|
+
"is_active": is_active,
|
|
909
|
+
"tags": tags,
|
|
910
|
+
"provider": convert_and_respect_annotation_metadata(
|
|
911
|
+
object_=provider, annotation=AgentCreateRequestProvider, direction="write"
|
|
912
|
+
),
|
|
913
|
+
},
|
|
914
|
+
headers={
|
|
915
|
+
"content-type": "application/json",
|
|
916
|
+
},
|
|
917
|
+
request_options=request_options,
|
|
918
|
+
omit=OMIT,
|
|
919
|
+
)
|
|
920
|
+
try:
|
|
921
|
+
if 200 <= _response.status_code < 300:
|
|
922
|
+
_data = typing.cast(
|
|
923
|
+
AgentResponse,
|
|
924
|
+
parse_obj_as(
|
|
925
|
+
type_=AgentResponse, # type: ignore
|
|
926
|
+
object_=_response.json(),
|
|
927
|
+
),
|
|
928
|
+
)
|
|
929
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
930
|
+
if _response.status_code == 400:
|
|
931
|
+
raise BadRequestError(
|
|
932
|
+
headers=dict(_response.headers),
|
|
933
|
+
body=typing.cast(
|
|
934
|
+
typing.Optional[typing.Any],
|
|
935
|
+
parse_obj_as(
|
|
936
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
937
|
+
object_=_response.json(),
|
|
938
|
+
),
|
|
939
|
+
),
|
|
940
|
+
)
|
|
941
|
+
if _response.status_code == 401:
|
|
942
|
+
raise UnauthorizedError(
|
|
943
|
+
headers=dict(_response.headers),
|
|
944
|
+
body=typing.cast(
|
|
945
|
+
typing.Optional[typing.Any],
|
|
946
|
+
parse_obj_as(
|
|
947
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
948
|
+
object_=_response.json(),
|
|
949
|
+
),
|
|
950
|
+
),
|
|
951
|
+
)
|
|
952
|
+
if _response.status_code == 403:
|
|
953
|
+
raise ForbiddenError(
|
|
954
|
+
headers=dict(_response.headers),
|
|
955
|
+
body=typing.cast(
|
|
956
|
+
typing.Optional[typing.Any],
|
|
957
|
+
parse_obj_as(
|
|
958
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
959
|
+
object_=_response.json(),
|
|
960
|
+
),
|
|
961
|
+
),
|
|
962
|
+
)
|
|
963
|
+
if _response.status_code == 500:
|
|
964
|
+
raise InternalServerError(
|
|
965
|
+
headers=dict(_response.headers),
|
|
966
|
+
body=typing.cast(
|
|
967
|
+
typing.Optional[typing.Any],
|
|
968
|
+
parse_obj_as(
|
|
969
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
970
|
+
object_=_response.json(),
|
|
971
|
+
),
|
|
972
|
+
),
|
|
973
|
+
)
|
|
974
|
+
_response_json = _response.json()
|
|
975
|
+
except JSONDecodeError:
|
|
976
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
977
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
978
|
+
|
|
979
|
+
async def list(
|
|
980
|
+
self,
|
|
981
|
+
*,
|
|
982
|
+
is_active: typing.Optional[bool] = None,
|
|
983
|
+
tags: typing.Optional[str] = None,
|
|
984
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
985
|
+
) -> AsyncHttpResponse[AgentListResponse]:
|
|
986
|
+
"""
|
|
987
|
+
Retrieves a list of PhenoAgents belonging to the authenticated user
|
|
988
|
+
|
|
989
|
+
Parameters
|
|
990
|
+
----------
|
|
991
|
+
is_active : typing.Optional[bool]
|
|
992
|
+
Filter by active status
|
|
993
|
+
|
|
994
|
+
tags : typing.Optional[str]
|
|
995
|
+
Filter by tags
|
|
996
|
+
|
|
997
|
+
request_options : typing.Optional[RequestOptions]
|
|
998
|
+
Request-specific configuration.
|
|
999
|
+
|
|
1000
|
+
Returns
|
|
1001
|
+
-------
|
|
1002
|
+
AsyncHttpResponse[AgentListResponse]
|
|
1003
|
+
Agents retrieved successfully
|
|
1004
|
+
"""
|
|
1005
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1006
|
+
"agent/list",
|
|
1007
|
+
method="GET",
|
|
1008
|
+
params={
|
|
1009
|
+
"is_active": is_active,
|
|
1010
|
+
"tags": tags,
|
|
1011
|
+
},
|
|
1012
|
+
request_options=request_options,
|
|
1013
|
+
)
|
|
1014
|
+
try:
|
|
1015
|
+
if 200 <= _response.status_code < 300:
|
|
1016
|
+
_data = typing.cast(
|
|
1017
|
+
AgentListResponse,
|
|
1018
|
+
parse_obj_as(
|
|
1019
|
+
type_=AgentListResponse, # type: ignore
|
|
1020
|
+
object_=_response.json(),
|
|
1021
|
+
),
|
|
1022
|
+
)
|
|
1023
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1024
|
+
if _response.status_code == 401:
|
|
1025
|
+
raise UnauthorizedError(
|
|
1026
|
+
headers=dict(_response.headers),
|
|
1027
|
+
body=typing.cast(
|
|
1028
|
+
typing.Optional[typing.Any],
|
|
1029
|
+
parse_obj_as(
|
|
1030
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1031
|
+
object_=_response.json(),
|
|
1032
|
+
),
|
|
1033
|
+
),
|
|
1034
|
+
)
|
|
1035
|
+
if _response.status_code == 403:
|
|
1036
|
+
raise ForbiddenError(
|
|
1037
|
+
headers=dict(_response.headers),
|
|
1038
|
+
body=typing.cast(
|
|
1039
|
+
typing.Optional[typing.Any],
|
|
1040
|
+
parse_obj_as(
|
|
1041
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1042
|
+
object_=_response.json(),
|
|
1043
|
+
),
|
|
1044
|
+
),
|
|
1045
|
+
)
|
|
1046
|
+
if _response.status_code == 500:
|
|
1047
|
+
raise InternalServerError(
|
|
1048
|
+
headers=dict(_response.headers),
|
|
1049
|
+
body=typing.cast(
|
|
1050
|
+
typing.Optional[typing.Any],
|
|
1051
|
+
parse_obj_as(
|
|
1052
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1053
|
+
object_=_response.json(),
|
|
1054
|
+
),
|
|
1055
|
+
),
|
|
1056
|
+
)
|
|
1057
|
+
_response_json = _response.json()
|
|
1058
|
+
except JSONDecodeError:
|
|
1059
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1060
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1061
|
+
|
|
1062
|
+
async def get(
|
|
1063
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1064
|
+
) -> AsyncHttpResponse[AgentResponse]:
|
|
1065
|
+
"""
|
|
1066
|
+
Retrieves a specific agent by its ID
|
|
1067
|
+
|
|
1068
|
+
Parameters
|
|
1069
|
+
----------
|
|
1070
|
+
id : str
|
|
1071
|
+
Agent ID
|
|
1072
|
+
|
|
1073
|
+
request_options : typing.Optional[RequestOptions]
|
|
1074
|
+
Request-specific configuration.
|
|
1075
|
+
|
|
1076
|
+
Returns
|
|
1077
|
+
-------
|
|
1078
|
+
AsyncHttpResponse[AgentResponse]
|
|
1079
|
+
Agent retrieved successfully
|
|
1080
|
+
"""
|
|
1081
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1082
|
+
f"agent/{jsonable_encoder(id)}",
|
|
1083
|
+
method="GET",
|
|
1084
|
+
request_options=request_options,
|
|
1085
|
+
)
|
|
1086
|
+
try:
|
|
1087
|
+
if 200 <= _response.status_code < 300:
|
|
1088
|
+
_data = typing.cast(
|
|
1089
|
+
AgentResponse,
|
|
1090
|
+
parse_obj_as(
|
|
1091
|
+
type_=AgentResponse, # type: ignore
|
|
1092
|
+
object_=_response.json(),
|
|
1093
|
+
),
|
|
1094
|
+
)
|
|
1095
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1096
|
+
if _response.status_code == 401:
|
|
1097
|
+
raise UnauthorizedError(
|
|
1098
|
+
headers=dict(_response.headers),
|
|
1099
|
+
body=typing.cast(
|
|
1100
|
+
typing.Optional[typing.Any],
|
|
1101
|
+
parse_obj_as(
|
|
1102
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1103
|
+
object_=_response.json(),
|
|
1104
|
+
),
|
|
1105
|
+
),
|
|
1106
|
+
)
|
|
1107
|
+
if _response.status_code == 403:
|
|
1108
|
+
raise ForbiddenError(
|
|
1109
|
+
headers=dict(_response.headers),
|
|
1110
|
+
body=typing.cast(
|
|
1111
|
+
typing.Optional[typing.Any],
|
|
1112
|
+
parse_obj_as(
|
|
1113
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1114
|
+
object_=_response.json(),
|
|
1115
|
+
),
|
|
1116
|
+
),
|
|
1117
|
+
)
|
|
1118
|
+
if _response.status_code == 404:
|
|
1119
|
+
raise NotFoundError(
|
|
1120
|
+
headers=dict(_response.headers),
|
|
1121
|
+
body=typing.cast(
|
|
1122
|
+
typing.Optional[typing.Any],
|
|
1123
|
+
parse_obj_as(
|
|
1124
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1125
|
+
object_=_response.json(),
|
|
1126
|
+
),
|
|
1127
|
+
),
|
|
1128
|
+
)
|
|
1129
|
+
if _response.status_code == 500:
|
|
1130
|
+
raise InternalServerError(
|
|
1131
|
+
headers=dict(_response.headers),
|
|
1132
|
+
body=typing.cast(
|
|
1133
|
+
typing.Optional[typing.Any],
|
|
1134
|
+
parse_obj_as(
|
|
1135
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1136
|
+
object_=_response.json(),
|
|
1137
|
+
),
|
|
1138
|
+
),
|
|
1139
|
+
)
|
|
1140
|
+
_response_json = _response.json()
|
|
1141
|
+
except JSONDecodeError:
|
|
1142
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1143
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1144
|
+
|
|
1145
|
+
async def update(
|
|
1146
|
+
self,
|
|
1147
|
+
id: str,
|
|
1148
|
+
*,
|
|
1149
|
+
name: str,
|
|
1150
|
+
prompts: typing.Sequence[str],
|
|
1151
|
+
is_active: bool,
|
|
1152
|
+
description: typing.Optional[str] = OMIT,
|
|
1153
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1154
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
1155
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
1156
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1157
|
+
) -> AsyncHttpResponse[AgentResponse]:
|
|
1158
|
+
"""
|
|
1159
|
+
Updates an existing agent's configuration
|
|
1160
|
+
|
|
1161
|
+
Parameters
|
|
1162
|
+
----------
|
|
1163
|
+
id : str
|
|
1164
|
+
Agent ID
|
|
1165
|
+
|
|
1166
|
+
name : str
|
|
1167
|
+
Agent name
|
|
1168
|
+
|
|
1169
|
+
prompts : typing.Sequence[str]
|
|
1170
|
+
Array of prompt IDs to use for this agent
|
|
1171
|
+
|
|
1172
|
+
is_active : bool
|
|
1173
|
+
Whether the agent is active
|
|
1174
|
+
|
|
1175
|
+
description : typing.Optional[str]
|
|
1176
|
+
Agent description
|
|
1177
|
+
|
|
1178
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
1179
|
+
Array of MCP server tool IDs to use for this agent
|
|
1180
|
+
|
|
1181
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
1182
|
+
Tags for categorizing the agent
|
|
1183
|
+
|
|
1184
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
1185
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
1186
|
+
|
|
1187
|
+
request_options : typing.Optional[RequestOptions]
|
|
1188
|
+
Request-specific configuration.
|
|
1189
|
+
|
|
1190
|
+
Returns
|
|
1191
|
+
-------
|
|
1192
|
+
AsyncHttpResponse[AgentResponse]
|
|
1193
|
+
Agent updated successfully
|
|
1194
|
+
"""
|
|
1195
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1196
|
+
f"agent/{jsonable_encoder(id)}",
|
|
1197
|
+
method="PUT",
|
|
1198
|
+
json={
|
|
1199
|
+
"name": name,
|
|
1200
|
+
"description": description,
|
|
1201
|
+
"prompts": prompts,
|
|
1202
|
+
"tools": tools,
|
|
1203
|
+
"is_active": is_active,
|
|
1204
|
+
"tags": tags,
|
|
1205
|
+
"provider": convert_and_respect_annotation_metadata(
|
|
1206
|
+
object_=provider, annotation=AgentCreateRequestProvider, direction="write"
|
|
1207
|
+
),
|
|
1208
|
+
},
|
|
1209
|
+
headers={
|
|
1210
|
+
"content-type": "application/json",
|
|
1211
|
+
},
|
|
1212
|
+
request_options=request_options,
|
|
1213
|
+
omit=OMIT,
|
|
1214
|
+
)
|
|
1215
|
+
try:
|
|
1216
|
+
if 200 <= _response.status_code < 300:
|
|
1217
|
+
_data = typing.cast(
|
|
1218
|
+
AgentResponse,
|
|
1219
|
+
parse_obj_as(
|
|
1220
|
+
type_=AgentResponse, # type: ignore
|
|
1221
|
+
object_=_response.json(),
|
|
1222
|
+
),
|
|
1223
|
+
)
|
|
1224
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1225
|
+
if _response.status_code == 400:
|
|
1226
|
+
raise BadRequestError(
|
|
1227
|
+
headers=dict(_response.headers),
|
|
1228
|
+
body=typing.cast(
|
|
1229
|
+
typing.Optional[typing.Any],
|
|
1230
|
+
parse_obj_as(
|
|
1231
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1232
|
+
object_=_response.json(),
|
|
1233
|
+
),
|
|
1234
|
+
),
|
|
1235
|
+
)
|
|
1236
|
+
if _response.status_code == 401:
|
|
1237
|
+
raise UnauthorizedError(
|
|
1238
|
+
headers=dict(_response.headers),
|
|
1239
|
+
body=typing.cast(
|
|
1240
|
+
typing.Optional[typing.Any],
|
|
1241
|
+
parse_obj_as(
|
|
1242
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1243
|
+
object_=_response.json(),
|
|
1244
|
+
),
|
|
1245
|
+
),
|
|
1246
|
+
)
|
|
1247
|
+
if _response.status_code == 403:
|
|
1248
|
+
raise ForbiddenError(
|
|
1249
|
+
headers=dict(_response.headers),
|
|
1250
|
+
body=typing.cast(
|
|
1251
|
+
typing.Optional[typing.Any],
|
|
1252
|
+
parse_obj_as(
|
|
1253
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1254
|
+
object_=_response.json(),
|
|
1255
|
+
),
|
|
1256
|
+
),
|
|
1257
|
+
)
|
|
1258
|
+
if _response.status_code == 404:
|
|
1259
|
+
raise NotFoundError(
|
|
1260
|
+
headers=dict(_response.headers),
|
|
1261
|
+
body=typing.cast(
|
|
1262
|
+
typing.Optional[typing.Any],
|
|
1263
|
+
parse_obj_as(
|
|
1264
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1265
|
+
object_=_response.json(),
|
|
1266
|
+
),
|
|
1267
|
+
),
|
|
1268
|
+
)
|
|
1269
|
+
if _response.status_code == 500:
|
|
1270
|
+
raise InternalServerError(
|
|
1271
|
+
headers=dict(_response.headers),
|
|
1272
|
+
body=typing.cast(
|
|
1273
|
+
typing.Optional[typing.Any],
|
|
1274
|
+
parse_obj_as(
|
|
1275
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1276
|
+
object_=_response.json(),
|
|
1277
|
+
),
|
|
1278
|
+
),
|
|
1279
|
+
)
|
|
1280
|
+
_response_json = _response.json()
|
|
1281
|
+
except JSONDecodeError:
|
|
1282
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1283
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1284
|
+
|
|
1285
|
+
async def delete(
|
|
1286
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1287
|
+
) -> AsyncHttpResponse[AgentDeleteResponse]:
|
|
1288
|
+
"""
|
|
1289
|
+
Deletes an existing agent
|
|
1290
|
+
|
|
1291
|
+
Parameters
|
|
1292
|
+
----------
|
|
1293
|
+
id : str
|
|
1294
|
+
Agent ID
|
|
1295
|
+
|
|
1296
|
+
request_options : typing.Optional[RequestOptions]
|
|
1297
|
+
Request-specific configuration.
|
|
1298
|
+
|
|
1299
|
+
Returns
|
|
1300
|
+
-------
|
|
1301
|
+
AsyncHttpResponse[AgentDeleteResponse]
|
|
1302
|
+
Agent deleted successfully
|
|
1303
|
+
"""
|
|
1304
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1305
|
+
f"agent/{jsonable_encoder(id)}",
|
|
1306
|
+
method="DELETE",
|
|
1307
|
+
request_options=request_options,
|
|
1308
|
+
)
|
|
1309
|
+
try:
|
|
1310
|
+
if 200 <= _response.status_code < 300:
|
|
1311
|
+
_data = typing.cast(
|
|
1312
|
+
AgentDeleteResponse,
|
|
1313
|
+
parse_obj_as(
|
|
1314
|
+
type_=AgentDeleteResponse, # type: ignore
|
|
1315
|
+
object_=_response.json(),
|
|
1316
|
+
),
|
|
1317
|
+
)
|
|
1318
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1319
|
+
if _response.status_code == 401:
|
|
1320
|
+
raise UnauthorizedError(
|
|
1321
|
+
headers=dict(_response.headers),
|
|
1322
|
+
body=typing.cast(
|
|
1323
|
+
typing.Optional[typing.Any],
|
|
1324
|
+
parse_obj_as(
|
|
1325
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1326
|
+
object_=_response.json(),
|
|
1327
|
+
),
|
|
1328
|
+
),
|
|
1329
|
+
)
|
|
1330
|
+
if _response.status_code == 403:
|
|
1331
|
+
raise ForbiddenError(
|
|
1332
|
+
headers=dict(_response.headers),
|
|
1333
|
+
body=typing.cast(
|
|
1334
|
+
typing.Optional[typing.Any],
|
|
1335
|
+
parse_obj_as(
|
|
1336
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1337
|
+
object_=_response.json(),
|
|
1338
|
+
),
|
|
1339
|
+
),
|
|
1340
|
+
)
|
|
1341
|
+
if _response.status_code == 404:
|
|
1342
|
+
raise NotFoundError(
|
|
1343
|
+
headers=dict(_response.headers),
|
|
1344
|
+
body=typing.cast(
|
|
1345
|
+
typing.Optional[typing.Any],
|
|
1346
|
+
parse_obj_as(
|
|
1347
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1348
|
+
object_=_response.json(),
|
|
1349
|
+
),
|
|
1350
|
+
),
|
|
1351
|
+
)
|
|
1352
|
+
if _response.status_code == 500:
|
|
1353
|
+
raise InternalServerError(
|
|
1354
|
+
headers=dict(_response.headers),
|
|
1355
|
+
body=typing.cast(
|
|
1356
|
+
typing.Optional[typing.Any],
|
|
1357
|
+
parse_obj_as(
|
|
1358
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1359
|
+
object_=_response.json(),
|
|
1360
|
+
),
|
|
1361
|
+
),
|
|
1362
|
+
)
|
|
1363
|
+
_response_json = _response.json()
|
|
1364
|
+
except JSONDecodeError:
|
|
1365
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1366
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1367
|
+
|
|
1368
|
+
async def patch(
|
|
1369
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
1370
|
+
) -> AsyncHttpResponse[AgentResponse]:
|
|
1371
|
+
"""
|
|
1372
|
+
Patches an existing agent's configuration
|
|
1373
|
+
|
|
1374
|
+
Parameters
|
|
1375
|
+
----------
|
|
1376
|
+
id : str
|
|
1377
|
+
Agent ID
|
|
1378
|
+
|
|
1379
|
+
request : JsonPatch
|
|
1380
|
+
|
|
1381
|
+
request_options : typing.Optional[RequestOptions]
|
|
1382
|
+
Request-specific configuration.
|
|
1383
|
+
|
|
1384
|
+
Returns
|
|
1385
|
+
-------
|
|
1386
|
+
AsyncHttpResponse[AgentResponse]
|
|
1387
|
+
Agent patched successfully
|
|
1388
|
+
"""
|
|
1389
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1390
|
+
f"agent/{jsonable_encoder(id)}",
|
|
1391
|
+
method="PATCH",
|
|
1392
|
+
json=convert_and_respect_annotation_metadata(object_=request, annotation=JsonPatch, direction="write"),
|
|
1393
|
+
headers={
|
|
1394
|
+
"content-type": "application/json+patch",
|
|
1395
|
+
},
|
|
1396
|
+
request_options=request_options,
|
|
1397
|
+
omit=OMIT,
|
|
1398
|
+
)
|
|
1399
|
+
try:
|
|
1400
|
+
if 200 <= _response.status_code < 300:
|
|
1401
|
+
_data = typing.cast(
|
|
1402
|
+
AgentResponse,
|
|
1403
|
+
parse_obj_as(
|
|
1404
|
+
type_=AgentResponse, # type: ignore
|
|
1405
|
+
object_=_response.json(),
|
|
1406
|
+
),
|
|
1407
|
+
)
|
|
1408
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1409
|
+
if _response.status_code == 400:
|
|
1410
|
+
raise BadRequestError(
|
|
1411
|
+
headers=dict(_response.headers),
|
|
1412
|
+
body=typing.cast(
|
|
1413
|
+
typing.Optional[typing.Any],
|
|
1414
|
+
parse_obj_as(
|
|
1415
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1416
|
+
object_=_response.json(),
|
|
1417
|
+
),
|
|
1418
|
+
),
|
|
1419
|
+
)
|
|
1420
|
+
if _response.status_code == 401:
|
|
1421
|
+
raise UnauthorizedError(
|
|
1422
|
+
headers=dict(_response.headers),
|
|
1423
|
+
body=typing.cast(
|
|
1424
|
+
typing.Optional[typing.Any],
|
|
1425
|
+
parse_obj_as(
|
|
1426
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1427
|
+
object_=_response.json(),
|
|
1428
|
+
),
|
|
1429
|
+
),
|
|
1430
|
+
)
|
|
1431
|
+
if _response.status_code == 403:
|
|
1432
|
+
raise ForbiddenError(
|
|
1433
|
+
headers=dict(_response.headers),
|
|
1434
|
+
body=typing.cast(
|
|
1435
|
+
typing.Optional[typing.Any],
|
|
1436
|
+
parse_obj_as(
|
|
1437
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1438
|
+
object_=_response.json(),
|
|
1439
|
+
),
|
|
1440
|
+
),
|
|
1441
|
+
)
|
|
1442
|
+
if _response.status_code == 404:
|
|
1443
|
+
raise NotFoundError(
|
|
1444
|
+
headers=dict(_response.headers),
|
|
1445
|
+
body=typing.cast(
|
|
1446
|
+
typing.Optional[typing.Any],
|
|
1447
|
+
parse_obj_as(
|
|
1448
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1449
|
+
object_=_response.json(),
|
|
1450
|
+
),
|
|
1451
|
+
),
|
|
1452
|
+
)
|
|
1453
|
+
if _response.status_code == 500:
|
|
1454
|
+
raise InternalServerError(
|
|
1455
|
+
headers=dict(_response.headers),
|
|
1456
|
+
body=typing.cast(
|
|
1457
|
+
typing.Optional[typing.Any],
|
|
1458
|
+
parse_obj_as(
|
|
1459
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1460
|
+
object_=_response.json(),
|
|
1461
|
+
),
|
|
1462
|
+
),
|
|
1463
|
+
)
|
|
1464
|
+
_response_json = _response.json()
|
|
1465
|
+
except JSONDecodeError:
|
|
1466
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1467
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1468
|
+
|
|
1469
|
+
async def chat(
|
|
1470
|
+
self,
|
|
1471
|
+
*,
|
|
1472
|
+
message: str,
|
|
1473
|
+
agent_id: str,
|
|
1474
|
+
context: typing.Optional[str] = OMIT,
|
|
1475
|
+
session_id: typing.Optional[str] = OMIT,
|
|
1476
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1477
|
+
) -> AsyncHttpResponse[AgentChatResponse]:
|
|
1478
|
+
"""
|
|
1479
|
+
Send a message to an agent and receive a response
|
|
1480
|
+
|
|
1481
|
+
Parameters
|
|
1482
|
+
----------
|
|
1483
|
+
message : str
|
|
1484
|
+
The message to send to the agent
|
|
1485
|
+
|
|
1486
|
+
agent_id : str
|
|
1487
|
+
The ID of the agent to chat with
|
|
1488
|
+
|
|
1489
|
+
context : typing.Optional[str]
|
|
1490
|
+
Optional context for the conversation
|
|
1491
|
+
|
|
1492
|
+
session_id : typing.Optional[str]
|
|
1493
|
+
Optional session ID for conversation continuity
|
|
1494
|
+
|
|
1495
|
+
request_options : typing.Optional[RequestOptions]
|
|
1496
|
+
Request-specific configuration.
|
|
1497
|
+
|
|
1498
|
+
Returns
|
|
1499
|
+
-------
|
|
1500
|
+
AsyncHttpResponse[AgentChatResponse]
|
|
1501
|
+
Chat response received successfully
|
|
1502
|
+
"""
|
|
1503
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1504
|
+
"agent/chat",
|
|
1505
|
+
method="POST",
|
|
1506
|
+
json={
|
|
1507
|
+
"message": message,
|
|
1508
|
+
"context": context,
|
|
1509
|
+
"session_id": session_id,
|
|
1510
|
+
"agent_id": agent_id,
|
|
1511
|
+
},
|
|
1512
|
+
headers={
|
|
1513
|
+
"content-type": "application/json",
|
|
1514
|
+
},
|
|
1515
|
+
request_options=request_options,
|
|
1516
|
+
omit=OMIT,
|
|
1517
|
+
)
|
|
1518
|
+
try:
|
|
1519
|
+
if 200 <= _response.status_code < 300:
|
|
1520
|
+
_data = typing.cast(
|
|
1521
|
+
AgentChatResponse,
|
|
1522
|
+
parse_obj_as(
|
|
1523
|
+
type_=AgentChatResponse, # type: ignore
|
|
1524
|
+
object_=_response.json(),
|
|
1525
|
+
),
|
|
1526
|
+
)
|
|
1527
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1528
|
+
if _response.status_code == 400:
|
|
1529
|
+
raise BadRequestError(
|
|
1530
|
+
headers=dict(_response.headers),
|
|
1531
|
+
body=typing.cast(
|
|
1532
|
+
typing.Optional[typing.Any],
|
|
1533
|
+
parse_obj_as(
|
|
1534
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1535
|
+
object_=_response.json(),
|
|
1536
|
+
),
|
|
1537
|
+
),
|
|
1538
|
+
)
|
|
1539
|
+
if _response.status_code == 401:
|
|
1540
|
+
raise UnauthorizedError(
|
|
1541
|
+
headers=dict(_response.headers),
|
|
1542
|
+
body=typing.cast(
|
|
1543
|
+
typing.Optional[typing.Any],
|
|
1544
|
+
parse_obj_as(
|
|
1545
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1546
|
+
object_=_response.json(),
|
|
1547
|
+
),
|
|
1548
|
+
),
|
|
1549
|
+
)
|
|
1550
|
+
if _response.status_code == 403:
|
|
1551
|
+
raise ForbiddenError(
|
|
1552
|
+
headers=dict(_response.headers),
|
|
1553
|
+
body=typing.cast(
|
|
1554
|
+
typing.Optional[typing.Any],
|
|
1555
|
+
parse_obj_as(
|
|
1556
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1557
|
+
object_=_response.json(),
|
|
1558
|
+
),
|
|
1559
|
+
),
|
|
1560
|
+
)
|
|
1561
|
+
if _response.status_code == 500:
|
|
1562
|
+
raise InternalServerError(
|
|
1563
|
+
headers=dict(_response.headers),
|
|
1564
|
+
body=typing.cast(
|
|
1565
|
+
typing.Optional[typing.Any],
|
|
1566
|
+
parse_obj_as(
|
|
1567
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1568
|
+
object_=_response.json(),
|
|
1569
|
+
),
|
|
1570
|
+
),
|
|
1571
|
+
)
|
|
1572
|
+
_response_json = _response.json()
|
|
1573
|
+
except JSONDecodeError:
|
|
1574
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1575
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1576
|
+
|
|
1577
|
+
async def get_chat_messages(
|
|
1578
|
+
self,
|
|
1579
|
+
*,
|
|
1580
|
+
chat_session_id: str,
|
|
1581
|
+
num_messages: typing.Optional[int] = None,
|
|
1582
|
+
role: typing.Optional[str] = None,
|
|
1583
|
+
order: typing.Optional[AgentGetChatMessagesRequestOrder] = None,
|
|
1584
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1585
|
+
) -> AsyncHttpResponse[AgentGetChatMessagesResponse]:
|
|
1586
|
+
"""
|
|
1587
|
+
Retrieves a list of chat messages for a given chat session
|
|
1588
|
+
|
|
1589
|
+
Parameters
|
|
1590
|
+
----------
|
|
1591
|
+
chat_session_id : str
|
|
1592
|
+
Chat session ID
|
|
1593
|
+
|
|
1594
|
+
num_messages : typing.Optional[int]
|
|
1595
|
+
Number of messages to return
|
|
1596
|
+
|
|
1597
|
+
role : typing.Optional[str]
|
|
1598
|
+
Filter by role
|
|
1599
|
+
|
|
1600
|
+
order : typing.Optional[AgentGetChatMessagesRequestOrder]
|
|
1601
|
+
Order of messages
|
|
1602
|
+
|
|
1603
|
+
request_options : typing.Optional[RequestOptions]
|
|
1604
|
+
Request-specific configuration.
|
|
1605
|
+
|
|
1606
|
+
Returns
|
|
1607
|
+
-------
|
|
1608
|
+
AsyncHttpResponse[AgentGetChatMessagesResponse]
|
|
1609
|
+
Chat messages retrieved successfully
|
|
1610
|
+
"""
|
|
1611
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1612
|
+
"agent/chat/messages",
|
|
1613
|
+
method="GET",
|
|
1614
|
+
params={
|
|
1615
|
+
"chat_session_id": chat_session_id,
|
|
1616
|
+
"num_messages": num_messages,
|
|
1617
|
+
"role": role,
|
|
1618
|
+
"order": order,
|
|
1619
|
+
},
|
|
1620
|
+
request_options=request_options,
|
|
1621
|
+
)
|
|
1622
|
+
try:
|
|
1623
|
+
if 200 <= _response.status_code < 300:
|
|
1624
|
+
_data = typing.cast(
|
|
1625
|
+
AgentGetChatMessagesResponse,
|
|
1626
|
+
parse_obj_as(
|
|
1627
|
+
type_=AgentGetChatMessagesResponse, # type: ignore
|
|
1628
|
+
object_=_response.json(),
|
|
1629
|
+
),
|
|
1630
|
+
)
|
|
1631
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1632
|
+
if _response.status_code == 401:
|
|
1633
|
+
raise UnauthorizedError(
|
|
1634
|
+
headers=dict(_response.headers),
|
|
1635
|
+
body=typing.cast(
|
|
1636
|
+
typing.Optional[typing.Any],
|
|
1637
|
+
parse_obj_as(
|
|
1638
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1639
|
+
object_=_response.json(),
|
|
1640
|
+
),
|
|
1641
|
+
),
|
|
1642
|
+
)
|
|
1643
|
+
if _response.status_code == 403:
|
|
1644
|
+
raise ForbiddenError(
|
|
1645
|
+
headers=dict(_response.headers),
|
|
1646
|
+
body=typing.cast(
|
|
1647
|
+
typing.Optional[typing.Any],
|
|
1648
|
+
parse_obj_as(
|
|
1649
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1650
|
+
object_=_response.json(),
|
|
1651
|
+
),
|
|
1652
|
+
),
|
|
1653
|
+
)
|
|
1654
|
+
if _response.status_code == 500:
|
|
1655
|
+
raise InternalServerError(
|
|
1656
|
+
headers=dict(_response.headers),
|
|
1657
|
+
body=typing.cast(
|
|
1658
|
+
typing.Optional[typing.Any],
|
|
1659
|
+
parse_obj_as(
|
|
1660
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1661
|
+
object_=_response.json(),
|
|
1662
|
+
),
|
|
1663
|
+
),
|
|
1664
|
+
)
|
|
1665
|
+
_response_json = _response.json()
|
|
1666
|
+
except JSONDecodeError:
|
|
1667
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1668
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|