typizer 0.1.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.
Files changed (318) hide show
  1. typizer/__init__.py +8 -0
  2. typizer/api/__init__.py +1 -0
  3. typizer/api/account/__init__.py +1 -0
  4. typizer/api/account/delete_me.py +243 -0
  5. typizer/api/account/get_me.py +192 -0
  6. typizer/api/account/list_sign_ins.py +194 -0
  7. typizer/api/agent/__init__.py +1 -0
  8. typizer/api/agent/create_agent_message.py +290 -0
  9. typizer/api/agent/create_agent_sample_run.py +304 -0
  10. typizer/api/agent/create_agent_thread.py +251 -0
  11. typizer/api/agent/get_agent_thread.py +223 -0
  12. typizer/api/agent/list_agent_threads.py +243 -0
  13. typizer/api/agent/save_agent_thread.py +283 -0
  14. typizer/api/agent/update_agent_thread.py +245 -0
  15. typizer/api/api_keys/__init__.py +1 -0
  16. typizer/api/api_keys/create_api_key.py +235 -0
  17. typizer/api/api_keys/delete_api_key.py +217 -0
  18. typizer/api/api_keys/list_api_keys.py +196 -0
  19. typizer/api/auth/__init__.py +1 -0
  20. typizer/api/auth/start_login.py +209 -0
  21. typizer/api/batches/__init__.py +1 -0
  22. typizer/api/batches/create_batch.py +333 -0
  23. typizer/api/batches/export_batch.py +281 -0
  24. typizer/api/batches/get_batch.py +213 -0
  25. typizer/api/batches/list_batches.py +243 -0
  26. typizer/api/billing/__init__.py +1 -0
  27. typizer/api/billing/create_checkout.py +243 -0
  28. typizer/api/billing/create_contract_request.py +233 -0
  29. typizer/api/billing/create_invoice.py +243 -0
  30. typizer/api/billing/get_act_pdf.py +225 -0
  31. typizer/api/billing/get_balance.py +187 -0
  32. typizer/api/billing/get_billing_profile.py +196 -0
  33. typizer/api/billing/get_company.py +233 -0
  34. typizer/api/billing/get_contract_request_pdf.py +225 -0
  35. typizer/api/billing/get_payment.py +213 -0
  36. typizer/api/billing/get_usage.py +278 -0
  37. typizer/api/billing/list_contract_requests.py +196 -0
  38. typizer/api/billing/list_payments.py +233 -0
  39. typizer/api/billing/suggest_companies.py +214 -0
  40. typizer/api/billing/update_autotopup.py +231 -0
  41. typizer/api/billing/update_billing_profile.py +230 -0
  42. typizer/api/consents/__init__.py +1 -0
  43. typizer/api/consents/create_consent.py +228 -0
  44. typizer/api/consents/get_my_consents.py +210 -0
  45. typizer/api/demo/__init__.py +1 -0
  46. typizer/api/demo/create_demo_run.py +314 -0
  47. typizer/api/demo/get_demo_run.py +249 -0
  48. typizer/api/demo/list_demo_samples.py +159 -0
  49. typizer/api/files/__init__.py +1 -0
  50. typizer/api/files/create_file.py +266 -0
  51. typizer/api/files/delete_file.py +231 -0
  52. typizer/api/files/get_file.py +213 -0
  53. typizer/api/files/get_file_content.py +233 -0
  54. typizer/api/meta/__init__.py +1 -0
  55. typizer/api/meta/get_open_api_document.py +185 -0
  56. typizer/api/organization/__init__.py +1 -0
  57. typizer/api/organization/delete_organization.py +231 -0
  58. typizer/api/organization/get_organization.py +194 -0
  59. typizer/api/organization/update_organization.py +212 -0
  60. typizer/api/runs/__init__.py +1 -0
  61. typizer/api/runs/create_run.py +358 -0
  62. typizer/api/runs/extract.py +350 -0
  63. typizer/api/runs/get_run.py +225 -0
  64. typizer/api/runs/get_run_output.py +286 -0
  65. typizer/api/runs/list_runs.py +362 -0
  66. typizer/api/runs/retry_run.py +275 -0
  67. typizer/api/status/__init__.py +1 -0
  68. typizer/api/status/get_status.py +172 -0
  69. typizer/api/typizers/__init__.py +1 -0
  70. typizer/api/typizers/create_typizer.py +239 -0
  71. typizer/api/typizers/delete_typizer.py +229 -0
  72. typizer/api/typizers/generate_typizer.py +282 -0
  73. typizer/api/typizers/get_typizer.py +213 -0
  74. typizer/api/typizers/get_typizer_version.py +231 -0
  75. typizer/api/typizers/get_typizer_xsd.py +215 -0
  76. typizer/api/typizers/list_typizer_versions.py +256 -0
  77. typizer/api/typizers/list_typizers.py +235 -0
  78. typizer/api/typizers/update_typizer.py +247 -0
  79. typizer/api/webhooks/__init__.py +1 -0
  80. typizer/api/webhooks/create_webhook_endpoint.py +259 -0
  81. typizer/api/webhooks/delete_webhook_endpoint.py +217 -0
  82. typizer/api/webhooks/get_webhook_endpoint.py +217 -0
  83. typizer/api/webhooks/list_webhook_deliveries.py +264 -0
  84. typizer/api/webhooks/list_webhook_endpoints.py +235 -0
  85. typizer/api/webhooks/retry_webhook_delivery.py +254 -0
  86. typizer/api/webhooks/test_webhook_endpoint.py +254 -0
  87. typizer/api/webhooks/update_webhook_endpoint.py +252 -0
  88. typizer/client.py +268 -0
  89. typizer/errors.py +16 -0
  90. typizer/models/__init__.py +449 -0
  91. typizer/models/agent_message.py +103 -0
  92. typizer/models/agent_message_content.py +72 -0
  93. typizer/models/agent_message_object.py +8 -0
  94. typizer/models/agent_message_role.py +10 -0
  95. typizer/models/agent_thread.py +166 -0
  96. typizer/models/agent_thread_draft_schema_type_0.py +47 -0
  97. typizer/models/agent_thread_object.py +8 -0
  98. typizer/models/api_key.py +152 -0
  99. typizer/models/api_key_created_by.py +87 -0
  100. typizer/models/api_key_object.py +8 -0
  101. typizer/models/balance.py +103 -0
  102. typizer/models/balance_lot.py +97 -0
  103. typizer/models/balance_lot_source.py +11 -0
  104. typizer/models/balance_object.py +8 -0
  105. typizer/models/batch.py +146 -0
  106. typizer/models/batch_object.py +8 -0
  107. typizer/models/batch_status.py +9 -0
  108. typizer/models/billing_profile.py +184 -0
  109. typizer/models/billing_profile_autotopup.py +148 -0
  110. typizer/models/billing_profile_object.py +8 -0
  111. typizer/models/checkout.py +69 -0
  112. typizer/models/checkout_request.py +87 -0
  113. typizer/models/checkout_request_autotopup.py +81 -0
  114. typizer/models/checkout_request_package_code.py +12 -0
  115. typizer/models/company.py +139 -0
  116. typizer/models/company_list.py +107 -0
  117. typizer/models/company_list_object.py +8 -0
  118. typizer/models/company_object.py +8 -0
  119. typizer/models/company_status.py +12 -0
  120. typizer/models/company_type.py +9 -0
  121. typizer/models/consent_request.py +61 -0
  122. typizer/models/consent_request_kind.py +9 -0
  123. typizer/models/contract_request.py +211 -0
  124. typizer/models/contract_request_delivery_type_1.py +9 -0
  125. typizer/models/contract_request_delivery_type_2_type_1.py +9 -0
  126. typizer/models/contract_request_delivery_type_3_type_1.py +9 -0
  127. typizer/models/contract_request_edo_type_0.py +112 -0
  128. typizer/models/contract_request_list.py +107 -0
  129. typizer/models/contract_request_list_object.py +8 -0
  130. typizer/models/contract_request_object.py +8 -0
  131. typizer/models/contract_request_status.py +12 -0
  132. typizer/models/create_agent_message_request.py +54 -0
  133. typizer/models/create_agent_thread_request.py +51 -0
  134. typizer/models/create_api_key_request.py +85 -0
  135. typizer/models/create_batch_files_body.py +149 -0
  136. typizer/models/create_batch_files_body_format.py +11 -0
  137. typizer/models/create_batch_files_body_mode.py +9 -0
  138. typizer/models/create_batch_request.py +108 -0
  139. typizer/models/create_batch_request_format.py +11 -0
  140. typizer/models/create_batch_request_metadata.py +52 -0
  141. typizer/models/create_batch_request_mode.py +9 -0
  142. typizer/models/create_demo_run_files_body.py +107 -0
  143. typizer/models/create_demo_run_files_body_consent_pd.py +8 -0
  144. typizer/models/create_file_body.py +75 -0
  145. typizer/models/create_invoice_request.py +63 -0
  146. typizer/models/create_invoice_request_package_code.py +12 -0
  147. typizer/models/create_run_files_body.py +169 -0
  148. typizer/models/create_run_files_body_format.py +11 -0
  149. typizer/models/create_run_files_body_mode.py +9 -0
  150. typizer/models/create_run_request.py +120 -0
  151. typizer/models/create_run_request_format.py +11 -0
  152. typizer/models/create_run_request_metadata.py +53 -0
  153. typizer/models/create_run_request_mode.py +9 -0
  154. typizer/models/create_typizer_request.py +125 -0
  155. typizer/models/create_typizer_request_default_format.py +11 -0
  156. typizer/models/create_typizer_request_mode.py +9 -0
  157. typizer/models/create_typizer_request_schema.py +53 -0
  158. typizer/models/create_webhook_endpoint_request.py +62 -0
  159. typizer/models/created_api_key.py +163 -0
  160. typizer/models/deleted_api_key.py +79 -0
  161. typizer/models/deleted_api_key_object.py +8 -0
  162. typizer/models/deleted_file.py +79 -0
  163. typizer/models/deleted_file_object.py +8 -0
  164. typizer/models/deleted_typizer.py +79 -0
  165. typizer/models/deleted_typizer_object.py +8 -0
  166. typizer/models/deleted_webhook_endpoint.py +79 -0
  167. typizer/models/deleted_webhook_endpoint_object.py +8 -0
  168. typizer/models/demo_run.py +180 -0
  169. typizer/models/demo_run_error_type_0.py +69 -0
  170. typizer/models/demo_run_object.py +8 -0
  171. typizer/models/demo_run_pages.py +76 -0
  172. typizer/models/demo_run_request.py +52 -0
  173. typizer/models/demo_run_request_sample.py +10 -0
  174. typizer/models/demo_run_status.py +11 -0
  175. typizer/models/demo_sample.py +95 -0
  176. typizer/models/demo_sample_id.py +10 -0
  177. typizer/models/demo_sample_list.py +85 -0
  178. typizer/models/demo_sample_list_object.py +8 -0
  179. typizer/models/export_batch_format.py +10 -0
  180. typizer/models/extract_files_body.py +194 -0
  181. typizer/models/extract_files_body_format.py +11 -0
  182. typizer/models/extract_files_body_mode.py +9 -0
  183. typizer/models/extract_request.py +146 -0
  184. typizer/models/extract_request_format.py +11 -0
  185. typizer/models/extract_request_metadata.py +53 -0
  186. typizer/models/extract_request_mode.py +9 -0
  187. typizer/models/extract_request_schema.py +53 -0
  188. typizer/models/file.py +153 -0
  189. typizer/models/file_object.py +8 -0
  190. typizer/models/file_source.py +12 -0
  191. typizer/models/generate_typizer_request.py +51 -0
  192. typizer/models/get_open_api_document_response_200.py +45 -0
  193. typizer/models/get_run_output_format.py +11 -0
  194. typizer/models/get_usage_group_by.py +10 -0
  195. typizer/models/list_agent_threads_response_200.py +107 -0
  196. typizer/models/list_agent_threads_response_200_object.py +8 -0
  197. typizer/models/list_api_keys_response_200.py +107 -0
  198. typizer/models/list_api_keys_response_200_object.py +8 -0
  199. typizer/models/list_batches_response_200.py +107 -0
  200. typizer/models/list_batches_response_200_object.py +8 -0
  201. typizer/models/list_runs_response_200.py +107 -0
  202. typizer/models/list_runs_response_200_object.py +8 -0
  203. typizer/models/list_runs_source.py +12 -0
  204. typizer/models/list_runs_status.py +11 -0
  205. typizer/models/list_typizer_versions_response_200.py +107 -0
  206. typizer/models/list_typizer_versions_response_200_object.py +8 -0
  207. typizer/models/list_typizers_response_200.py +107 -0
  208. typizer/models/list_typizers_response_200_object.py +8 -0
  209. typizer/models/list_webhook_deliveries_response_200.py +107 -0
  210. typizer/models/list_webhook_deliveries_response_200_object.py +8 -0
  211. typizer/models/list_webhook_endpoints_response_200.py +107 -0
  212. typizer/models/list_webhook_endpoints_response_200_object.py +8 -0
  213. typizer/models/login_challenge.py +71 -0
  214. typizer/models/login_challenge_object.py +8 -0
  215. typizer/models/login_start_request.py +94 -0
  216. typizer/models/login_start_request_consents.py +74 -0
  217. typizer/models/login_start_request_consents_pd_processing.py +61 -0
  218. typizer/models/maintenance_event.py +139 -0
  219. typizer/models/maintenance_event_components_item.py +13 -0
  220. typizer/models/maintenance_event_kind.py +9 -0
  221. typizer/models/maintenance_event_object.py +8 -0
  222. typizer/models/maintenance_event_status.py +9 -0
  223. typizer/models/marketing_consent_state.py +102 -0
  224. typizer/models/me.py +226 -0
  225. typizer/models/me_api_key_type_0.py +88 -0
  226. typizer/models/me_auth.py +9 -0
  227. typizer/models/me_features.py +70 -0
  228. typizer/models/me_object.py +8 -0
  229. typizer/models/me_organization.py +69 -0
  230. typizer/models/me_organizations_item.py +79 -0
  231. typizer/models/me_organizations_item_role.py +10 -0
  232. typizer/models/me_role_type_1.py +10 -0
  233. typizer/models/me_role_type_2_type_1.py +10 -0
  234. typizer/models/me_role_type_3_type_1.py +10 -0
  235. typizer/models/me_user_type_0.py +86 -0
  236. typizer/models/my_consents.py +77 -0
  237. typizer/models/my_consents_object.py +8 -0
  238. typizer/models/organization.py +93 -0
  239. typizer/models/organization_object.py +8 -0
  240. typizer/models/organization_settings.py +74 -0
  241. typizer/models/organization_settings_file_retention.py +11 -0
  242. typizer/models/organization_settings_output_retention.py +10 -0
  243. typizer/models/payment.py +231 -0
  244. typizer/models/payment_act_type_0.py +136 -0
  245. typizer/models/payment_act_type_0_edo_type_0.py +112 -0
  246. typizer/models/payment_invoice_type_0.py +121 -0
  247. typizer/models/payment_invoice_type_0_status.py +11 -0
  248. typizer/models/payment_list.py +107 -0
  249. typizer/models/payment_list_object.py +8 -0
  250. typizer/models/payment_method.py +10 -0
  251. typizer/models/payment_object.py +8 -0
  252. typizer/models/payment_status.py +15 -0
  253. typizer/models/problem.py +158 -0
  254. typizer/models/problem_code.py +26 -0
  255. typizer/models/run.py +318 -0
  256. typizer/models/run_error_type_0.py +69 -0
  257. typizer/models/run_fields_type_0.py +45 -0
  258. typizer/models/run_file_type_0.py +69 -0
  259. typizer/models/run_format.py +11 -0
  260. typizer/models/run_metadata.py +45 -0
  261. typizer/models/run_mode.py +9 -0
  262. typizer/models/run_object.py +8 -0
  263. typizer/models/run_pages.py +82 -0
  264. typizer/models/run_source.py +12 -0
  265. typizer/models/run_status.py +11 -0
  266. typizer/models/save_agent_thread_request.py +63 -0
  267. typizer/models/save_agent_thread_response_200.py +47 -0
  268. typizer/models/save_agent_thread_response_201.py +47 -0
  269. typizer/models/scope.py +12 -0
  270. typizer/models/sign_in.py +94 -0
  271. typizer/models/sign_in_list.py +108 -0
  272. typizer/models/sign_in_list_object.py +8 -0
  273. typizer/models/sign_in_object.py +8 -0
  274. typizer/models/status.py +85 -0
  275. typizer/models/status_object.py +8 -0
  276. typizer/models/typizer.py +158 -0
  277. typizer/models/typizer_default_format.py +11 -0
  278. typizer/models/typizer_draft.py +97 -0
  279. typizer/models/typizer_draft_object.py +8 -0
  280. typizer/models/typizer_draft_schema.py +53 -0
  281. typizer/models/typizer_mode.py +9 -0
  282. typizer/models/typizer_object.py +8 -0
  283. typizer/models/typizer_schema.py +47 -0
  284. typizer/models/typizer_version.py +118 -0
  285. typizer/models/typizer_version_object.py +8 -0
  286. typizer/models/typizer_version_schema.py +45 -0
  287. typizer/models/update_agent_thread_request.py +80 -0
  288. typizer/models/update_agent_thread_request_draft_schema.py +53 -0
  289. typizer/models/update_autotopup_request.py +111 -0
  290. typizer/models/update_autotopup_request_consent.py +62 -0
  291. typizer/models/update_autotopup_request_package_code.py +12 -0
  292. typizer/models/update_billing_profile_request.py +127 -0
  293. typizer/models/update_organization_request.py +69 -0
  294. typizer/models/update_organization_request_file_retention.py +11 -0
  295. typizer/models/update_organization_request_output_retention.py +10 -0
  296. typizer/models/update_typizer_request.py +131 -0
  297. typizer/models/update_typizer_request_default_format.py +11 -0
  298. typizer/models/update_typizer_request_mode.py +9 -0
  299. typizer/models/update_typizer_request_schema.py +53 -0
  300. typizer/models/update_webhook_endpoint_request.py +83 -0
  301. typizer/models/update_webhook_endpoint_request_status.py +9 -0
  302. typizer/models/usage.py +119 -0
  303. typizer/models/usage_group_by.py +10 -0
  304. typizer/models/usage_object.py +8 -0
  305. typizer/models/usage_row.py +102 -0
  306. typizer/models/webhook_delivery.py +154 -0
  307. typizer/models/webhook_delivery_object.py +8 -0
  308. typizer/models/webhook_delivery_status.py +10 -0
  309. typizer/models/webhook_endpoint.py +156 -0
  310. typizer/models/webhook_endpoint_object.py +8 -0
  311. typizer/models/webhook_endpoint_status.py +9 -0
  312. typizer/models/webhook_event_type.py +11 -0
  313. typizer/py.typed +1 -0
  314. typizer/types.py +54 -0
  315. typizer-0.1.0.dist-info/METADATA +280 -0
  316. typizer-0.1.0.dist-info/RECORD +318 -0
  317. typizer-0.1.0.dist-info/WHEEL +4 -0
  318. typizer-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,290 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.create_agent_message_request import CreateAgentMessageRequest
