phenoml 0.0.1__py3-none-any.whl → 0.0.5__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.

Potentially problematic release.


This version of phenoml might be problematic. Click here for more details.

Files changed (86) hide show
  1. phenoml/agent/__init__.py +10 -12
  2. phenoml/agent/client.py +172 -65
  3. phenoml/agent/prompts/client.py +60 -60
  4. phenoml/agent/prompts/raw_client.py +134 -134
  5. phenoml/agent/raw_client.py +236 -69
  6. phenoml/agent/types/__init__.py +10 -12
  7. phenoml/agent/types/agent_create_request.py +53 -0
  8. phenoml/agent/types/agent_create_request_provider.py +1 -9
  9. phenoml/agent/types/agent_get_chat_messages_request_order.py +5 -0
  10. phenoml/agent/types/agent_get_chat_messages_response.py +22 -0
  11. phenoml/agent/types/agent_template.py +6 -4
  12. phenoml/agent/types/agent_template_provider.py +1 -9
  13. phenoml/agent/types/chat_message_template.py +72 -0
  14. phenoml/agent/types/chat_session_template.py +67 -0
  15. phenoml/client.py +6 -0
  16. phenoml/core/client_wrapper.py +2 -2
  17. phenoml/fhir/__init__.py +36 -0
  18. phenoml/fhir/client.py +970 -0
  19. phenoml/fhir/errors/__init__.py +10 -0
  20. phenoml/fhir/errors/bad_request_error.py +10 -0
  21. phenoml/fhir/errors/internal_server_error.py +10 -0
  22. phenoml/fhir/errors/not_found_error.py +10 -0
  23. phenoml/fhir/errors/unauthorized_error.py +10 -0
  24. phenoml/fhir/raw_client.py +1385 -0
  25. phenoml/fhir/types/__init__.py +29 -0
  26. phenoml/{agent/types/chat_fhir_client_config.py → fhir/types/error_response.py} +11 -6
  27. phenoml/fhir/types/fhir_bundle.py +43 -0
  28. phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
  29. phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
  30. phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
  31. phenoml/fhir/types/fhir_bundle_entry_item_response.py +24 -0
  32. phenoml/fhir/types/fhir_patch_request_body_item.py +36 -0
  33. phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
  34. phenoml/fhir/types/fhir_resource.py +40 -0
  35. phenoml/fhir/types/fhir_resource_meta.py +28 -0
  36. phenoml/fhir/types/fhir_search_response.py +8 -0
  37. phenoml/fhir_provider/__init__.py +43 -0
  38. phenoml/fhir_provider/client.py +731 -0
  39. phenoml/fhir_provider/errors/__init__.py +11 -0
  40. phenoml/fhir_provider/errors/bad_request_error.py +10 -0
  41. phenoml/fhir_provider/errors/forbidden_error.py +10 -0
  42. phenoml/fhir_provider/errors/internal_server_error.py +10 -0
  43. phenoml/fhir_provider/errors/not_found_error.py +10 -0
  44. phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
  45. phenoml/fhir_provider/raw_client.py +1445 -0
  46. phenoml/fhir_provider/types/__init__.py +35 -0
  47. phenoml/fhir_provider/types/auth_method.py +7 -0
  48. phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
  49. phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
  50. phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
  51. phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
  52. phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
  53. phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
  54. phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
  55. phenoml/fhir_provider/types/fhir_query_response.py +27 -0
  56. phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
  57. phenoml/fhir_provider/types/json_web_key.py +51 -0
  58. phenoml/fhir_provider/types/provider.py +8 -0
  59. phenoml/fhir_provider/types/service_account_key.py +35 -0
  60. phenoml/fhir_provider/types/smart_configuration.py +46 -0
  61. phenoml/tools/__init__.py +12 -8
  62. phenoml/tools/client.py +27 -60
  63. phenoml/tools/mcp_server/__init__.py +7 -0
  64. phenoml/tools/mcp_server/client.py +336 -0
  65. phenoml/tools/mcp_server/raw_client.py +641 -0
  66. phenoml/tools/mcp_server/tools/__init__.py +4 -0
  67. phenoml/tools/mcp_server/tools/client.py +358 -0
  68. phenoml/tools/mcp_server/tools/raw_client.py +656 -0
  69. phenoml/tools/raw_client.py +18 -67
  70. phenoml/tools/types/__init__.py +10 -8
  71. phenoml/{agent/types/agent_fhir_config.py → tools/types/mcp_server_response.py} +8 -6
  72. phenoml/tools/types/mcp_server_response_data.py +51 -0
  73. phenoml/tools/types/mcp_server_tool_call_response.py +37 -0
  74. phenoml/tools/types/{fhir_client_config.py → mcp_server_tool_response.py} +8 -6
  75. phenoml/tools/types/mcp_server_tool_response_data.py +61 -0
  76. {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/METADATA +1 -1
  77. {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/RECORD +79 -29
  78. phenoml/agent/types/agent_create_request_provider_item.py +0 -7
  79. phenoml/agent/types/agent_template_provider_item.py +0 -5
  80. phenoml/agent/types/agent_update_request_provider.py +0 -13
  81. phenoml/agent/types/agent_update_request_provider_item.py +0 -7
  82. phenoml/tools/types/cohort_request_provider.py +0 -5
  83. phenoml/tools/types/lang2fhir_and_create_request_provider.py +0 -7
  84. phenoml/tools/types/lang2fhir_and_search_request_provider.py +0 -7
  85. {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/LICENSE +0 -0
  86. {phenoml-0.0.1.dist-info → phenoml-0.0.5.dist-info}/WHEEL +0 -0
@@ -18,11 +18,10 @@ from .errors.unauthorized_error import UnauthorizedError
18
18
  from .types.agent_chat_response import AgentChatResponse
19
19
  from .types.agent_create_request_provider import AgentCreateRequestProvider
20
20
  from .types.agent_delete_response import AgentDeleteResponse
21
- from .types.agent_fhir_config import AgentFhirConfig
21
+ from .types.agent_get_chat_messages_request_order import AgentGetChatMessagesRequestOrder
22
+ from .types.agent_get_chat_messages_response import AgentGetChatMessagesResponse
22
23
  from .types.agent_list_response import AgentListResponse
23
24
  from .types.agent_response import AgentResponse
24
- from .types.agent_update_request_provider import AgentUpdateRequestProvider
25
- from .types.chat_fhir_client_config import ChatFhirClientConfig
26
25
  from .types.json_patch import JsonPatch
27
26
 
28
27
  # this is used as the default value for optional parameters
@@ -40,9 +39,9 @@ class RawAgentClient:
40
39
  prompts: typing.Sequence[str],
41
40
  is_active: bool,
42
41
  description: typing.Optional[str] = OMIT,
42
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
43
43
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
44
44
  provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
45
- meta: typing.Optional[AgentFhirConfig] = OMIT,
46
45
  request_options: typing.Optional[RequestOptions] = None,
47
46
  ) -> HttpResponse[AgentResponse]:
48
47
  """
@@ -62,13 +61,14 @@ class RawAgentClient:
62
61
  description : typing.Optional[str]
63
62
  Agent description
64
63
 
64
+ tools : typing.Optional[typing.Sequence[str]]
65
+ Array of MCP server tool IDs to use for this agent
66
+
65
67
  tags : typing.Optional[typing.Sequence[str]]
66
68
  Tags for categorizing the agent
67
69
 
68
70
  provider : typing.Optional[AgentCreateRequestProvider]
69
- FHIR provider type - can be a single provider or array of providers
70
-
71
- meta : typing.Optional[AgentFhirConfig]
71
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
72
72
 
73
73
  request_options : typing.Optional[RequestOptions]
74
74
  Request-specific configuration.
@@ -85,14 +85,12 @@ class RawAgentClient:
85
85
  "name": name,
86
86
  "description": description,
87
87
  "prompts": prompts,
88
+ "tools": tools,
88
89
  "is_active": is_active,
89
90
  "tags": tags,
90
91
  "provider": convert_and_respect_annotation_metadata(
91
92
  object_=provider, annotation=AgentCreateRequestProvider, direction="write"
92
93
  ),
93
- "meta": convert_and_respect_annotation_metadata(
94
- object_=meta, annotation=AgentFhirConfig, direction="write"
95
- ),
96
94
  },
97
95
  headers={
98
96
  "content-type": "application/json",
@@ -327,13 +325,13 @@ class RawAgentClient:
327
325
  self,
328
326
  id: str,
329
327
  *,
330
- name: typing.Optional[str] = OMIT,
328
+ name: str,
329
+ prompts: typing.Sequence[str],
330
+ is_active: bool,
331
331
  description: typing.Optional[str] = OMIT,
332
- prompts: typing.Optional[typing.Sequence[str]] = OMIT,
333
- is_active: typing.Optional[bool] = OMIT,
332
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
334
333
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
335
- provider: typing.Optional[AgentUpdateRequestProvider] = OMIT,
336
- meta: typing.Optional[AgentFhirConfig] = OMIT,
334
+ provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
337
335
  request_options: typing.Optional[RequestOptions] = None,
338
336
  ) -> HttpResponse[AgentResponse]:
339
337
  """
@@ -344,25 +342,26 @@ class RawAgentClient:
344
342
  id : str
345
343
  Agent ID
346
344
 
347
- name : typing.Optional[str]
345
+ name : str
348
346
  Agent name
349
347
 
350
- description : typing.Optional[str]
351
- Agent description
352
-
353
- prompts : typing.Optional[typing.Sequence[str]]
348
+ prompts : typing.Sequence[str]
354
349
  Array of prompt IDs to use for this agent
355
350
 
356
- is_active : typing.Optional[bool]
351
+ is_active : bool
357
352
  Whether the agent is active
358
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
+
359
360
  tags : typing.Optional[typing.Sequence[str]]
360
361
  Tags for categorizing the agent
361
362
 
362
- provider : typing.Optional[AgentUpdateRequestProvider]
363
- FHIR provider type - can be a single provider or array of providers
364
-
365
- meta : typing.Optional[AgentFhirConfig]
363
+ provider : typing.Optional[AgentCreateRequestProvider]
364
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
366
365
 
367
366
  request_options : typing.Optional[RequestOptions]
368
367
  Request-specific configuration.
@@ -379,13 +378,11 @@ class RawAgentClient:
379
378
  "name": name,
380
379
  "description": description,
381
380
  "prompts": prompts,
381
+ "tools": tools,
382
382
  "is_active": is_active,
383
383
  "tags": tags,
384
384
  "provider": convert_and_respect_annotation_metadata(
385
- object_=provider, annotation=AgentUpdateRequestProvider, direction="write"
386
- ),
387
- "meta": convert_and_respect_annotation_metadata(
388
- object_=meta, annotation=AgentFhirConfig, direction="write"
385
+ object_=provider, annotation=AgentCreateRequestProvider, direction="write"
389
386
  ),
390
387
  },
391
388
  headers={
@@ -655,7 +652,6 @@ class RawAgentClient:
655
652
  agent_id: str,
656
653
  context: typing.Optional[str] = OMIT,
657
654
  session_id: typing.Optional[str] = OMIT,
658
- meta: typing.Optional[ChatFhirClientConfig] = OMIT,
659
655
  request_options: typing.Optional[RequestOptions] = None,
660
656
  ) -> HttpResponse[AgentChatResponse]:
661
657
  """
@@ -675,9 +671,6 @@ class RawAgentClient:
675
671
  session_id : typing.Optional[str]
676
672
  Optional session ID for conversation continuity
677
673
 
678
- meta : typing.Optional[ChatFhirClientConfig]
679
- Optional user-specific FHIR configuration overrides
680
-
681
674
  request_options : typing.Optional[RequestOptions]
682
675
  Request-specific configuration.
683
676
 
@@ -694,9 +687,6 @@ class RawAgentClient:
694
687
  "context": context,
695
688
  "session_id": session_id,
696
689
  "agent_id": agent_id,
697
- "meta": convert_and_respect_annotation_metadata(
698
- object_=meta, annotation=ChatFhirClientConfig, direction="write"
699
- ),
700
690
  },
701
691
  headers={
702
692
  "content-type": "application/json",
@@ -763,6 +753,99 @@ class RawAgentClient:
763
753
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
764
754
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
765
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
+
766
849
 
767
850
  class AsyncRawAgentClient:
768
851
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -775,9 +858,9 @@ class AsyncRawAgentClient:
775
858
  prompts: typing.Sequence[str],
776
859
  is_active: bool,
777
860
  description: typing.Optional[str] = OMIT,
861
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
778
862
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
779
863
  provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
780
- meta: typing.Optional[AgentFhirConfig] = OMIT,
781
864
  request_options: typing.Optional[RequestOptions] = None,
782
865
  ) -> AsyncHttpResponse[AgentResponse]:
783
866
  """
@@ -797,13 +880,14 @@ class AsyncRawAgentClient:
797
880
  description : typing.Optional[str]
798
881
  Agent description
799
882
 
883
+ tools : typing.Optional[typing.Sequence[str]]
884
+ Array of MCP server tool IDs to use for this agent
885
+
800
886
  tags : typing.Optional[typing.Sequence[str]]
801
887
  Tags for categorizing the agent
802
888
 
803
889
  provider : typing.Optional[AgentCreateRequestProvider]
804
- FHIR provider type - can be a single provider or array of providers
805
-
806
- meta : typing.Optional[AgentFhirConfig]
890
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
807
891
 
808
892
  request_options : typing.Optional[RequestOptions]
809
893
  Request-specific configuration.
@@ -820,14 +904,12 @@ class AsyncRawAgentClient:
820
904
  "name": name,
821
905
  "description": description,
822
906
  "prompts": prompts,
907
+ "tools": tools,
823
908
  "is_active": is_active,
824
909
  "tags": tags,
825
910
  "provider": convert_and_respect_annotation_metadata(
826
911
  object_=provider, annotation=AgentCreateRequestProvider, direction="write"
827
912
  ),
828
- "meta": convert_and_respect_annotation_metadata(
829
- object_=meta, annotation=AgentFhirConfig, direction="write"
830
- ),
831
913
  },
