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
phenoml/agent/client.py
ADDED
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from .prompts.client import AsyncPromptsClient, PromptsClient
|
|
8
|
+
from .raw_client import AsyncRawAgentClient, RawAgentClient
|
|
9
|
+
from .types.agent_chat_response import AgentChatResponse
|
|
10
|
+
from .types.agent_create_request_provider import AgentCreateRequestProvider
|
|
11
|
+
from .types.agent_delete_response import AgentDeleteResponse
|
|
12
|
+
from .types.agent_get_chat_messages_request_order import AgentGetChatMessagesRequestOrder
|
|
13
|
+
from .types.agent_get_chat_messages_response import AgentGetChatMessagesResponse
|
|
14
|
+
from .types.agent_list_response import AgentListResponse
|
|
15
|
+
from .types.agent_response import AgentResponse
|
|
16
|
+
from .types.json_patch import JsonPatch
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AgentClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._raw_client = RawAgentClient(client_wrapper=client_wrapper)
|
|
25
|
+
self.prompts = PromptsClient(client_wrapper=client_wrapper)
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def with_raw_response(self) -> RawAgentClient:
|
|
29
|
+
"""
|
|
30
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
31
|
+
|
|
32
|
+
Returns
|
|
33
|
+
-------
|
|
34
|
+
RawAgentClient
|
|
35
|
+
"""
|
|
36
|
+
return self._raw_client
|
|
37
|
+
|
|
38
|
+
def create(
|
|
39
|
+
self,
|
|
40
|
+
*,
|
|
41
|
+
name: str,
|
|
42
|
+
prompts: typing.Sequence[str],
|
|
43
|
+
is_active: bool,
|
|
44
|
+
description: typing.Optional[str] = OMIT,
|
|
45
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
46
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
47
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
48
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
49
|
+
) -> AgentResponse:
|
|
50
|
+
"""
|
|
51
|
+
Creates a new PhenoAgent with specified configuration
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
name : str
|
|
56
|
+
Agent name
|
|
57
|
+
|
|
58
|
+
prompts : typing.Sequence[str]
|
|
59
|
+
Array of prompt IDs to use for this agent
|
|
60
|
+
|
|
61
|
+
is_active : bool
|
|
62
|
+
Whether the agent is active
|
|
63
|
+
|
|
64
|
+
description : typing.Optional[str]
|
|
65
|
+
Agent description
|
|
66
|
+
|
|
67
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
68
|
+
Array of MCP server tool IDs to use for this agent
|
|
69
|
+
|
|
70
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
71
|
+
Tags for categorizing the agent
|
|
72
|
+
|
|
73
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
74
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
75
|
+
|
|
76
|
+
request_options : typing.Optional[RequestOptions]
|
|
77
|
+
Request-specific configuration.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
AgentResponse
|
|
82
|
+
Agent created successfully
|
|
83
|
+
|
|
84
|
+
Examples
|
|
85
|
+
--------
|
|
86
|
+
from phenoml import phenoml
|
|
87
|
+
|
|
88
|
+
client = phenoml(
|
|
89
|
+
token="YOUR_TOKEN",
|
|
90
|
+
)
|
|
91
|
+
client.agent.create(
|
|
92
|
+
name="name",
|
|
93
|
+
prompts=["prompt_123", "prompt_456"],
|
|
94
|
+
is_active=True,
|
|
95
|
+
)
|
|
96
|
+
"""
|
|
97
|
+
_response = self._raw_client.create(
|
|
98
|
+
name=name,
|
|
99
|
+
prompts=prompts,
|
|
100
|
+
is_active=is_active,
|
|
101
|
+
description=description,
|
|
102
|
+
tools=tools,
|
|
103
|
+
tags=tags,
|
|
104
|
+
provider=provider,
|
|
105
|
+
request_options=request_options,
|
|
106
|
+
)
|
|
107
|
+
return _response.data
|
|
108
|
+
|
|
109
|
+
def list(
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
is_active: typing.Optional[bool] = None,
|
|
113
|
+
tags: typing.Optional[str] = None,
|
|
114
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
115
|
+
) -> AgentListResponse:
|
|
116
|
+
"""
|
|
117
|
+
Retrieves a list of PhenoAgents belonging to the authenticated user
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
is_active : typing.Optional[bool]
|
|
122
|
+
Filter by active status
|
|
123
|
+
|
|
124
|
+
tags : typing.Optional[str]
|
|
125
|
+
Filter by tags
|
|
126
|
+
|
|
127
|
+
request_options : typing.Optional[RequestOptions]
|
|
128
|
+
Request-specific configuration.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
AgentListResponse
|
|
133
|
+
Agents retrieved successfully
|
|
134
|
+
|
|
135
|
+
Examples
|
|
136
|
+
--------
|
|
137
|
+
from phenoml import phenoml
|
|
138
|
+
|
|
139
|
+
client = phenoml(
|
|
140
|
+
token="YOUR_TOKEN",
|
|
141
|
+
)
|
|
142
|
+
client.agent.list(
|
|
143
|
+
is_active=True,
|
|
144
|
+
tags="tags",
|
|
145
|
+
)
|
|
146
|
+
"""
|
|
147
|
+
_response = self._raw_client.list(is_active=is_active, tags=tags, request_options=request_options)
|
|
148
|
+
return _response.data
|
|
149
|
+
|
|
150
|
+
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentResponse:
|
|
151
|
+
"""
|
|
152
|
+
Retrieves a specific agent by its ID
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
id : str
|
|
157
|
+
Agent ID
|
|
158
|
+
|
|
159
|
+
request_options : typing.Optional[RequestOptions]
|
|
160
|
+
Request-specific configuration.
|
|
161
|
+
|
|
162
|
+
Returns
|
|
163
|
+
-------
|
|
164
|
+
AgentResponse
|
|
165
|
+
Agent retrieved successfully
|
|
166
|
+
|
|
167
|
+
Examples
|
|
168
|
+
--------
|
|
169
|
+
from phenoml import phenoml
|
|
170
|
+
|
|
171
|
+
client = phenoml(
|
|
172
|
+
token="YOUR_TOKEN",
|
|
173
|
+
)
|
|
174
|
+
client.agent.get(
|
|
175
|
+
id="id",
|
|
176
|
+
)
|
|
177
|
+
"""
|
|
178
|
+
_response = self._raw_client.get(id, request_options=request_options)
|
|
179
|
+
return _response.data
|
|
180
|
+
|
|
181
|
+
def update(
|
|
182
|
+
self,
|
|
183
|
+
id: str,
|
|
184
|
+
*,
|
|
185
|
+
name: str,
|
|
186
|
+
prompts: typing.Sequence[str],
|
|
187
|
+
is_active: bool,
|
|
188
|
+
description: typing.Optional[str] = OMIT,
|
|
189
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
190
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
191
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
192
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
193
|
+
) -> AgentResponse:
|
|
194
|
+
"""
|
|
195
|
+
Updates an existing agent's configuration
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
id : str
|
|
200
|
+
Agent ID
|
|
201
|
+
|
|
202
|
+
name : str
|
|
203
|
+
Agent name
|
|
204
|
+
|
|
205
|
+
prompts : typing.Sequence[str]
|
|
206
|
+
Array of prompt IDs to use for this agent
|
|
207
|
+
|
|
208
|
+
is_active : bool
|
|
209
|
+
Whether the agent is active
|
|
210
|
+
|
|
211
|
+
description : typing.Optional[str]
|
|
212
|
+
Agent description
|
|
213
|
+
|
|
214
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
215
|
+
Array of MCP server tool IDs to use for this agent
|
|
216
|
+
|
|
217
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
218
|
+
Tags for categorizing the agent
|
|
219
|
+
|
|
220
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
221
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
222
|
+
|
|
223
|
+
request_options : typing.Optional[RequestOptions]
|
|
224
|
+
Request-specific configuration.
|
|
225
|
+
|
|
226
|
+
Returns
|
|
227
|
+
-------
|
|
228
|
+
AgentResponse
|
|
229
|
+
Agent updated successfully
|
|
230
|
+
|
|
231
|
+
Examples
|
|
232
|
+
--------
|
|
233
|
+
from phenoml import phenoml
|
|
234
|
+
|
|
235
|
+
client = phenoml(
|
|
236
|
+
token="YOUR_TOKEN",
|
|
237
|
+
)
|
|
238
|
+
client.agent.update(
|
|
239
|
+
id="id",
|
|
240
|
+
name="name",
|
|
241
|
+
prompts=["prompt_123", "prompt_456"],
|
|
242
|
+
is_active=True,
|
|
243
|
+
)
|
|
244
|
+
"""
|
|
245
|
+
_response = self._raw_client.update(
|
|
246
|
+
id,
|
|
247
|
+
name=name,
|
|
248
|
+
prompts=prompts,
|
|
249
|
+
is_active=is_active,
|
|
250
|
+
description=description,
|
|
251
|
+
tools=tools,
|
|
252
|
+
tags=tags,
|
|
253
|
+
provider=provider,
|
|
254
|
+
request_options=request_options,
|
|
255
|
+
)
|
|
256
|
+
return _response.data
|
|
257
|
+
|
|
258
|
+
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentDeleteResponse:
|
|
259
|
+
"""
|
|
260
|
+
Deletes an existing agent
|
|
261
|
+
|
|
262
|
+
Parameters
|
|
263
|
+
----------
|
|
264
|
+
id : str
|
|
265
|
+
Agent ID
|
|
266
|
+
|
|
267
|
+
request_options : typing.Optional[RequestOptions]
|
|
268
|
+
Request-specific configuration.
|
|
269
|
+
|
|
270
|
+
Returns
|
|
271
|
+
-------
|
|
272
|
+
AgentDeleteResponse
|
|
273
|
+
Agent deleted successfully
|
|
274
|
+
|
|
275
|
+
Examples
|
|
276
|
+
--------
|
|
277
|
+
from phenoml import phenoml
|
|
278
|
+
|
|
279
|
+
client = phenoml(
|
|
280
|
+
token="YOUR_TOKEN",
|
|
281
|
+
)
|
|
282
|
+
client.agent.delete(
|
|
283
|
+
id="id",
|
|
284
|
+
)
|
|
285
|
+
"""
|
|
286
|
+
_response = self._raw_client.delete(id, request_options=request_options)
|
|
287
|
+
return _response.data
|
|
288
|
+
|
|
289
|
+
def patch(
|
|
290
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
291
|
+
) -> AgentResponse:
|
|
292
|
+
"""
|
|
293
|
+
Patches an existing agent's configuration
|
|
294
|
+
|
|
295
|
+
Parameters
|
|
296
|
+
----------
|
|
297
|
+
id : str
|
|
298
|
+
Agent ID
|
|
299
|
+
|
|
300
|
+
request : JsonPatch
|
|
301
|
+
|
|
302
|
+
request_options : typing.Optional[RequestOptions]
|
|
303
|
+
Request-specific configuration.
|
|
304
|
+
|
|
305
|
+
Returns
|
|
306
|
+
-------
|
|
307
|
+
AgentResponse
|
|
308
|
+
Agent patched successfully
|
|
309
|
+
|
|
310
|
+
Examples
|
|
311
|
+
--------
|
|
312
|
+
from phenoml import phenoml
|
|
313
|
+
from phenoml.agent import JsonPatchOperation
|
|
314
|
+
|
|
315
|
+
client = phenoml(
|
|
316
|
+
token="YOUR_TOKEN",
|
|
317
|
+
)
|
|
318
|
+
client.agent.patch(
|
|
319
|
+
id="id",
|
|
320
|
+
request=[
|
|
321
|
+
JsonPatchOperation(
|
|
322
|
+
op="replace",
|
|
323
|
+
path="/name",
|
|
324
|
+
value="Updated Agent Name",
|
|
325
|
+
),
|
|
326
|
+
JsonPatchOperation(
|
|
327
|
+
op="add",
|
|
328
|
+
path="/tags/-",
|
|
329
|
+
value="new-tag",
|
|
330
|
+
),
|
|
331
|
+
JsonPatchOperation(
|
|
332
|
+
op="remove",
|
|
333
|
+
path="/description",
|
|
334
|
+
),
|
|
335
|
+
],
|
|
336
|
+
)
|
|
337
|
+
"""
|
|
338
|
+
_response = self._raw_client.patch(id, request=request, request_options=request_options)
|
|
339
|
+
return _response.data
|
|
340
|
+
|
|
341
|
+
def chat(
|
|
342
|
+
self,
|
|
343
|
+
*,
|
|
344
|
+
message: str,
|
|
345
|
+
agent_id: str,
|
|
346
|
+
context: typing.Optional[str] = OMIT,
|
|
347
|
+
session_id: typing.Optional[str] = OMIT,
|
|
348
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
349
|
+
) -> AgentChatResponse:
|
|
350
|
+
"""
|
|
351
|
+
Send a message to an agent and receive a response
|
|
352
|
+
|
|
353
|
+
Parameters
|
|
354
|
+
----------
|
|
355
|
+
message : str
|
|
356
|
+
The message to send to the agent
|
|
357
|
+
|
|
358
|
+
agent_id : str
|
|
359
|
+
The ID of the agent to chat with
|
|
360
|
+
|
|
361
|
+
context : typing.Optional[str]
|
|
362
|
+
Optional context for the conversation
|
|
363
|
+
|
|
364
|
+
session_id : typing.Optional[str]
|
|
365
|
+
Optional session ID for conversation continuity
|
|
366
|
+
|
|
367
|
+
request_options : typing.Optional[RequestOptions]
|
|
368
|
+
Request-specific configuration.
|
|
369
|
+
|
|
370
|
+
Returns
|
|
371
|
+
-------
|
|
372
|
+
AgentChatResponse
|
|
373
|
+
Chat response received successfully
|
|
374
|
+
|
|
375
|
+
Examples
|
|
376
|
+
--------
|
|
377
|
+
from phenoml import phenoml
|
|
378
|
+
|
|
379
|
+
client = phenoml(
|
|
380
|
+
token="YOUR_TOKEN",
|
|
381
|
+
)
|
|
382
|
+
client.agent.chat(
|
|
383
|
+
message="What is the patient's current condition?",
|
|
384
|
+
agent_id="agent-123",
|
|
385
|
+
)
|
|
386
|
+
"""
|
|
387
|
+
_response = self._raw_client.chat(
|
|
388
|
+
message=message, agent_id=agent_id, context=context, session_id=session_id, request_options=request_options
|
|
389
|
+
)
|
|
390
|
+
return _response.data
|
|
391
|
+
|
|
392
|
+
def get_chat_messages(
|
|
393
|
+
self,
|
|
394
|
+
*,
|
|
395
|
+
chat_session_id: str,
|
|
396
|
+
num_messages: typing.Optional[int] = None,
|
|
397
|
+
role: typing.Optional[str] = None,
|
|
398
|
+
order: typing.Optional[AgentGetChatMessagesRequestOrder] = None,
|
|
399
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
400
|
+
) -> AgentGetChatMessagesResponse:
|
|
401
|
+
"""
|
|
402
|
+
Retrieves a list of chat messages for a given chat session
|
|
403
|
+
|
|
404
|
+
Parameters
|
|
405
|
+
----------
|
|
406
|
+
chat_session_id : str
|
|
407
|
+
Chat session ID
|
|
408
|
+
|
|
409
|
+
num_messages : typing.Optional[int]
|
|
410
|
+
Number of messages to return
|
|
411
|
+
|
|
412
|
+
role : typing.Optional[str]
|
|
413
|
+
Filter by role
|
|
414
|
+
|
|
415
|
+
order : typing.Optional[AgentGetChatMessagesRequestOrder]
|
|
416
|
+
Order of messages
|
|
417
|
+
|
|
418
|
+
request_options : typing.Optional[RequestOptions]
|
|
419
|
+
Request-specific configuration.
|
|
420
|
+
|
|
421
|
+
Returns
|
|
422
|
+
-------
|
|
423
|
+
AgentGetChatMessagesResponse
|
|
424
|
+
Chat messages retrieved successfully
|
|
425
|
+
|
|
426
|
+
Examples
|
|
427
|
+
--------
|
|
428
|
+
from phenoml import phenoml
|
|
429
|
+
|
|
430
|
+
client = phenoml(
|
|
431
|
+
token="YOUR_TOKEN",
|
|
432
|
+
)
|
|
433
|
+
client.agent.get_chat_messages(
|
|
434
|
+
chat_session_id="chat_session_id",
|
|
435
|
+
num_messages=1,
|
|
436
|
+
role="role",
|
|
437
|
+
order="asc",
|
|
438
|
+
)
|
|
439
|
+
"""
|
|
440
|
+
_response = self._raw_client.get_chat_messages(
|
|
441
|
+
chat_session_id=chat_session_id,
|
|
442
|
+
num_messages=num_messages,
|
|
443
|
+
role=role,
|
|
444
|
+
order=order,
|
|
445
|
+
request_options=request_options,
|
|
446
|
+
)
|
|
447
|
+
return _response.data
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
class AsyncAgentClient:
|
|
451
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
452
|
+
self._raw_client = AsyncRawAgentClient(client_wrapper=client_wrapper)
|
|
453
|
+
self.prompts = AsyncPromptsClient(client_wrapper=client_wrapper)
|
|
454
|
+
|
|
455
|
+
@property
|
|
456
|
+
def with_raw_response(self) -> AsyncRawAgentClient:
|
|
457
|
+
"""
|
|
458
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
459
|
+
|
|
460
|
+
Returns
|
|
461
|
+
-------
|
|
462
|
+
AsyncRawAgentClient
|
|
463
|
+
"""
|
|
464
|
+
return self._raw_client
|
|
465
|
+
|
|
466
|
+
async def create(
|
|
467
|
+
self,
|
|
468
|
+
*,
|
|
469
|
+
name: str,
|
|
470
|
+
prompts: typing.Sequence[str],
|
|
471
|
+
is_active: bool,
|
|
472
|
+
description: typing.Optional[str] = OMIT,
|
|
473
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
474
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
475
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
476
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
477
|
+
) -> AgentResponse:
|
|
478
|
+
"""
|
|
479
|
+
Creates a new PhenoAgent with specified configuration
|
|
480
|
+
|
|
481
|
+
Parameters
|
|
482
|
+
----------
|
|
483
|
+
name : str
|
|
484
|
+
Agent name
|
|
485
|
+
|
|
486
|
+
prompts : typing.Sequence[str]
|
|
487
|
+
Array of prompt IDs to use for this agent
|
|
488
|
+
|
|
489
|
+
is_active : bool
|
|
490
|
+
Whether the agent is active
|
|
491
|
+
|
|
492
|
+
description : typing.Optional[str]
|
|
493
|
+
Agent description
|
|
494
|
+
|
|
495
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
496
|
+
Array of MCP server tool IDs to use for this agent
|
|
497
|
+
|
|
498
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
499
|
+
Tags for categorizing the agent
|
|
500
|
+
|
|
501
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
502
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
503
|
+
|
|
504
|
+
request_options : typing.Optional[RequestOptions]
|
|
505
|
+
Request-specific configuration.
|
|
506
|
+
|
|
507
|
+
Returns
|
|
508
|
+
-------
|
|
509
|
+
AgentResponse
|
|
510
|
+
Agent created successfully
|
|
511
|
+
|
|
512
|
+
Examples
|
|
513
|
+
--------
|
|
514
|
+
import asyncio
|
|
515
|
+
|
|
516
|
+
from phenoml import Asyncphenoml
|
|
517
|
+
|
|
518
|
+
client = Asyncphenoml(
|
|
519
|
+
token="YOUR_TOKEN",
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
async def main() -> None:
|
|
524
|
+
await client.agent.create(
|
|
525
|
+
name="name",
|
|
526
|
+
prompts=["prompt_123", "prompt_456"],
|
|
527
|
+
is_active=True,
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
asyncio.run(main())
|
|
532
|
+
"""
|
|
533
|
+
_response = await self._raw_client.create(
|
|
534
|
+
name=name,
|
|
535
|
+
prompts=prompts,
|
|
536
|
+
is_active=is_active,
|
|
537
|
+
description=description,
|
|
538
|
+
tools=tools,
|
|
539
|
+
tags=tags,
|
|
540
|
+
provider=provider,
|
|
541
|
+
request_options=request_options,
|
|
542
|
+
)
|
|
543
|
+
return _response.data
|
|
544
|
+
|
|
545
|
+
async def list(
|
|
546
|
+
self,
|
|
547
|
+
*,
|
|
548
|
+
is_active: typing.Optional[bool] = None,
|
|
549
|
+
tags: typing.Optional[str] = None,
|
|
550
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
551
|
+
) -> AgentListResponse:
|
|
552
|
+
"""
|
|
553
|
+
Retrieves a list of PhenoAgents belonging to the authenticated user
|
|
554
|
+
|
|
555
|
+
Parameters
|
|
556
|
+
----------
|
|
557
|
+
is_active : typing.Optional[bool]
|
|
558
|
+
Filter by active status
|
|
559
|
+
|
|
560
|
+
tags : typing.Optional[str]
|
|
561
|
+
Filter by tags
|
|
562
|
+
|
|
563
|
+
request_options : typing.Optional[RequestOptions]
|
|
564
|
+
Request-specific configuration.
|
|
565
|
+
|
|
566
|
+
Returns
|
|
567
|
+
-------
|
|
568
|
+
AgentListResponse
|
|
569
|
+
Agents retrieved successfully
|
|
570
|
+
|
|
571
|
+
Examples
|
|
572
|
+
--------
|
|
573
|
+
import asyncio
|
|
574
|
+
|
|
575
|
+
from phenoml import Asyncphenoml
|
|
576
|
+
|
|
577
|
+
client = Asyncphenoml(
|
|
578
|
+
token="YOUR_TOKEN",
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
async def main() -> None:
|
|
583
|
+
await client.agent.list(
|
|
584
|
+
is_active=True,
|
|
585
|
+
tags="tags",
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
asyncio.run(main())
|
|
590
|
+
"""
|
|
591
|
+
_response = await self._raw_client.list(is_active=is_active, tags=tags, request_options=request_options)
|
|
592
|
+
return _response.data
|
|
593
|
+
|
|
594
|
+
async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentResponse:
|
|
595
|
+
"""
|
|
596
|
+
Retrieves a specific agent by its ID
|
|
597
|
+
|
|
598
|
+
Parameters
|
|
599
|
+
----------
|
|
600
|
+
id : str
|
|
601
|
+
Agent ID
|
|
602
|
+
|
|
603
|
+
request_options : typing.Optional[RequestOptions]
|
|
604
|
+
Request-specific configuration.
|
|
605
|
+
|
|
606
|
+
Returns
|
|
607
|
+
-------
|
|
608
|
+
AgentResponse
|
|
609
|
+
Agent retrieved successfully
|
|
610
|
+
|
|
611
|
+
Examples
|
|
612
|
+
--------
|
|
613
|
+
import asyncio
|
|
614
|
+
|
|
615
|
+
from phenoml import Asyncphenoml
|
|
616
|
+
|
|
617
|
+
client = Asyncphenoml(
|
|
618
|
+
token="YOUR_TOKEN",
|
|
619
|
+
)
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
async def main() -> None:
|
|
623
|
+
await client.agent.get(
|
|
624
|
+
id="id",
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
asyncio.run(main())
|
|
629
|
+
"""
|
|
630
|
+
_response = await self._raw_client.get(id, request_options=request_options)
|
|
631
|
+
return _response.data
|
|
632
|
+
|
|
633
|
+
async def update(
|
|
634
|
+
self,
|
|
635
|
+
id: str,
|
|
636
|
+
*,
|
|
637
|
+
name: str,
|
|
638
|
+
prompts: typing.Sequence[str],
|
|
639
|
+
is_active: bool,
|
|
640
|
+
description: typing.Optional[str] = OMIT,
|
|
641
|
+
tools: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
642
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
643
|
+
provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
|
|
644
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
645
|
+
) -> AgentResponse:
|
|
646
|
+
"""
|
|
647
|
+
Updates an existing agent's configuration
|
|
648
|
+
|
|
649
|
+
Parameters
|
|
650
|
+
----------
|
|
651
|
+
id : str
|
|
652
|
+
Agent ID
|
|
653
|
+
|
|
654
|
+
name : str
|
|
655
|
+
Agent name
|
|
656
|
+
|
|
657
|
+
prompts : typing.Sequence[str]
|
|
658
|
+
Array of prompt IDs to use for this agent
|
|
659
|
+
|
|
660
|
+
is_active : bool
|
|
661
|
+
Whether the agent is active
|
|
662
|
+
|
|
663
|
+
description : typing.Optional[str]
|
|
664
|
+
Agent description
|
|
665
|
+
|
|
666
|
+
tools : typing.Optional[typing.Sequence[str]]
|
|
667
|
+
Array of MCP server tool IDs to use for this agent
|
|
668
|
+
|
|
669
|
+
tags : typing.Optional[typing.Sequence[str]]
|
|
670
|
+
Tags for categorizing the agent
|
|
671
|
+
|
|
672
|
+
provider : typing.Optional[AgentCreateRequestProvider]
|
|
673
|
+
FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
|
|
674
|
+
|
|
675
|
+
request_options : typing.Optional[RequestOptions]
|
|
676
|
+
Request-specific configuration.
|
|
677
|
+
|
|
678
|
+
Returns
|
|
679
|
+
-------
|
|
680
|
+
AgentResponse
|
|
681
|
+
Agent updated successfully
|
|
682
|
+
|
|
683
|
+
Examples
|
|
684
|
+
--------
|
|
685
|
+
import asyncio
|
|
686
|
+
|
|
687
|
+
from phenoml import Asyncphenoml
|
|
688
|
+
|
|
689
|
+
client = Asyncphenoml(
|
|
690
|
+
token="YOUR_TOKEN",
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
async def main() -> None:
|
|
695
|
+
await client.agent.update(
|
|
696
|
+
id="id",
|
|
697
|
+
name="name",
|
|
698
|
+
prompts=["prompt_123", "prompt_456"],
|
|
699
|
+
is_active=True,
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
asyncio.run(main())
|
|
704
|
+
"""
|
|
705
|
+
_response = await self._raw_client.update(
|
|
706
|
+
id,
|
|
707
|
+
name=name,
|
|
708
|
+
prompts=prompts,
|
|
709
|
+
is_active=is_active,
|
|
710
|
+
description=description,
|
|
711
|
+
tools=tools,
|
|
712
|
+
tags=tags,
|
|
713
|
+
provider=provider,
|
|
714
|
+
request_options=request_options,
|
|
715
|
+
)
|
|
716
|
+
return _response.data
|
|
717
|
+
|
|
718
|
+
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentDeleteResponse:
|
|
719
|
+
"""
|
|
720
|
+
Deletes an existing agent
|
|
721
|
+
|
|
722
|
+
Parameters
|
|
723
|
+
----------
|
|
724
|
+
id : str
|
|
725
|
+
Agent ID
|
|
726
|
+
|
|
727
|
+
request_options : typing.Optional[RequestOptions]
|
|
728
|
+
Request-specific configuration.
|
|
729
|
+
|
|
730
|
+
Returns
|
|
731
|
+
-------
|
|
732
|
+
AgentDeleteResponse
|
|
733
|
+
Agent deleted successfully
|
|
734
|
+
|
|
735
|
+
Examples
|
|
736
|
+
--------
|
|
737
|
+
import asyncio
|
|
738
|
+
|
|
739
|
+
from phenoml import Asyncphenoml
|
|
740
|
+
|
|
741
|
+
client = Asyncphenoml(
|
|
742
|
+
token="YOUR_TOKEN",
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
async def main() -> None:
|
|
747
|
+
await client.agent.delete(
|
|
748
|
+
id="id",
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
asyncio.run(main())
|
|
753
|
+
"""
|
|
754
|
+
_response = await self._raw_client.delete(id, request_options=request_options)
|
|
755
|
+
return _response.data
|
|
756
|
+
|
|
757
|
+
async def patch(
|
|
758
|
+
self, id: str, *, request: JsonPatch, request_options: typing.Optional[RequestOptions] = None
|
|
759
|
+
) -> AgentResponse:
|
|
760
|
+
"""
|
|
761
|
+
Patches an existing agent's configuration
|
|
762
|
+
|
|
763
|
+
Parameters
|
|
764
|
+
----------
|
|
765
|
+
id : str
|
|
766
|
+
Agent ID
|
|
767
|
+
|
|
768
|
+
request : JsonPatch
|
|
769
|
+
|
|
770
|
+
request_options : typing.Optional[RequestOptions]
|
|
771
|
+
Request-specific configuration.
|
|
772
|
+
|
|
773
|
+
Returns
|
|
774
|
+
-------
|
|
775
|
+
AgentResponse
|
|
776
|
+
Agent patched successfully
|
|
777
|
+
|
|
778
|
+
Examples
|
|
779
|
+
--------
|
|
780
|
+
import asyncio
|
|
781
|
+
|
|
782
|
+
from phenoml import Asyncphenoml
|
|
783
|
+
from phenoml.agent import JsonPatchOperation
|
|
784
|
+
|
|
785
|
+
client = Asyncphenoml(
|
|
786
|
+
token="YOUR_TOKEN",
|
|
787
|
+
)
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
async def main() -> None:
|
|
791
|
+
await client.agent.patch(
|
|
792
|
+
id="id",
|
|
793
|
+
request=[
|
|
794
|
+
JsonPatchOperation(
|
|
795
|
+
op="replace",
|
|
796
|
+
path="/name",
|
|
797
|
+
value="Updated Agent Name",
|
|
798
|
+
),
|
|
799
|
+
JsonPatchOperation(
|
|
800
|
+
op="add",
|
|
801
|
+
path="/tags/-",
|
|
802
|
+
value="new-tag",
|
|
803
|
+
),
|
|
804
|
+
JsonPatchOperation(
|
|
805
|
+
op="remove",
|
|
806
|
+
path="/description",
|
|
807
|
+
),
|
|
808
|
+
],
|
|
809
|
+
)
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
asyncio.run(main())
|
|
813
|
+
"""
|
|
814
|
+
_response = await self._raw_client.patch(id, request=request, request_options=request_options)
|
|
815
|
+
return _response.data
|
|
816
|
+
|
|
817
|
+
async def chat(
|
|
818
|
+
self,
|
|
819
|
+
*,
|
|
820
|
+
message: str,
|
|
821
|
+
agent_id: str,
|
|
822
|
+
context: typing.Optional[str] = OMIT,
|
|
823
|
+
session_id: typing.Optional[str] = OMIT,
|
|
824
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
825
|
+
) -> AgentChatResponse:
|
|
826
|
+
"""
|
|
827
|
+
Send a message to an agent and receive a response
|
|
828
|
+
|
|
829
|
+
Parameters
|
|
830
|
+
----------
|
|
831
|
+
message : str
|
|
832
|
+
The message to send to the agent
|
|
833
|
+
|
|
834
|
+
agent_id : str
|
|
835
|
+
The ID of the agent to chat with
|
|
836
|
+
|
|
837
|
+
context : typing.Optional[str]
|
|
838
|
+
Optional context for the conversation
|
|
839
|
+
|
|
840
|
+
session_id : typing.Optional[str]
|
|
841
|
+
Optional session ID for conversation continuity
|
|
842
|
+
|
|
843
|
+
request_options : typing.Optional[RequestOptions]
|
|
844
|
+
Request-specific configuration.
|
|
845
|
+
|
|
846
|
+
Returns
|
|
847
|
+
-------
|
|
848
|
+
AgentChatResponse
|
|
849
|
+
Chat response received successfully
|
|
850
|
+
|
|
851
|
+
Examples
|
|
852
|
+
--------
|
|
853
|
+
import asyncio
|
|
854
|
+
|
|
855
|
+
from phenoml import Asyncphenoml
|
|
856
|
+
|
|
857
|
+
client = Asyncphenoml(
|
|
858
|
+
token="YOUR_TOKEN",
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
async def main() -> None:
|
|
863
|
+
await client.agent.chat(
|
|
864
|
+
message="What is the patient's current condition?",
|
|
865
|
+
agent_id="agent-123",
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
asyncio.run(main())
|
|
870
|
+
"""
|
|
871
|
+
_response = await self._raw_client.chat(
|
|
872
|
+
message=message, agent_id=agent_id, context=context, session_id=session_id, request_options=request_options
|
|
873
|
+
)
|
|
874
|
+
return _response.data
|
|
875
|
+
|
|
876
|
+
async def get_chat_messages(
|
|
877
|
+
self,
|
|
878
|
+
*,
|
|
879
|
+
chat_session_id: str,
|
|
880
|
+
num_messages: typing.Optional[int] = None,
|
|
881
|
+
role: typing.Optional[str] = None,
|
|
882
|
+
order: typing.Optional[AgentGetChatMessagesRequestOrder] = None,
|
|
883
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
884
|
+
) -> AgentGetChatMessagesResponse:
|
|
885
|
+
"""
|
|
886
|
+
Retrieves a list of chat messages for a given chat session
|
|
887
|
+
|
|
888
|
+
Parameters
|
|
889
|
+
----------
|
|
890
|
+
chat_session_id : str
|
|
891
|
+
Chat session ID
|
|
892
|
+
|
|
893
|
+
num_messages : typing.Optional[int]
|
|
894
|
+
Number of messages to return
|
|
895
|
+
|
|
896
|
+
role : typing.Optional[str]
|
|
897
|
+
Filter by role
|
|
898
|
+
|
|
899
|
+
order : typing.Optional[AgentGetChatMessagesRequestOrder]
|
|
900
|
+
Order of messages
|
|
901
|
+
|
|
902
|
+
request_options : typing.Optional[RequestOptions]
|
|
903
|
+
Request-specific configuration.
|
|
904
|
+
|
|
905
|
+
Returns
|
|
906
|
+
-------
|
|
907
|
+
AgentGetChatMessagesResponse
|
|
908
|
+
Chat messages retrieved successfully
|
|
909
|
+
|
|
910
|
+
Examples
|
|
911
|
+
--------
|
|
912
|
+
import asyncio
|
|
913
|
+
|
|
914
|
+
from phenoml import Asyncphenoml
|
|
915
|
+
|
|
916
|
+
client = Asyncphenoml(
|
|
917
|
+
token="YOUR_TOKEN",
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
async def main() -> None:
|
|
922
|
+
await client.agent.get_chat_messages(
|
|
923
|
+
chat_session_id="chat_session_id",
|
|
924
|
+
num_messages=1,
|
|
925
|
+
role="role",
|
|
926
|
+
order="asc",
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
asyncio.run(main())
|
|
931
|
+
"""
|
|
932
|
+
_response = await self._raw_client.get_chat_messages(
|
|
933
|
+
chat_session_id=chat_session_id,
|
|
934
|
+
num_messages=num_messages,
|
|
935
|
+
role=role,
|
|
936
|
+
order=order,
|
|
937
|
+
request_options=request_options,
|
|
938
|
+
)
|
|
939
|
+
return _response.data
|