mistralai 1.9.11__py3-none-any.whl → 1.10.0__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.
- mistralai/_hooks/registration.py +5 -0
- mistralai/_hooks/tracing.py +50 -0
- mistralai/_version.py +2 -2
- mistralai/accesses.py +8 -8
- mistralai/agents.py +29 -17
- mistralai/chat.py +41 -29
- mistralai/conversations.py +294 -62
- mistralai/documents.py +19 -3
- mistralai/embeddings.py +6 -6
- mistralai/extra/observability/__init__.py +15 -0
- mistralai/extra/observability/otel.py +393 -0
- mistralai/extra/run/tools.py +28 -16
- mistralai/files.py +6 -0
- mistralai/fim.py +17 -5
- mistralai/mistral_agents.py +229 -1
- mistralai/mistral_jobs.py +10 -10
- mistralai/models/__init__.py +69 -2
- mistralai/models/agent.py +15 -2
- mistralai/models/agentconversation.py +11 -3
- mistralai/models/agentcreationrequest.py +6 -2
- mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
- mistralai/models/agents_api_v1_agents_getop.py +40 -3
- mistralai/models/agents_api_v1_agents_listop.py +72 -2
- mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
- mistralai/models/agents_api_v1_conversations_listop.py +39 -2
- mistralai/models/agentscompletionrequest.py +21 -6
- mistralai/models/agentscompletionstreamrequest.py +21 -6
- mistralai/models/agentupdaterequest.py +18 -2
- mistralai/models/audiotranscriptionrequest.py +2 -0
- mistralai/models/batchjobin.py +10 -0
- mistralai/models/chatcompletionrequest.py +22 -5
- mistralai/models/chatcompletionstreamrequest.py +22 -5
- mistralai/models/conversationrequest.py +15 -4
- mistralai/models/conversationrestartrequest.py +50 -2
- mistralai/models/conversationrestartstreamrequest.py +50 -2
- mistralai/models/conversationstreamrequest.py +15 -4
- mistralai/models/documentout.py +26 -10
- mistralai/models/documentupdatein.py +24 -3
- mistralai/models/embeddingrequest.py +8 -8
- mistralai/models/files_api_routes_list_filesop.py +7 -0
- mistralai/models/fimcompletionrequest.py +8 -9
- mistralai/models/fimcompletionstreamrequest.py +8 -9
- mistralai/models/libraries_documents_list_v1op.py +15 -2
- mistralai/models/libraryout.py +10 -7
- mistralai/models/listfilesout.py +35 -4
- mistralai/models/modelcapabilities.py +13 -4
- mistralai/models/modelconversation.py +8 -2
- mistralai/models/ocrpageobject.py +26 -5
- mistralai/models/ocrrequest.py +17 -1
- mistralai/models/ocrtableobject.py +31 -0
- mistralai/models/prediction.py +4 -0
- mistralai/models/requestsource.py +7 -0
- mistralai/models/responseformat.py +4 -2
- mistralai/models/responseformats.py +0 -1
- mistralai/models/sharingdelete.py +36 -5
- mistralai/models/sharingin.py +36 -5
- mistralai/models/sharingout.py +3 -3
- mistralai/models/toolexecutiondeltaevent.py +13 -4
- mistralai/models/toolexecutiondoneevent.py +13 -4
- mistralai/models/toolexecutionentry.py +9 -4
- mistralai/models/toolexecutionstartedevent.py +13 -4
- mistralai/models_.py +2 -14
- mistralai/ocr.py +18 -0
- mistralai/transcriptions.py +4 -4
- {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/METADATA +30 -12
- {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/RECORD +68 -61
- {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/WHEEL +0 -0
- {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/licenses/LICENSE +0 -0
mistralai/conversations.py
CHANGED
|
@@ -6,7 +6,7 @@ from mistralai._hooks import HookContext
|
|
|
6
6
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
7
|
from mistralai.utils import eventstreaming, get_security_from_env
|
|
8
8
|
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
9
|
-
from typing import Any, List, Mapping, Optional, Union
|
|
9
|
+
from typing import Any, Dict, List, Mapping, Optional, Union
|
|
10
10
|
|
|
11
11
|
# region imports
|
|
12
12
|
import typing
|
|
@@ -26,8 +26,10 @@ from mistralai.extra.run.result import (
|
|
|
26
26
|
reconstitue_entries,
|
|
27
27
|
)
|
|
28
28
|
from mistralai.extra.run.utils import run_requirements
|
|
29
|
+
from mistralai.extra.observability.otel import GenAISpanEnum, get_or_create_otel_tracer
|
|
29
30
|
|
|
30
31
|
logger = logging.getLogger(__name__)
|
|
32
|
+
tracing_enabled, tracer = get_or_create_otel_tracer()
|
|
31
33
|
|
|
32
34
|
if typing.TYPE_CHECKING:
|
|
33
35
|
from mistralai.extra.run.context import RunContext
|
|
@@ -67,50 +69,52 @@ class Conversations(BaseSDK):
|
|
|
67
69
|
from mistralai.extra.run.context import _validate_run
|
|
68
70
|
from mistralai.extra.run.tools import get_function_calls
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
with tracer.start_as_current_span(GenAISpanEnum.VALIDATE_RUN.value):
|
|
73
|
+
req, run_result, input_entries = await _validate_run(
|
|
74
|
+
beta_client=Beta(self.sdk_configuration),
|
|
75
|
+
run_ctx=run_ctx,
|
|
76
|
+
inputs=inputs,
|
|
77
|
+
instructions=instructions,
|
|
78
|
+
tools=tools,
|
|
79
|
+
completion_args=completion_args,
|
|
80
|
+
)
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
82
|
+
with tracer.start_as_current_span(GenAISpanEnum.CONVERSATION.value):
|
|
83
|
+
while True:
|
|
84
|
+
if run_ctx.conversation_id is None:
|
|
85
|
+
res = await self.start_async(
|
|
86
|
+
inputs=input_entries,
|
|
87
|
+
http_headers=http_headers,
|
|
88
|
+
name=name,
|
|
89
|
+
description=description,
|
|
90
|
+
retries=retries,
|
|
91
|
+
server_url=server_url,
|
|
92
|
+
timeout_ms=timeout_ms,
|
|
93
|
+
**req, # type: ignore
|
|
94
|
+
)
|
|
95
|
+
run_result.conversation_id = res.conversation_id
|
|
96
|
+
run_ctx.conversation_id = res.conversation_id
|
|
97
|
+
logger.info(
|
|
98
|
+
f"Started Run with conversation with id {res.conversation_id}"
|
|
99
|
+
)
|
|
100
|
+
else:
|
|
101
|
+
res = await self.append_async(
|
|
102
|
+
conversation_id=run_ctx.conversation_id,
|
|
103
|
+
inputs=input_entries,
|
|
104
|
+
retries=retries,
|
|
105
|
+
server_url=server_url,
|
|
106
|
+
timeout_ms=timeout_ms,
|
|
107
|
+
)
|
|
108
|
+
run_ctx.request_count += 1
|
|
109
|
+
run_result.output_entries.extend(res.outputs)
|
|
110
|
+
fcalls = get_function_calls(res.outputs)
|
|
111
|
+
if not fcalls:
|
|
112
|
+
logger.debug("No more function calls to execute")
|
|
113
|
+
break
|
|
114
|
+
else:
|
|
115
|
+
fresults = await run_ctx.execute_function_calls(fcalls)
|
|
116
|
+
run_result.output_entries.extend(fresults)
|
|
117
|
+
input_entries = typing.cast(list[InputEntries], fresults)
|
|
114
118
|
return run_result
|
|
115
119
|
|
|
116
120
|
@run_requirements
|
|
@@ -224,15 +228,15 @@ class Conversations(BaseSDK):
|
|
|
224
228
|
store: OptionalNullable[bool] = UNSET,
|
|
225
229
|
handoff_execution: OptionalNullable[models.HandoffExecution] = UNSET,
|
|
226
230
|
instructions: OptionalNullable[str] = UNSET,
|
|
227
|
-
tools:
|
|
228
|
-
Union[List[models.Tools], List[models.ToolsTypedDict]]
|
|
229
|
-
] = UNSET,
|
|
231
|
+
tools: Optional[Union[List[models.Tools], List[models.ToolsTypedDict]]] = None,
|
|
230
232
|
completion_args: OptionalNullable[
|
|
231
233
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
232
234
|
] = UNSET,
|
|
233
235
|
name: OptionalNullable[str] = UNSET,
|
|
234
236
|
description: OptionalNullable[str] = UNSET,
|
|
237
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
235
238
|
agent_id: OptionalNullable[str] = UNSET,
|
|
239
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
236
240
|
model: OptionalNullable[str] = UNSET,
|
|
237
241
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
238
242
|
server_url: Optional[str] = None,
|
|
@@ -248,11 +252,13 @@ class Conversations(BaseSDK):
|
|
|
248
252
|
:param store:
|
|
249
253
|
:param handoff_execution:
|
|
250
254
|
:param instructions:
|
|
251
|
-
:param tools:
|
|
255
|
+
:param tools: List of tools which are available to the model during the conversation.
|
|
252
256
|
:param completion_args:
|
|
253
257
|
:param name:
|
|
254
258
|
:param description:
|
|
259
|
+
:param metadata:
|
|
255
260
|
:param agent_id:
|
|
261
|
+
:param agent_version:
|
|
256
262
|
:param model:
|
|
257
263
|
:param retries: Override the default retry configuration for this method
|
|
258
264
|
:param server_url: Override the default server URL for this method
|
|
@@ -275,13 +281,15 @@ class Conversations(BaseSDK):
|
|
|
275
281
|
store=store,
|
|
276
282
|
handoff_execution=handoff_execution,
|
|
277
283
|
instructions=instructions,
|
|
278
|
-
tools=utils.get_pydantic_model(tools,
|
|
284
|
+
tools=utils.get_pydantic_model(tools, Optional[List[models.Tools]]),
|
|
279
285
|
completion_args=utils.get_pydantic_model(
|
|
280
286
|
completion_args, OptionalNullable[models.CompletionArgs]
|
|
281
287
|
),
|
|
282
288
|
name=name,
|
|
283
289
|
description=description,
|
|
290
|
+
metadata=metadata,
|
|
284
291
|
agent_id=agent_id,
|
|
292
|
+
agent_version=agent_version,
|
|
285
293
|
model=model,
|
|
286
294
|
)
|
|
287
295
|
|
|
@@ -352,15 +360,15 @@ class Conversations(BaseSDK):
|
|
|
352
360
|
store: OptionalNullable[bool] = UNSET,
|
|
353
361
|
handoff_execution: OptionalNullable[models.HandoffExecution] = UNSET,
|
|
354
362
|
instructions: OptionalNullable[str] = UNSET,
|
|
355
|
-
tools:
|
|
356
|
-
Union[List[models.Tools], List[models.ToolsTypedDict]]
|
|
357
|
-
] = UNSET,
|
|
363
|
+
tools: Optional[Union[List[models.Tools], List[models.ToolsTypedDict]]] = None,
|
|
358
364
|
completion_args: OptionalNullable[
|
|
359
365
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
360
366
|
] = UNSET,
|
|
361
367
|
name: OptionalNullable[str] = UNSET,
|
|
362
368
|
description: OptionalNullable[str] = UNSET,
|
|
369
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
363
370
|
agent_id: OptionalNullable[str] = UNSET,
|
|
371
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
364
372
|
model: OptionalNullable[str] = UNSET,
|
|
365
373
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
366
374
|
server_url: Optional[str] = None,
|
|
@@ -376,11 +384,13 @@ class Conversations(BaseSDK):
|
|
|
376
384
|
:param store:
|
|
377
385
|
:param handoff_execution:
|
|
378
386
|
:param instructions:
|
|
379
|
-
:param tools:
|
|
387
|
+
:param tools: List of tools which are available to the model during the conversation.
|
|
380
388
|
:param completion_args:
|
|
381
389
|
:param name:
|
|
382
390
|
:param description:
|
|
391
|
+
:param metadata:
|
|
383
392
|
:param agent_id:
|
|
393
|
+
:param agent_version:
|
|
384
394
|
:param model:
|
|
385
395
|
:param retries: Override the default retry configuration for this method
|
|
386
396
|
:param server_url: Override the default server URL for this method
|
|
@@ -403,13 +413,15 @@ class Conversations(BaseSDK):
|
|
|
403
413
|
store=store,
|
|
404
414
|
handoff_execution=handoff_execution,
|
|
405
415
|
instructions=instructions,
|
|
406
|
-
tools=utils.get_pydantic_model(tools,
|
|
416
|
+
tools=utils.get_pydantic_model(tools, Optional[List[models.Tools]]),
|
|
407
417
|
completion_args=utils.get_pydantic_model(
|
|
408
418
|
completion_args, OptionalNullable[models.CompletionArgs]
|
|
409
419
|
),
|
|
410
420
|
name=name,
|
|
411
421
|
description=description,
|
|
422
|
+
metadata=metadata,
|
|
412
423
|
agent_id=agent_id,
|
|
424
|
+
agent_version=agent_version,
|
|
413
425
|
model=model,
|
|
414
426
|
)
|
|
415
427
|
|
|
@@ -477,6 +489,7 @@ class Conversations(BaseSDK):
|
|
|
477
489
|
*,
|
|
478
490
|
page: Optional[int] = 0,
|
|
479
491
|
page_size: Optional[int] = 100,
|
|
492
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
480
493
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
481
494
|
server_url: Optional[str] = None,
|
|
482
495
|
timeout_ms: Optional[int] = None,
|
|
@@ -488,6 +501,7 @@ class Conversations(BaseSDK):
|
|
|
488
501
|
|
|
489
502
|
:param page:
|
|
490
503
|
:param page_size:
|
|
504
|
+
:param metadata:
|
|
491
505
|
:param retries: Override the default retry configuration for this method
|
|
492
506
|
:param server_url: Override the default server URL for this method
|
|
493
507
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -506,6 +520,7 @@ class Conversations(BaseSDK):
|
|
|
506
520
|
request = models.AgentsAPIV1ConversationsListRequest(
|
|
507
521
|
page=page,
|
|
508
522
|
page_size=page_size,
|
|
523
|
+
metadata=metadata,
|
|
509
524
|
)
|
|
510
525
|
|
|
511
526
|
req = self._build_request(
|
|
@@ -569,6 +584,7 @@ class Conversations(BaseSDK):
|
|
|
569
584
|
*,
|
|
570
585
|
page: Optional[int] = 0,
|
|
571
586
|
page_size: Optional[int] = 100,
|
|
587
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
572
588
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
573
589
|
server_url: Optional[str] = None,
|
|
574
590
|
timeout_ms: Optional[int] = None,
|
|
@@ -580,6 +596,7 @@ class Conversations(BaseSDK):
|
|
|
580
596
|
|
|
581
597
|
:param page:
|
|
582
598
|
:param page_size:
|
|
599
|
+
:param metadata:
|
|
583
600
|
:param retries: Override the default retry configuration for this method
|
|
584
601
|
:param server_url: Override the default server URL for this method
|
|
585
602
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -598,6 +615,7 @@ class Conversations(BaseSDK):
|
|
|
598
615
|
request = models.AgentsAPIV1ConversationsListRequest(
|
|
599
616
|
page=page,
|
|
600
617
|
page_size=page_size,
|
|
618
|
+
metadata=metadata,
|
|
601
619
|
)
|
|
602
620
|
|
|
603
621
|
req = self._build_request_async(
|
|
@@ -838,6 +856,184 @@ class Conversations(BaseSDK):
|
|
|
838
856
|
|
|
839
857
|
raise models.SDKError("Unexpected response received", http_res)
|
|
840
858
|
|
|
859
|
+
def delete(
|
|
860
|
+
self,
|
|
861
|
+
*,
|
|
862
|
+
conversation_id: str,
|
|
863
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
864
|
+
server_url: Optional[str] = None,
|
|
865
|
+
timeout_ms: Optional[int] = None,
|
|
866
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
867
|
+
):
|
|
868
|
+
r"""Delete a conversation.
|
|
869
|
+
|
|
870
|
+
Delete a conversation given a conversation_id.
|
|
871
|
+
|
|
872
|
+
:param conversation_id: ID of the conversation from which we are fetching metadata.
|
|
873
|
+
:param retries: Override the default retry configuration for this method
|
|
874
|
+
:param server_url: Override the default server URL for this method
|
|
875
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
876
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
877
|
+
"""
|
|
878
|
+
base_url = None
|
|
879
|
+
url_variables = None
|
|
880
|
+
if timeout_ms is None:
|
|
881
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
882
|
+
|
|
883
|
+
if server_url is not None:
|
|
884
|
+
base_url = server_url
|
|
885
|
+
else:
|
|
886
|
+
base_url = self._get_url(base_url, url_variables)
|
|
887
|
+
|
|
888
|
+
request = models.AgentsAPIV1ConversationsDeleteRequest(
|
|
889
|
+
conversation_id=conversation_id,
|
|
890
|
+
)
|
|
891
|
+
|
|
892
|
+
req = self._build_request(
|
|
893
|
+
method="DELETE",
|
|
894
|
+
path="/v1/conversations/{conversation_id}",
|
|
895
|
+
base_url=base_url,
|
|
896
|
+
url_variables=url_variables,
|
|
897
|
+
request=request,
|
|
898
|
+
request_body_required=False,
|
|
899
|
+
request_has_path_params=True,
|
|
900
|
+
request_has_query_params=True,
|
|
901
|
+
user_agent_header="user-agent",
|
|
902
|
+
accept_header_value="application/json",
|
|
903
|
+
http_headers=http_headers,
|
|
904
|
+
security=self.sdk_configuration.security,
|
|
905
|
+
timeout_ms=timeout_ms,
|
|
906
|
+
)
|
|
907
|
+
|
|
908
|
+
if retries == UNSET:
|
|
909
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
910
|
+
retries = self.sdk_configuration.retry_config
|
|
911
|
+
|
|
912
|
+
retry_config = None
|
|
913
|
+
if isinstance(retries, utils.RetryConfig):
|
|
914
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
915
|
+
|
|
916
|
+
http_res = self.do_request(
|
|
917
|
+
hook_ctx=HookContext(
|
|
918
|
+
config=self.sdk_configuration,
|
|
919
|
+
base_url=base_url or "",
|
|
920
|
+
operation_id="agents_api_v1_conversations_delete",
|
|
921
|
+
oauth2_scopes=[],
|
|
922
|
+
security_source=get_security_from_env(
|
|
923
|
+
self.sdk_configuration.security, models.Security
|
|
924
|
+
),
|
|
925
|
+
),
|
|
926
|
+
request=req,
|
|
927
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
928
|
+
retry_config=retry_config,
|
|
929
|
+
)
|
|
930
|
+
|
|
931
|
+
response_data: Any = None
|
|
932
|
+
if utils.match_response(http_res, "204", "*"):
|
|
933
|
+
return
|
|
934
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
935
|
+
response_data = unmarshal_json_response(
|
|
936
|
+
models.HTTPValidationErrorData, http_res
|
|
937
|
+
)
|
|
938
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
939
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
940
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
941
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
942
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
943
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
944
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
945
|
+
|
|
946
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
947
|
+
|
|
948
|
+
async def delete_async(
|
|
949
|
+
self,
|
|
950
|
+
*,
|
|
951
|
+
conversation_id: str,
|
|
952
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
953
|
+
server_url: Optional[str] = None,
|
|
954
|
+
timeout_ms: Optional[int] = None,
|
|
955
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
956
|
+
):
|
|
957
|
+
r"""Delete a conversation.
|
|
958
|
+
|
|
959
|
+
Delete a conversation given a conversation_id.
|
|
960
|
+
|
|
961
|
+
:param conversation_id: ID of the conversation from which we are fetching metadata.
|
|
962
|
+
:param retries: Override the default retry configuration for this method
|
|
963
|
+
:param server_url: Override the default server URL for this method
|
|
964
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
965
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
966
|
+
"""
|
|
967
|
+
base_url = None
|
|
968
|
+
url_variables = None
|
|
969
|
+
if timeout_ms is None:
|
|
970
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
971
|
+
|
|
972
|
+
if server_url is not None:
|
|
973
|
+
base_url = server_url
|
|
974
|
+
else:
|
|
975
|
+
base_url = self._get_url(base_url, url_variables)
|
|
976
|
+
|
|
977
|
+
request = models.AgentsAPIV1ConversationsDeleteRequest(
|
|
978
|
+
conversation_id=conversation_id,
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
req = self._build_request_async(
|
|
982
|
+
method="DELETE",
|
|
983
|
+
path="/v1/conversations/{conversation_id}",
|
|
984
|
+
base_url=base_url,
|
|
985
|
+
url_variables=url_variables,
|
|
986
|
+
request=request,
|
|
987
|
+
request_body_required=False,
|
|
988
|
+
request_has_path_params=True,
|
|
989
|
+
request_has_query_params=True,
|
|
990
|
+
user_agent_header="user-agent",
|
|
991
|
+
accept_header_value="application/json",
|
|
992
|
+
http_headers=http_headers,
|
|
993
|
+
security=self.sdk_configuration.security,
|
|
994
|
+
timeout_ms=timeout_ms,
|
|
995
|
+
)
|
|
996
|
+
|
|
997
|
+
if retries == UNSET:
|
|
998
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
999
|
+
retries = self.sdk_configuration.retry_config
|
|
1000
|
+
|
|
1001
|
+
retry_config = None
|
|
1002
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1003
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1004
|
+
|
|
1005
|
+
http_res = await self.do_request_async(
|
|
1006
|
+
hook_ctx=HookContext(
|
|
1007
|
+
config=self.sdk_configuration,
|
|
1008
|
+
base_url=base_url or "",
|
|
1009
|
+
operation_id="agents_api_v1_conversations_delete",
|
|
1010
|
+
oauth2_scopes=[],
|
|
1011
|
+
security_source=get_security_from_env(
|
|
1012
|
+
self.sdk_configuration.security, models.Security
|
|
1013
|
+
),
|
|
1014
|
+
),
|
|
1015
|
+
request=req,
|
|
1016
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1017
|
+
retry_config=retry_config,
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
response_data: Any = None
|
|
1021
|
+
if utils.match_response(http_res, "204", "*"):
|
|
1022
|
+
return
|
|
1023
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1024
|
+
response_data = unmarshal_json_response(
|
|
1025
|
+
models.HTTPValidationErrorData, http_res
|
|
1026
|
+
)
|
|
1027
|
+
raise models.HTTPValidationError(response_data, http_res)
|
|
1028
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1029
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1030
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1031
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1032
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1033
|
+
raise models.SDKError("API error occurred", http_res, http_res_text)
|
|
1034
|
+
|
|
1035
|
+
raise models.SDKError("Unexpected response received", http_res)
|
|
1036
|
+
|
|
841
1037
|
def append(
|
|
842
1038
|
self,
|
|
843
1039
|
*,
|
|
@@ -1446,6 +1642,8 @@ class Conversations(BaseSDK):
|
|
|
1446
1642
|
completion_args: Optional[
|
|
1447
1643
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
1448
1644
|
] = None,
|
|
1645
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
1646
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
1449
1647
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1450
1648
|
server_url: Optional[str] = None,
|
|
1451
1649
|
timeout_ms: Optional[int] = None,
|
|
@@ -1462,6 +1660,8 @@ class Conversations(BaseSDK):
|
|
|
1462
1660
|
:param store: Whether to store the results into our servers or not.
|
|
1463
1661
|
:param handoff_execution:
|
|
1464
1662
|
:param completion_args: White-listed arguments from the completion API
|
|
1663
|
+
:param metadata: Custom metadata for the conversation.
|
|
1664
|
+
:param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
|
|
1465
1665
|
:param retries: Override the default retry configuration for this method
|
|
1466
1666
|
:param server_url: Override the default server URL for this method
|
|
1467
1667
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -1487,7 +1687,9 @@ class Conversations(BaseSDK):
|
|
|
1487
1687
|
completion_args=utils.get_pydantic_model(
|
|
1488
1688
|
completion_args, Optional[models.CompletionArgs]
|
|
1489
1689
|
),
|
|
1690
|
+
metadata=metadata,
|
|
1490
1691
|
from_entry_id=from_entry_id,
|
|
1692
|
+
agent_version=agent_version,
|
|
1491
1693
|
),
|
|
1492
1694
|
)
|
|
1493
1695
|
|
|
@@ -1568,6 +1770,8 @@ class Conversations(BaseSDK):
|
|
|
1568
1770
|
completion_args: Optional[
|
|
1569
1771
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
1570
1772
|
] = None,
|
|
1773
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
1774
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
1571
1775
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1572
1776
|
server_url: Optional[str] = None,
|
|
1573
1777
|
timeout_ms: Optional[int] = None,
|
|
@@ -1584,6 +1788,8 @@ class Conversations(BaseSDK):
|
|
|
1584
1788
|
:param store: Whether to store the results into our servers or not.
|
|
1585
1789
|
:param handoff_execution:
|
|
1586
1790
|
:param completion_args: White-listed arguments from the completion API
|
|
1791
|
+
:param metadata: Custom metadata for the conversation.
|
|
1792
|
+
:param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
|
|
1587
1793
|
:param retries: Override the default retry configuration for this method
|
|
1588
1794
|
:param server_url: Override the default server URL for this method
|
|
1589
1795
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -1609,7 +1815,9 @@ class Conversations(BaseSDK):
|
|
|
1609
1815
|
completion_args=utils.get_pydantic_model(
|
|
1610
1816
|
completion_args, Optional[models.CompletionArgs]
|
|
1611
1817
|
),
|
|
1818
|
+
metadata=metadata,
|
|
1612
1819
|
from_entry_id=from_entry_id,
|
|
1820
|
+
agent_version=agent_version,
|
|
1613
1821
|
),
|
|
1614
1822
|
)
|
|
1615
1823
|
|
|
@@ -1686,18 +1894,20 @@ class Conversations(BaseSDK):
|
|
|
1686
1894
|
models.ConversationStreamRequestHandoffExecution
|
|
1687
1895
|
] = UNSET,
|
|
1688
1896
|
instructions: OptionalNullable[str] = UNSET,
|
|
1689
|
-
tools:
|
|
1897
|
+
tools: Optional[
|
|
1690
1898
|
Union[
|
|
1691
1899
|
List[models.ConversationStreamRequestTools],
|
|
1692
1900
|
List[models.ConversationStreamRequestToolsTypedDict],
|
|
1693
1901
|
]
|
|
1694
|
-
] =
|
|
1902
|
+
] = None,
|
|
1695
1903
|
completion_args: OptionalNullable[
|
|
1696
1904
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
1697
1905
|
] = UNSET,
|
|
1698
1906
|
name: OptionalNullable[str] = UNSET,
|
|
1699
1907
|
description: OptionalNullable[str] = UNSET,
|
|
1908
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
1700
1909
|
agent_id: OptionalNullable[str] = UNSET,
|
|
1910
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
1701
1911
|
model: OptionalNullable[str] = UNSET,
|
|
1702
1912
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1703
1913
|
server_url: Optional[str] = None,
|
|
@@ -1713,11 +1923,13 @@ class Conversations(BaseSDK):
|
|
|
1713
1923
|
:param store:
|
|
1714
1924
|
:param handoff_execution:
|
|
1715
1925
|
:param instructions:
|
|
1716
|
-
:param tools:
|
|
1926
|
+
:param tools: List of tools which are available to the model during the conversation.
|
|
1717
1927
|
:param completion_args:
|
|
1718
1928
|
:param name:
|
|
1719
1929
|
:param description:
|
|
1930
|
+
:param metadata:
|
|
1720
1931
|
:param agent_id:
|
|
1932
|
+
:param agent_version:
|
|
1721
1933
|
:param model:
|
|
1722
1934
|
:param retries: Override the default retry configuration for this method
|
|
1723
1935
|
:param server_url: Override the default server URL for this method
|
|
@@ -1741,14 +1953,16 @@ class Conversations(BaseSDK):
|
|
|
1741
1953
|
handoff_execution=handoff_execution,
|
|
1742
1954
|
instructions=instructions,
|
|
1743
1955
|
tools=utils.get_pydantic_model(
|
|
1744
|
-
tools,
|
|
1956
|
+
tools, Optional[List[models.ConversationStreamRequestTools]]
|
|
1745
1957
|
),
|
|
1746
1958
|
completion_args=utils.get_pydantic_model(
|
|
1747
1959
|
completion_args, OptionalNullable[models.CompletionArgs]
|
|
1748
1960
|
),
|
|
1749
1961
|
name=name,
|
|
1750
1962
|
description=description,
|
|
1963
|
+
metadata=metadata,
|
|
1751
1964
|
agent_id=agent_id,
|
|
1965
|
+
agent_version=agent_version,
|
|
1752
1966
|
model=model,
|
|
1753
1967
|
)
|
|
1754
1968
|
|
|
@@ -1828,18 +2042,20 @@ class Conversations(BaseSDK):
|
|
|
1828
2042
|
models.ConversationStreamRequestHandoffExecution
|
|
1829
2043
|
] = UNSET,
|
|
1830
2044
|
instructions: OptionalNullable[str] = UNSET,
|
|
1831
|
-
tools:
|
|
2045
|
+
tools: Optional[
|
|
1832
2046
|
Union[
|
|
1833
2047
|
List[models.ConversationStreamRequestTools],
|
|
1834
2048
|
List[models.ConversationStreamRequestToolsTypedDict],
|
|
1835
2049
|
]
|
|
1836
|
-
] =
|
|
2050
|
+
] = None,
|
|
1837
2051
|
completion_args: OptionalNullable[
|
|
1838
2052
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
1839
2053
|
] = UNSET,
|
|
1840
2054
|
name: OptionalNullable[str] = UNSET,
|
|
1841
2055
|
description: OptionalNullable[str] = UNSET,
|
|
2056
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
1842
2057
|
agent_id: OptionalNullable[str] = UNSET,
|
|
2058
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
1843
2059
|
model: OptionalNullable[str] = UNSET,
|
|
1844
2060
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1845
2061
|
server_url: Optional[str] = None,
|
|
@@ -1855,11 +2071,13 @@ class Conversations(BaseSDK):
|
|
|
1855
2071
|
:param store:
|
|
1856
2072
|
:param handoff_execution:
|
|
1857
2073
|
:param instructions:
|
|
1858
|
-
:param tools:
|
|
2074
|
+
:param tools: List of tools which are available to the model during the conversation.
|
|
1859
2075
|
:param completion_args:
|
|
1860
2076
|
:param name:
|
|
1861
2077
|
:param description:
|
|
2078
|
+
:param metadata:
|
|
1862
2079
|
:param agent_id:
|
|
2080
|
+
:param agent_version:
|
|
1863
2081
|
:param model:
|
|
1864
2082
|
:param retries: Override the default retry configuration for this method
|
|
1865
2083
|
:param server_url: Override the default server URL for this method
|
|
@@ -1883,14 +2101,16 @@ class Conversations(BaseSDK):
|
|
|
1883
2101
|
handoff_execution=handoff_execution,
|
|
1884
2102
|
instructions=instructions,
|
|
1885
2103
|
tools=utils.get_pydantic_model(
|
|
1886
|
-
tools,
|
|
2104
|
+
tools, Optional[List[models.ConversationStreamRequestTools]]
|
|
1887
2105
|
),
|
|
1888
2106
|
completion_args=utils.get_pydantic_model(
|
|
1889
2107
|
completion_args, OptionalNullable[models.CompletionArgs]
|
|
1890
2108
|
),
|
|
1891
2109
|
name=name,
|
|
1892
2110
|
description=description,
|
|
2111
|
+
metadata=metadata,
|
|
1893
2112
|
agent_id=agent_id,
|
|
2113
|
+
agent_version=agent_version,
|
|
1894
2114
|
model=model,
|
|
1895
2115
|
)
|
|
1896
2116
|
|
|
@@ -2226,6 +2446,8 @@ class Conversations(BaseSDK):
|
|
|
2226
2446
|
completion_args: Optional[
|
|
2227
2447
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
2228
2448
|
] = None,
|
|
2449
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
2450
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
2229
2451
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2230
2452
|
server_url: Optional[str] = None,
|
|
2231
2453
|
timeout_ms: Optional[int] = None,
|
|
@@ -2242,6 +2464,8 @@ class Conversations(BaseSDK):
|
|
|
2242
2464
|
:param store: Whether to store the results into our servers or not.
|
|
2243
2465
|
:param handoff_execution:
|
|
2244
2466
|
:param completion_args: White-listed arguments from the completion API
|
|
2467
|
+
:param metadata: Custom metadata for the conversation.
|
|
2468
|
+
:param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
|
|
2245
2469
|
:param retries: Override the default retry configuration for this method
|
|
2246
2470
|
:param server_url: Override the default server URL for this method
|
|
2247
2471
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -2267,7 +2491,9 @@ class Conversations(BaseSDK):
|
|
|
2267
2491
|
completion_args=utils.get_pydantic_model(
|
|
2268
2492
|
completion_args, Optional[models.CompletionArgs]
|
|
2269
2493
|
),
|
|
2494
|
+
metadata=metadata,
|
|
2270
2495
|
from_entry_id=from_entry_id,
|
|
2496
|
+
agent_version=agent_version,
|
|
2271
2497
|
),
|
|
2272
2498
|
)
|
|
2273
2499
|
|
|
@@ -2355,6 +2581,8 @@ class Conversations(BaseSDK):
|
|
|
2355
2581
|
completion_args: Optional[
|
|
2356
2582
|
Union[models.CompletionArgs, models.CompletionArgsTypedDict]
|
|
2357
2583
|
] = None,
|
|
2584
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
2585
|
+
agent_version: OptionalNullable[int] = UNSET,
|
|
2358
2586
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2359
2587
|
server_url: Optional[str] = None,
|
|
2360
2588
|
timeout_ms: Optional[int] = None,
|
|
@@ -2371,6 +2599,8 @@ class Conversations(BaseSDK):
|
|
|
2371
2599
|
:param store: Whether to store the results into our servers or not.
|
|
2372
2600
|
:param handoff_execution:
|
|
2373
2601
|
:param completion_args: White-listed arguments from the completion API
|
|
2602
|
+
:param metadata: Custom metadata for the conversation.
|
|
2603
|
+
:param agent_version: Specific version of the agent to use when restarting. If not provided, uses the current version.
|
|
2374
2604
|
:param retries: Override the default retry configuration for this method
|
|
2375
2605
|
:param server_url: Override the default server URL for this method
|
|
2376
2606
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -2396,7 +2626,9 @@ class Conversations(BaseSDK):
|
|
|
2396
2626
|
completion_args=utils.get_pydantic_model(
|
|
2397
2627
|
completion_args, Optional[models.CompletionArgs]
|
|
2398
2628
|
),
|
|
2629
|
+
metadata=metadata,
|
|
2399
2630
|
from_entry_id=from_entry_id,
|
|
2631
|
+
agent_version=agent_version,
|
|
2400
2632
|
),
|
|
2401
2633
|
)
|
|
2402
2634
|
|