832
914
  headers={
833
915
  "content-type": "application/json",
@@ -1064,13 +1146,13 @@ class AsyncRawAgentClient:
1064
1146
  self,
1065
1147
  id: str,
1066
1148
  *,
1067
- name: typing.Optional[str] = OMIT,
1149
+ name: str,
1150
+ prompts: typing.Sequence[str],
1151
+ is_active: bool,
1068
1152
  description: typing.Optional[str] = OMIT,
1069
- prompts: typing.Optional[typing.Sequence[str]] = OMIT,
1070
- is_active: typing.Optional[bool] = OMIT,
1153
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
1071
1154
  tags: typing.Optional[typing.Sequence[str]] = OMIT,
1072
- provider: typing.Optional[AgentUpdateRequestProvider] = OMIT,
1073
- meta: typing.Optional[AgentFhirConfig] = OMIT,
1155
+ provider: typing.Optional[AgentCreateRequestProvider] = OMIT,
1074
1156
  request_options: typing.Optional[RequestOptions] = None,
1075
1157
  ) -> AsyncHttpResponse[AgentResponse]:
1076
1158
  """
@@ -1081,25 +1163,26 @@ class AsyncRawAgentClient:
1081
1163
  id : str
1082
1164
  Agent ID
1083
1165
 
1084
- name : typing.Optional[str]
1166
+ name : str
1085
1167
  Agent name
1086
1168
 
1087
- description : typing.Optional[str]
1088
- Agent description
1089
-
1090
- prompts : typing.Optional[typing.Sequence[str]]
1169
+ prompts : typing.Sequence[str]
1091
1170
  Array of prompt IDs to use for this agent
1092
1171
 
1093
- is_active : typing.Optional[bool]
1172
+ is_active : bool
1094
1173
  Whether the agent is active
1095
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
+
1096
1181
  tags : typing.Optional[typing.Sequence[str]]
1097
1182
  Tags for categorizing the agent
1098
1183
 
1099
- provider : typing.Optional[AgentUpdateRequestProvider]
1100
- FHIR provider type - can be a single provider or array of providers
1101
-
1102
- meta : typing.Optional[AgentFhirConfig]
1184
+ provider : typing.Optional[AgentCreateRequestProvider]
1185
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
1103
1186
 
1104
1187
  request_options : typing.Optional[RequestOptions]
1105
1188
  Request-specific configuration.
@@ -1116,13 +1199,11 @@ class AsyncRawAgentClient:
1116
1199
  "name": name,
1117
1200
  "description": description,
1118
1201
  "prompts": prompts,
1202
+ "tools": tools,
1119
1203
  "is_active": is_active,
1120
1204
  "tags": tags,
1121
1205
  "provider": convert_and_respect_annotation_metadata(
1122
- object_=provider, annotation=AgentUpdateRequestProvider, direction="write"
1123
- ),
1124
- "meta": convert_and_respect_annotation_metadata(
1125
- object_=meta, annotation=AgentFhirConfig, direction="write"
1206
+ object_=provider, annotation=AgentCreateRequestProvider, direction="write"
1126
1207
  ),
1127
1208
  },
1128
1209
  headers={
@@ -1392,7 +1473,6 @@ class AsyncRawAgentClient:
1392
1473
  agent_id: str,
1393
1474
  context: typing.Optional[str] = OMIT,
1394
1475
  session_id: typing.Optional[str] = OMIT,
1395
- meta: typing.Optional[ChatFhirClientConfig] = OMIT,
1396
1476
  request_options: typing.Optional[RequestOptions] = None,
1397
1477
  ) -> AsyncHttpResponse[AgentChatResponse]:
1398
1478
  """