10
+ from ...models.problem import Problem
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ id: str,
16
+ *,
17
+ body: CreateAgentMessageRequest,
18
+ typizer_organization: str | Unset = UNSET,
19
+ idempotency_key: str | Unset = UNSET,
20
+ ) -> dict[str, Any]:
21
+ headers: dict[str, Any] = {}
22
+ if not isinstance(typizer_organization, Unset):
23
+ headers["Typizer-Organization"] = typizer_organization
24
+
25
+ if not isinstance(idempotency_key, Unset):
26
+ headers["Idempotency-Key"] = idempotency_key
27
+
28
+ _kwargs: dict[str, Any] = {
29
+ "method": "post",
30
+ "url": "/v1/agent/threads/{id}/messages".format(
31
+ id=quote(str(id), safe=""),
32
+ ),
33
+ }
34
+
35
+ _kwargs["json"] = body.to_dict()
36
+
37
+ headers["Content-Type"] = "application/json"
38
+
39
+ _kwargs["headers"] = headers
40
+ return _kwargs
41
+
42
+
43
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Problem | str | None:
44
+ if response.status_code == 200:
45
+ response_200 = response.text
46
+ return response_200
47
+
48
+ if response.status_code == 400:
49
+ response_400 = Problem.from_dict(response.json())
50
+
51
+ return response_400
52
+
53
+ if response.status_code == 401:
54
+ response_401 = Problem.from_dict(response.json())
55
+
56
+ return response_401
57
+
58
+ if response.status_code == 403:
59
+ response_403 = Problem.from_dict(response.json())
60
+
61
+ return response_403
62
+
63
+ if response.status_code == 404:
64
+ response_404 = Problem.from_dict(response.json())
65
+
66
+ return response_404
67
+
68
+ if response.status_code == 409:
69
+ response_409 = Problem.from_dict(response.json())
70
+
71
+ return response_409
72
+
73
+ if response.status_code == 429:
74
+ response_429 = Problem.from_dict(response.json())
75
+
76
+ return response_429
77
+
78
+ if response.status_code == 500:
79
+ response_500 = Problem.from_dict(response.json())
80
+
81
+ return response_500
82
+
83
+ if response.status_code == 503:
84
+ response_503 = Problem.from_dict(response.json())
85
+
86
+ return response_503
87
+
88
+ if client.raise_on_unexpected_status:
89
+ raise errors.UnexpectedStatus(response.status_code, response.content)
90
+ else:
91
+ return None
92
+
93
+
94
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Problem | str]:
95
+ return Response(
96
+ status_code=HTTPStatus(response.status_code),
97
+ content=response.content,
98
+ headers=response.headers,
99
+ parsed=_parse_response(client=client, response=response),
100
+ )
101
+
102
+
103
+ def sync_detailed(
104
+ id: str,
105
+ *,
106
+ client: AuthenticatedClient,
107
+ body: CreateAgentMessageRequest,
108
+ typizer_organization: str | Unset = UNSET,
109
+ idempotency_key: str | Unset = UNSET,
110
+ ) -> Response[Problem | str]:
111
+ """Отправить сообщение; ассистент отвечает потоком server-sent events
112
+
113
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Расходует одну единицу
114
+ дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх квоты 429
115
+ с Retry-After до открытия потока). Стоимость модели ассистента также ограничена на пользователя и на
116
+ организацию за сутки по Москве: когда лимит исчерпан, 429 до открытия потока или событие error с
117
+ 429, завершающее текущий ход. Одно сообщение за раз в диалоге: 409 conflict, пока ассистент отвечает
118
+ на предыдущее. Ответ — text/event-stream с событиями message_start, text_delta, tool_call,
119
+ tool_result, schema_updated, sample_run, ask_user, error (ошибка в формате problem) и последним
120
+ message_end (stop_reason: end_turn, ask_user, max_steps или aborted); комментарий : ping каждые 15
121
+ с. Ход длится не больше 300 с. Idempotency-Key принимается и игнорируется.
122
+
123
+ Доступ: только сессия.
124
+
125
+ Args:
126
+ id (str): Example: thr_….
127
+ typizer_organization (str | Unset):
128
+ idempotency_key (str | Unset):
129
+ body (CreateAgentMessageRequest):
130
+
131
+ Raises:
132
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
133
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
134
+
135
+ Returns:
136
+ Response[Problem | str]
137
+ """
138
+
139
+ kwargs = _get_kwargs(
140
+ id=id,
141
+ body=body,
142
+ typizer_organization=typizer_organization,
143
+ idempotency_key=idempotency_key,
144
+ )
145
+
146
+ response = client.get_httpx_client().request(
147
+ **kwargs,
148
+ )
149
+
150
+ return _build_response(client=client, response=response)
151
+
152
+
153
+ def sync(
154
+ id: str,
155
+ *,
156
+ client: AuthenticatedClient,
157
+ body: CreateAgentMessageRequest,
158
+ typizer_organization: str | Unset = UNSET,
159
+ idempotency_key: str | Unset = UNSET,
160
+ ) -> Problem | str | None:
161
+ """Отправить сообщение; ассистент отвечает потоком server-sent events
162
+
163
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Расходует одну единицу
164
+ дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх квоты 429
165
+ с Retry-After до открытия потока). Стоимость модели ассистента также ограничена на пользователя и на
166
+ организацию за сутки по Москве: когда лимит исчерпан, 429 до открытия потока или событие error с
167
+ 429, завершающее текущий ход. Одно сообщение за раз в диалоге: 409 conflict, пока ассистент отвечает
168
+ на предыдущее. Ответ — text/event-stream с событиями message_start, text_delta, tool_call,
169
+ tool_result, schema_updated, sample_run, ask_user, error (ошибка в формате problem) и последним
170
+ message_end (stop_reason: end_turn, ask_user, max_steps или aborted); комментарий : ping каждые 15
171
+ с. Ход длится не больше 300 с. Idempotency-Key принимается и игнорируется.
172
+
173
+ Доступ: только сессия.
174
+
175
+ Args:
176
+ id (str): Example: thr_….
177
+ typizer_organization (str | Unset):
178
+ idempotency_key (str | Unset):
179
+ body (CreateAgentMessageRequest):
180
+
181
+ Raises:
182
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
183
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
184
+
185
+ Returns:
186
+ Problem | str
187
+ """
188
+
189
+ return sync_detailed(
190
+ id=id,
191
+ client=client,
192
+ body=body,
193
+ typizer_organization=typizer_organization,
194
+ idempotency_key=idempotency_key,
195
+ ).parsed
196
+
197
+
198
+ async def asyncio_detailed(
199
+ id: str,
200
+ *,
201
+ client: AuthenticatedClient,
202
+ body: CreateAgentMessageRequest,
203
+ typizer_organization: str | Unset = UNSET,
204
+ idempotency_key: str | Unset = UNSET,
205
+ ) -> Response[Problem | str]:
206
+ """Отправить сообщение; ассистент отвечает потоком server-sent events
207
+
208
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Расходует одну единицу
209
+ дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх квоты 429
210
+ с Retry-After до открытия потока). Стоимость модели ассистента также ограничена на пользователя и на
211
+ организацию за сутки по Москве: когда лимит исчерпан, 429 до открытия потока или событие error с
212
+ 429, завершающее текущий ход. Одно сообщение за раз в диалоге: 409 conflict, пока ассистент отвечает
213
+ на предыдущее. Ответ — text/event-stream с событиями message_start, text_delta, tool_call,
214
+ tool_result, schema_updated, sample_run, ask_user, error (ошибка в формате problem) и последним
215
+ message_end (stop_reason: end_turn, ask_user, max_steps или aborted); комментарий : ping каждые 15
216
+ с. Ход длится не больше 300 с. Idempotency-Key принимается и игнорируется.
217
+
218
+ Доступ: только сессия.
219
+
220
+ Args:
221
+ id (str): Example: thr_….
222
+ typizer_organization (str | Unset):
223
+ idempotency_key (str | Unset):
224
+ body (CreateAgentMessageRequest):
225
+
226
+ Raises:
227
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
228
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
229
+
230
+ Returns:
231
+ Response[Problem | str]
232
+ """
233
+
234
+ kwargs = _get_kwargs(
235
+ id=id,
236
+ body=body,
237
+ typizer_organization=typizer_organization,
238
+ idempotency_key=idempotency_key,
239
+ )
240
+
241
+ response = await client.get_async_httpx_client().request(**kwargs)
242
+
243
+ return _build_response(client=client, response=response)
244
+
245
+
246
+ async def asyncio(
247
+ id: str,
248
+ *,
249
+ client: AuthenticatedClient,
250
+ body: CreateAgentMessageRequest,
251
+ typizer_organization: str | Unset = UNSET,
252
+ idempotency_key: str | Unset = UNSET,
253
+ ) -> Problem | str | None:
254
+ """Отправить сообщение; ассистент отвечает потоком server-sent events
255
+
256
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Расходует одну единицу
257
+ дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх квоты 429
258
+ с Retry-After до открытия потока). Стоимость модели ассистента также ограничена на пользователя и на
259
+ организацию за сутки по Москве: когда лимит исчерпан, 429 до открытия потока или событие error с
260
+ 429, завершающее текущий ход. Одно сообщение за раз в диалоге: 409 conflict, пока ассистент отвечает
261
+ на предыдущее. Ответ — text/event-stream с событиями message_start, text_delta, tool_call,
262
+ tool_result, schema_updated, sample_run, ask_user, error (ошибка в формате problem) и последним
263
+ message_end (stop_reason: end_turn, ask_user, max_steps или aborted); комментарий : ping каждые 15
264
+ с. Ход длится не больше 300 с. Idempotency-Key принимается и игнорируется.
265
+
266
+ Доступ: только сессия.
267
+
268
+ Args:
269
+ id (str): Example: thr_….
270
+ typizer_organization (str | Unset):
271
+ idempotency_key (str | Unset):
272
+ body (CreateAgentMessageRequest):
273
+
274
+ Raises:
275
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
276
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
277
+
278
+ Returns:
279
+ Problem | str
280
+ """
281
+
282
+ return (
283
+ await asyncio_detailed(
284
+ id=id,
285
+ client=client,
286
+ body=body,
287
+ typizer_organization=typizer_organization,
288
+ idempotency_key=idempotency_key,
289
+ )
290
+ ).parsed
@@ -0,0 +1,304 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.problem import Problem
10
+ from ...models.run import Run
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ id: str,
16
+ *,
17
+ wait: int | None | Unset = UNSET,
18
+ typizer_organization: str | Unset = UNSET,
19
+ idempotency_key: str | Unset = UNSET,
20
+ ) -> dict[str, Any]:
21
+ headers: dict[str, Any] = {}
22
+ if not isinstance(typizer_organization, Unset):
23
+ headers["Typizer-Organization"] = typizer_organization
24
+
25
+ if not isinstance(idempotency_key, Unset):
26
+ headers["Idempotency-Key"] = idempotency_key
27
+
28
+ params: dict[str, Any] = {}
29
+
30
+ json_wait: int | None | Unset
31
+ if isinstance(wait, Unset):
32
+ json_wait = UNSET
33
+ else:
34
+ json_wait = wait
35
+ params["wait"] = json_wait
36
+
37
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
38
+
39
+ _kwargs: dict[str, Any] = {
40
+ "method": "post",
41
+ "url": "/v1/agent/threads/{id}/sample_runs".format(
42
+ id=quote(str(id), safe=""),
43
+ ),
44
+ "params": params,
45
+ }
46
+
47
+ _kwargs["headers"] = headers
48
+ return _kwargs
49
+
50
+
51
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Problem | Run | None:
52
+ if response.status_code == 200:
53
+ response_200 = Run.from_dict(response.json())
54
+
55
+ return response_200
56
+
57
+ if response.status_code == 202:
58
+ response_202 = Run.from_dict(response.json())
59
+
60
+ return response_202
61
+
62
+ if response.status_code == 400:
63
+ response_400 = Problem.from_dict(response.json())
64
+
65
+ return response_400
66
+
67
+ if response.status_code == 401:
68
+ response_401 = Problem.from_dict(response.json())
69
+
70
+ return response_401
71
+
72
+ if response.status_code == 403:
73
+ response_403 = Problem.from_dict(response.json())
74
+
75
+ return response_403
76
+
77
+ if response.status_code == 404:
78
+ response_404 = Problem.from_dict(response.json())
79
+
80
+ return response_404
81
+
82
+ if response.status_code == 409:
83
+ response_409 = Problem.from_dict(response.json())
84
+
85
+ return response_409
86
+
87
+ if response.status_code == 429:
88
+ response_429 = Problem.from_dict(response.json())
89
+
90
+ return response_429
91
+
92
+ if response.status_code == 500:
93
+ response_500 = Problem.from_dict(response.json())
94
+
95
+ return response_500
96
+
97
+ if response.status_code == 503:
98
+ response_503 = Problem.from_dict(response.json())
99
+
100
+ return response_503
101
+
102
+ if client.raise_on_unexpected_status:
103
+ raise errors.UnexpectedStatus(response.status_code, response.content)
104
+ else:
105
+ return None
106
+
107
+
108
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Problem | Run]:
109
+ return Response(
110
+ status_code=HTTPStatus(response.status_code),
111
+ content=response.content,
112
+ headers=response.headers,
113
+ parsed=_parse_response(client=client, response=response),
114
+ )
115
+
116
+
117
+ def sync_detailed(
118
+ id: str,
119
+ *,
120
+ client: AuthenticatedClient,
121
+ wait: int | None | Unset = UNSET,
122
+ typizer_organization: str | Unset = UNSET,
123
+ idempotency_key: str | Unset = UNSET,
124
+ ) -> Response[Problem | Run]:
125
+ """Запустить черновик на образце (бесплатно)
126
+
127
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Запускает черновик схемы
128
+ на образце диалога (source agent); страницы не резервируются и не списываются. Расходует одну
129
+ единицу дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх
130
+ квоты 429 с Retry-After). 409 conflict без черновика или образца; 400 too_many_pages для образца
131
+ больше 10 страниц. Отвечает так же, как создание прогона. Поддерживает Idempotency-Key.
132
+
133
+ Доступ: только сессия.
134
+
135
+ Args:
136
+ id (str): Example: thr_….
137
+ wait (int | None | Unset): Сколько секунд (0–60) держать запрос до завершения прогона: 200
138
+ с завершённым прогоном или 202 с его текущим состоянием, когда время вышло. Если при
139
+ создании прогона очередь была ненадолго недоступна, прогон автоматически ставится в
140
+ очередь снова и стартует примерно в течение 15 минут; ожидание тогда просто заканчивается
141
+ ответом 202. Example: 60.
142
+ typizer_organization (str | Unset):
143
+ idempotency_key (str | Unset):
144
+
145
+ Raises:
146
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
147
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
148
+
149
+ Returns:
150
+ Response[Problem | Run]
151
+ """
152
+
153
+ kwargs = _get_kwargs(
154
+ id=id,
155
+ wait=wait,
156
+ typizer_organization=typizer_organization,
157
+ idempotency_key=idempotency_key,
158
+ )
159
+
160
+ response = client.get_httpx_client().request(
161
+ **kwargs,
162
+ )
163
+
164
+ return _build_response(client=client, response=response)
165
+
166
+
167
+ def sync(
168
+ id: str,
169
+ *,
170
+ client: AuthenticatedClient,
171
+ wait: int | None | Unset = UNSET,
172
+ typizer_organization: str | Unset = UNSET,
173
+ idempotency_key: str | Unset = UNSET,
174
+ ) -> Problem | Run | None:
175
+ """Запустить черновик на образце (бесплатно)
176
+
177
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Запускает черновик схемы
178
+ на образце диалога (source agent); страницы не резервируются и не списываются. Расходует одну
179
+ единицу дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх
180
+ квоты 429 с Retry-After). 409 conflict без черновика или образца; 400 too_many_pages для образца
181
+ больше 10 страниц. Отвечает так же, как создание прогона. Поддерживает Idempotency-Key.
182
+
183
+ Доступ: только сессия.
184
+
185
+ Args:
186
+ id (str): Example: thr_….
187
+ wait (int | None | Unset): Сколько секунд (0–60) держать запрос до завершения прогона: 200
188
+ с завершённым прогоном или 202 с его текущим состоянием, когда время вышло. Если при
189
+ создании прогона очередь была ненадолго недоступна, прогон автоматически ставится в
190
+ очередь снова и стартует примерно в течение 15 минут; ожидание тогда просто заканчивается
191
+ ответом 202. Example: 60.
192
+ typizer_organization (str | Unset):
193
+ idempotency_key (str | Unset):
194
+
195
+ Raises:
196
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
197
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
198
+
199
+ Returns:
200
+ Problem | Run
201
+ """
202
+
203
+ return sync_detailed(
204
+ id=id,
205
+ client=client,
206
+ wait=wait,
207
+ typizer_organization=typizer_organization,
208
+ idempotency_key=idempotency_key,
209
+ ).parsed
210
+
211
+
212
+ async def asyncio_detailed(
213
+ id: str,
214
+ *,
215
+ client: AuthenticatedClient,
216
+ wait: int | None | Unset = UNSET,
217
+ typizer_organization: str | Unset = UNSET,
218
+ idempotency_key: str | Unset = UNSET,
219
+ ) -> Response[Problem | Run]:
220
+ """Запустить черновик на образце (бесплатно)
221
+
222
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Запускает черновик схемы
223
+ на образце диалога (source agent); страницы не резервируются и не списываются. Расходует одну
224
+ единицу дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх
225
+ квоты 429 с Retry-After). 409 conflict без черновика или образца; 400 too_many_pages для образца
226
+ больше 10 страниц. Отвечает так же, как создание прогона. Поддерживает Idempotency-Key.
227
+
228
+ Доступ: только сессия.
229
+
230
+ Args:
231
+ id (str): Example: thr_….
232
+ wait (int | None | Unset): Сколько секунд (0–60) держать запрос до завершения прогона: 200
233
+ с завершённым прогоном или 202 с его текущим состоянием, когда время вышло. Если при
234
+ создании прогона очередь была ненадолго недоступна, прогон автоматически ставится в
235
+ очередь снова и стартует примерно в течение 15 минут; ожидание тогда просто заканчивается
236
+ ответом 202. Example: 60.
237
+ typizer_organization (str | Unset):
238
+ idempotency_key (str | Unset):
239
+
240
+ Raises:
241
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
242
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
243
+
244
+ Returns:
245
+ Response[Problem | Run]
246
+ """
247
+
248
+ kwargs = _get_kwargs(
249
+ id=id,
250
+ wait=wait,
251
+ typizer_organization=typizer_organization,
252
+ idempotency_key=idempotency_key,
253
+ )
254
+
255
+ response = await client.get_async_httpx_client().request(**kwargs)
256
+
257
+ return _build_response(client=client, response=response)
258
+
259
+
260
+ async def asyncio(
261
+ id: str,
262
+ *,
263
+ client: AuthenticatedClient,
264
+ wait: int | None | Unset = UNSET,
265
+ typizer_organization: str | Unset = UNSET,
266
+ idempotency_key: str | Unset = UNSET,
267
+ ) -> Problem | Run | None:
268
+ """Запустить черновик на образце (бесплатно)
269
+
270
+ Только сессия (любая роль); диалог виден пользователю, который его начал. Запускает черновик схемы
271
+ на образце диалога (source agent); страницы не резервируются и не списываются. Расходует одну
272
+ единицу дневной квоты ассистента (100 на организацию и 100 на пользователя, сутки по Москве; сверх
273
+ квоты 429 с Retry-After). 409 conflict без черновика или образца; 400 too_many_pages для образца
274
+ больше 10 страниц. Отвечает так же, как создание прогона. Поддерживает Idempotency-Key.
275
+
276
+ Доступ: только сессия.
277
+
278
+ Args:
279
+ id (str): Example: thr_….
280
+ wait (int | None | Unset): Сколько секунд (0–60) держать запрос до завершения прогона: 200
281
+ с завершённым прогоном или 202 с его текущим состоянием, когда время вышло. Если при
282
+ создании прогона очередь была ненадолго недоступна, прогон автоматически ставится в
283
+ очередь снова и стартует примерно в течение 15 минут; ожидание тогда просто заканчивается
284
+ ответом 202. Example: 60.
285
+ typizer_organization (str | Unset):
286
+ idempotency_key (str | Unset):
287
+
288
+ Raises:
289
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
290
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
291
+
292
+ Returns:
293
+ Problem | Run
294
+ """
295
+
296
+ return (
297
+ await asyncio_detailed(
298
+ id=id,
299
+ client=client,
300
+ wait=wait,
301
+ typizer_organization=typizer_organization,
302
+ idempotency_key=idempotency_key,
303
+ )
304
+ ).parsed