@@ -1412,9 +1492,6 @@ class AsyncRawAgentClient:
1412
1492
  session_id : typing.Optional[str]
1413
1493
  Optional session ID for conversation continuity
1414
1494
 
1415
- meta : typing.Optional[ChatFhirClientConfig]
1416
- Optional user-specific FHIR configuration overrides
1417
-
1418
1495
  request_options : typing.Optional[RequestOptions]
1419
1496
  Request-specific configuration.
1420
1497
 
@@ -1431,9 +1508,6 @@ class AsyncRawAgentClient:
1431
1508
  "context": context,
1432
1509
  "session_id": session_id,
1433
1510
  "agent_id": agent_id,
1434
- "meta": convert_and_respect_annotation_metadata(
1435
- object_=meta, annotation=ChatFhirClientConfig, direction="write"
1436
- ),
1437
1511
  },
1438
1512
  headers={
1439
1513
  "content-type": "application/json",
@@ -1499,3 +1573,96 @@ class AsyncRawAgentClient:
1499
1573
  except JSONDecodeError:
1500
1574
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1501
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)
@@ -3,19 +3,18 @@
3
3
  # isort: skip_file
4
4
 
5
5
  from .agent_chat_response import AgentChatResponse
6
+ from .agent_create_request import AgentCreateRequest
6
7
  from .agent_create_request_provider import AgentCreateRequestProvider
7
- from .agent_create_request_provider_item import AgentCreateRequestProviderItem
8
8
  from .agent_delete_response import AgentDeleteResponse
9
- from .agent_fhir_config import AgentFhirConfig
9
+ from .agent_get_chat_messages_request_order import AgentGetChatMessagesRequestOrder
10
+ from .agent_get_chat_messages_response import AgentGetChatMessagesResponse
10
11
  from .agent_list_response import AgentListResponse
11
12
  from .agent_prompts_response import AgentPromptsResponse
12
13
  from .agent_response import AgentResponse
13
14
  from .agent_template import AgentTemplate
14
15
  from .agent_template_provider import AgentTemplateProvider
15
- from .agent_template_provider_item import AgentTemplateProviderItem
16
- from .agent_update_request_provider import AgentUpdateRequestProvider
17
- from .agent_update_request_provider_item import AgentUpdateRequestProviderItem
18
- from .chat_fhir_client_config import ChatFhirClientConfig
16
+ from .chat_message_template import ChatMessageTemplate
17
+ from .chat_session_template import ChatSessionTemplate
19
18
  from .json_patch import JsonPatch
20
19
  from .json_patch_operation import JsonPatchOperation
21
20
  from .json_patch_operation_op import JsonPatchOperationOp
@@ -24,19 +23,18 @@ from .success_response import SuccessResponse
24
23
 
25
24
  __all__ = [
26
25
  "AgentChatResponse",
26
+ "AgentCreateRequest",
27
27
  "AgentCreateRequestProvider",
28
- "AgentCreateRequestProviderItem",
29
28
  "AgentDeleteResponse",
30
- "AgentFhirConfig",
29
+ "AgentGetChatMessagesRequestOrder",
30
+ "AgentGetChatMessagesResponse",
31
31
  "AgentListResponse",
32
32
  "AgentPromptsResponse",
33
33
  "AgentResponse",
34
34
  "AgentTemplate",
35
35
  "AgentTemplateProvider",
36
- "AgentTemplateProviderItem",
37
- "AgentUpdateRequestProvider",
38
- "AgentUpdateRequestProviderItem",
39
- "ChatFhirClientConfig",
36
+ "ChatMessageTemplate",
37
+ "ChatSessionTemplate",
40
38
  "JsonPatch",
41
39
  "JsonPatchOperation",
42
40
  "JsonPatchOperationOp",
@@ -0,0 +1,53 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .agent_create_request_provider import AgentCreateRequestProvider
8
+
9
+
10
+ class AgentCreateRequest(UniversalBaseModel):
11
+ name: str = pydantic.Field()
12
+ """
13
+ Agent name
14
+ """
15
+
16
+ description: typing.Optional[str] = pydantic.Field(default=None)
17
+ """
18
+ Agent description
19
+ """
20
+
21
+ prompts: typing.List[str] = pydantic.Field()
22
+ """
23
+ Array of prompt IDs to use for this agent
24
+ """
25
+
26
+ tools: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
27
+ """
28
+ Array of MCP server tool IDs to use for this agent
29
+ """
30
+
31
+ is_active: bool = pydantic.Field()
32
+ """
33
+ Whether the agent is active
34
+ """
35
+
36
+ tags: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
37
+ """
38
+ Tags for categorizing the agent
39
+ """
40
+
41
+ provider: typing.Optional[AgentCreateRequestProvider] = pydantic.Field(default=None)
42
+ """
43
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
44
+ """
45
+
46
+ if IS_PYDANTIC_V2:
47
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
48
+ else:
49
+
50
+ class Config:
51
+ frozen = True
52
+ smart_union = True
53
+ extra = pydantic.Extra.allow
@@ -2,12 +2,4 @@
2
2
 
3
3
  import typing
4
4
 
5
- from .agent_create_request_provider_item import AgentCreateRequestProviderItem
6
-
7
- AgentCreateRequestProvider = typing.Union[
8
- typing.Literal["medplum"],
9
- typing.Literal["google_healthcare"],
10
- typing.Literal["canvas"],
11
- typing.Literal["hapi"],
12
- typing.List[AgentCreateRequestProviderItem],
13
- ]
5
+ AgentCreateRequestProvider = typing.Union[str, typing.List[str]]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ AgentGetChatMessagesRequestOrder = typing.Union[typing.Literal["asc", "desc"], typing.Any]
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .chat_message_template import ChatMessageTemplate
8
+
9
+
10
+ class AgentGetChatMessagesResponse(UniversalBaseModel):
11
+ messages: typing.Optional[typing.List[ChatMessageTemplate]] = None
12
+ total: typing.Optional[int] = None
13
+ session_id: typing.Optional[str] = None
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -4,7 +4,6 @@ import typing
4
4
 
5
5
  import pydantic
6
6
  from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
- from .agent_fhir_config import AgentFhirConfig
8
7
  from .agent_template_provider import AgentTemplateProvider
9
8
 
10
9
 
@@ -29,6 +28,11 @@ class AgentTemplate(UniversalBaseModel):
29
28
  Array of prompt IDs used by this agent
30
29
  """
31
30
 
31
+ tools: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
32
+ """
33
+ Array of MCP server tool IDs used by this agent
34
+ """
35
+
32
36
  is_active: typing.Optional[bool] = pydantic.Field(default=None)
33
37
  """
34
38
  Whether the agent is active
@@ -41,11 +45,9 @@ class AgentTemplate(UniversalBaseModel):
41
45
 
42
46
  provider: typing.Optional[AgentTemplateProvider] = pydantic.Field(default=None)
43
47
  """
44
- FHIR provider type - can be a single provider or array of providers
48
+ FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers
45
49
  """
46
50
 
47
- meta: typing.Optional[AgentFhirConfig] = None
48
-
49
51
  if IS_PYDANTIC_V2:
50
52
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
51
53
  else: