opik 1.9.5__py3-none-any.whl → 1.9.39__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 (248) hide show
  1. opik/__init__.py +10 -3
  2. opik/anonymizer/__init__.py +5 -0
  3. opik/anonymizer/anonymizer.py +12 -0
  4. opik/anonymizer/factory.py +80 -0
  5. opik/anonymizer/recursive_anonymizer.py +64 -0
  6. opik/anonymizer/rules.py +56 -0
  7. opik/anonymizer/rules_anonymizer.py +35 -0
  8. opik/api_objects/dataset/rest_operations.py +5 -0
  9. opik/api_objects/experiment/experiment.py +46 -49
  10. opik/api_objects/experiment/helpers.py +34 -10
  11. opik/api_objects/local_recording.py +8 -3
  12. opik/api_objects/opik_client.py +230 -48
  13. opik/api_objects/opik_query_language.py +9 -0
  14. opik/api_objects/prompt/__init__.py +11 -3
  15. opik/api_objects/prompt/base_prompt.py +69 -0
  16. opik/api_objects/prompt/base_prompt_template.py +29 -0
  17. opik/api_objects/prompt/chat/__init__.py +1 -0
  18. opik/api_objects/prompt/chat/chat_prompt.py +193 -0
  19. opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
  20. opik/api_objects/prompt/{chat_content_renderer_registry.py → chat/content_renderer_registry.py} +37 -35
  21. opik/api_objects/prompt/client.py +101 -30
  22. opik/api_objects/prompt/text/__init__.py +1 -0
  23. opik/api_objects/prompt/text/prompt.py +174 -0
  24. opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +10 -6
  25. opik/api_objects/prompt/types.py +1 -1
  26. opik/cli/export.py +6 -2
  27. opik/cli/usage_report/charts.py +39 -10
  28. opik/cli/usage_report/cli.py +164 -45
  29. opik/cli/usage_report/pdf.py +14 -1
  30. opik/config.py +0 -5
  31. opik/decorator/base_track_decorator.py +37 -40
  32. opik/decorator/context_manager/span_context_manager.py +9 -0
  33. opik/decorator/context_manager/trace_context_manager.py +5 -0
  34. opik/dict_utils.py +3 -3
  35. opik/evaluation/__init__.py +13 -2
  36. opik/evaluation/engine/engine.py +195 -223
  37. opik/evaluation/engine/helpers.py +8 -7
  38. opik/evaluation/engine/metrics_evaluator.py +237 -0
  39. opik/evaluation/evaluation_result.py +35 -1
  40. opik/evaluation/evaluator.py +318 -30
  41. opik/evaluation/models/litellm/util.py +78 -6
  42. opik/evaluation/models/model_capabilities.py +33 -0
  43. opik/evaluation/report.py +14 -2
  44. opik/evaluation/rest_operations.py +36 -33
  45. opik/evaluation/test_case.py +2 -2
  46. opik/evaluation/types.py +9 -1
  47. opik/exceptions.py +17 -0
  48. opik/hooks/__init__.py +17 -1
  49. opik/hooks/anonymizer_hook.py +36 -0
  50. opik/id_helpers.py +18 -0
  51. opik/integrations/adk/helpers.py +16 -7
  52. opik/integrations/adk/legacy_opik_tracer.py +7 -4
  53. opik/integrations/adk/opik_tracer.py +3 -1
  54. opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
  55. opik/integrations/adk/recursive_callback_injector.py +1 -6
  56. opik/integrations/dspy/callback.py +1 -4
  57. opik/integrations/haystack/opik_connector.py +2 -2
  58. opik/integrations/haystack/opik_tracer.py +2 -4
  59. opik/integrations/langchain/opik_tracer.py +273 -82
  60. opik/integrations/llama_index/callback.py +110 -108
  61. opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
  62. opik/integrations/openai/opik_tracker.py +1 -1
  63. opik/message_processing/batching/batchers.py +11 -7
  64. opik/message_processing/encoder_helpers.py +79 -0
  65. opik/message_processing/messages.py +25 -1
  66. opik/message_processing/online_message_processor.py +23 -8
  67. opik/opik_context.py +7 -7
  68. opik/rest_api/__init__.py +188 -12
  69. opik/rest_api/client.py +3 -0
  70. opik/rest_api/dashboards/__init__.py +4 -0
  71. opik/rest_api/dashboards/client.py +462 -0
  72. opik/rest_api/dashboards/raw_client.py +648 -0
  73. opik/rest_api/datasets/client.py +893 -89
  74. opik/rest_api/datasets/raw_client.py +1328 -87
  75. opik/rest_api/experiments/client.py +30 -2
  76. opik/rest_api/experiments/raw_client.py +26 -0
  77. opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -1
  78. opik/rest_api/optimizations/client.py +302 -0
  79. opik/rest_api/optimizations/raw_client.py +463 -0
  80. opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
  81. opik/rest_api/prompts/__init__.py +2 -2
  82. opik/rest_api/prompts/client.py +34 -4
  83. opik/rest_api/prompts/raw_client.py +32 -2
  84. opik/rest_api/prompts/types/__init__.py +3 -1
  85. opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
  86. opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
  87. opik/rest_api/spans/__init__.py +0 -2
  88. opik/rest_api/spans/client.py +148 -64
  89. opik/rest_api/spans/raw_client.py +210 -83
  90. opik/rest_api/spans/types/__init__.py +0 -2
  91. opik/rest_api/traces/client.py +241 -73
  92. opik/rest_api/traces/raw_client.py +344 -90
  93. opik/rest_api/types/__init__.py +200 -15
  94. opik/rest_api/types/aggregation_data.py +1 -0
  95. opik/rest_api/types/alert_trigger_config_public_type.py +6 -1
  96. opik/rest_api/types/alert_trigger_config_type.py +6 -1
  97. opik/rest_api/types/alert_trigger_config_write_type.py +6 -1
  98. opik/rest_api/types/automation_rule_evaluator.py +23 -1
  99. opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
  100. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
  101. opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
  102. opik/rest_api/types/{automation_rule_evaluator_object_public.py → automation_rule_evaluator_object_object_public.py} +32 -10
  103. opik/rest_api/types/automation_rule_evaluator_page_public.py +2 -2
  104. opik/rest_api/types/automation_rule_evaluator_public.py +23 -1
  105. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
  106. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
  107. opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
  108. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
  109. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
  110. opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
  111. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
  112. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
  113. opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
  114. opik/rest_api/types/automation_rule_evaluator_update.py +23 -1
  115. opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
  116. opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
  117. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
  118. opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
  119. opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
  120. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
  121. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
  122. opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
  123. opik/rest_api/types/automation_rule_evaluator_write.py +23 -1
  124. opik/rest_api/types/boolean_feedback_definition.py +25 -0
  125. opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
  126. opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
  127. opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
  128. opik/rest_api/types/boolean_feedback_detail.py +29 -0
  129. opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
  130. opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
  131. opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
  132. opik/rest_api/types/dashboard_page_public.py +24 -0
  133. opik/rest_api/types/dashboard_public.py +30 -0
  134. opik/rest_api/types/dataset.py +2 -0
  135. opik/rest_api/types/dataset_item.py +2 -0
  136. opik/rest_api/types/dataset_item_compare.py +2 -0
  137. opik/rest_api/types/dataset_item_filter.py +23 -0
  138. opik/rest_api/types/dataset_item_filter_operator.py +21 -0
  139. opik/rest_api/types/dataset_item_page_compare.py +1 -0
  140. opik/rest_api/types/dataset_item_page_public.py +1 -0
  141. opik/rest_api/types/dataset_item_public.py +2 -0
  142. opik/rest_api/types/dataset_item_update.py +39 -0
  143. opik/rest_api/types/dataset_item_write.py +1 -0
  144. opik/rest_api/types/dataset_public.py +2 -0
  145. opik/rest_api/types/dataset_public_status.py +5 -0
  146. opik/rest_api/types/dataset_status.py +5 -0
  147. opik/rest_api/types/dataset_version_diff.py +22 -0
  148. opik/rest_api/types/dataset_version_diff_stats.py +24 -0
  149. opik/rest_api/types/dataset_version_page_public.py +23 -0
  150. opik/rest_api/types/dataset_version_public.py +49 -0
  151. opik/rest_api/types/experiment.py +2 -0
  152. opik/rest_api/types/experiment_public.py +2 -0
  153. opik/rest_api/types/experiment_score.py +20 -0
  154. opik/rest_api/types/experiment_score_public.py +20 -0
  155. opik/rest_api/types/experiment_score_write.py +20 -0
  156. opik/rest_api/types/feedback.py +20 -1
  157. opik/rest_api/types/feedback_create.py +16 -1
  158. opik/rest_api/types/feedback_object_public.py +22 -1
  159. opik/rest_api/types/feedback_public.py +20 -1
  160. opik/rest_api/types/feedback_score_public.py +4 -0
  161. opik/rest_api/types/feedback_update.py +16 -1
  162. opik/rest_api/types/image_url.py +20 -0
  163. opik/rest_api/types/image_url_public.py +20 -0
  164. opik/rest_api/types/image_url_write.py +20 -0
  165. opik/rest_api/types/llm_as_judge_message.py +5 -1
  166. opik/rest_api/types/llm_as_judge_message_content.py +24 -0
  167. opik/rest_api/types/llm_as_judge_message_content_public.py +24 -0
  168. opik/rest_api/types/llm_as_judge_message_content_write.py +24 -0
  169. opik/rest_api/types/llm_as_judge_message_public.py +5 -1
  170. opik/rest_api/types/llm_as_judge_message_write.py +5 -1
  171. opik/rest_api/types/llm_as_judge_model_parameters.py +2 -0
  172. opik/rest_api/types/llm_as_judge_model_parameters_public.py +2 -0
  173. opik/rest_api/types/llm_as_judge_model_parameters_write.py +2 -0
  174. opik/rest_api/types/optimization.py +2 -0
  175. opik/rest_api/types/optimization_public.py +2 -0
  176. opik/rest_api/types/optimization_public_status.py +3 -1
  177. opik/rest_api/types/optimization_status.py +3 -1
  178. opik/rest_api/types/optimization_studio_config.py +27 -0
  179. opik/rest_api/types/optimization_studio_config_public.py +27 -0
  180. opik/rest_api/types/optimization_studio_config_write.py +27 -0
  181. opik/rest_api/types/optimization_studio_log.py +22 -0
  182. opik/rest_api/types/optimization_write.py +2 -0
  183. opik/rest_api/types/optimization_write_status.py +3 -1
  184. opik/rest_api/types/prompt.py +6 -0
  185. opik/rest_api/types/prompt_detail.py +6 -0
  186. opik/rest_api/types/prompt_detail_template_structure.py +5 -0
  187. opik/rest_api/types/prompt_public.py +6 -0
  188. opik/rest_api/types/prompt_public_template_structure.py +5 -0
  189. opik/rest_api/types/prompt_template_structure.py +5 -0
  190. opik/rest_api/types/prompt_version.py +2 -0
  191. opik/rest_api/types/prompt_version_detail.py +2 -0
  192. opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
  193. opik/rest_api/types/prompt_version_public.py +2 -0
  194. opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
  195. opik/rest_api/types/prompt_version_template_structure.py +5 -0
  196. opik/rest_api/types/score_name.py +1 -0
  197. opik/rest_api/types/service_toggles_config.py +6 -0
  198. opik/rest_api/types/span_enrichment_options.py +31 -0
  199. opik/rest_api/types/span_filter.py +23 -0
  200. opik/rest_api/types/span_filter_operator.py +21 -0
  201. opik/rest_api/types/span_filter_write.py +23 -0
  202. opik/rest_api/types/span_filter_write_operator.py +21 -0
  203. opik/rest_api/types/span_llm_as_judge_code.py +27 -0
  204. opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
  205. opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
  206. opik/rest_api/types/span_update.py +46 -0
  207. opik/rest_api/types/studio_evaluation.py +20 -0
  208. opik/rest_api/types/studio_evaluation_public.py +20 -0
  209. opik/rest_api/types/studio_evaluation_write.py +20 -0
  210. opik/rest_api/types/studio_llm_model.py +21 -0
  211. opik/rest_api/types/studio_llm_model_public.py +21 -0
  212. opik/rest_api/types/studio_llm_model_write.py +21 -0
  213. opik/rest_api/types/studio_message.py +20 -0
  214. opik/rest_api/types/studio_message_public.py +20 -0
  215. opik/rest_api/types/studio_message_write.py +20 -0
  216. opik/rest_api/types/studio_metric.py +21 -0
  217. opik/rest_api/types/studio_metric_public.py +21 -0
  218. opik/rest_api/types/studio_metric_write.py +21 -0
  219. opik/rest_api/types/studio_optimizer.py +21 -0
  220. opik/rest_api/types/studio_optimizer_public.py +21 -0
  221. opik/rest_api/types/studio_optimizer_write.py +21 -0
  222. opik/rest_api/types/studio_prompt.py +20 -0
  223. opik/rest_api/types/studio_prompt_public.py +20 -0
  224. opik/rest_api/types/studio_prompt_write.py +20 -0
  225. opik/rest_api/types/trace.py +6 -0
  226. opik/rest_api/types/trace_public.py +6 -0
  227. opik/rest_api/types/trace_thread_filter_write.py +23 -0
  228. opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
  229. opik/rest_api/types/trace_thread_update.py +19 -0
  230. opik/rest_api/types/trace_update.py +39 -0
  231. opik/rest_api/types/value_entry.py +2 -0
  232. opik/rest_api/types/value_entry_compare.py +2 -0
  233. opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
  234. opik/rest_api/types/value_entry_public.py +2 -0
  235. opik/rest_api/types/video_url.py +19 -0
  236. opik/rest_api/types/video_url_public.py +19 -0
  237. opik/rest_api/types/video_url_write.py +19 -0
  238. opik/synchronization.py +5 -6
  239. opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
  240. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/METADATA +5 -4
  241. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/RECORD +246 -151
  242. opik/api_objects/prompt/chat_prompt_template.py +0 -164
  243. opik/api_objects/prompt/prompt.py +0 -131
  244. /opik/rest_api/{spans/types → types}/span_update_type.py +0 -0
  245. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/WHEEL +0 -0
  246. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/entry_points.txt +0 -0
  247. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/licenses/LICENSE +0 -0
  248. {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/top_level.txt +0 -0
@@ -13,9 +13,12 @@ from ..core.request_options import RequestOptions
13
13
  from ..core.serialization import convert_and_respect_annotation_metadata
14
14
  from ..errors.bad_request_error import BadRequestError
15
15
  from ..errors.not_found_error import NotFoundError
16
+ from ..errors.not_implemented_error import NotImplementedError
16
17
  from ..types.json_list_string_write import JsonListStringWrite
17
18
  from ..types.optimization_page_public import OptimizationPagePublic
18
19
  from ..types.optimization_public import OptimizationPublic
20
+ from ..types.optimization_studio_config_write import OptimizationStudioConfigWrite
21
+ from ..types.optimization_studio_log import OptimizationStudioLog
19
22
  from ..types.optimization_write_status import OptimizationWriteStatus
20
23
  from .types.optimization_update_status import OptimizationUpdateStatus
21
24
 
@@ -27,6 +30,47 @@ class RawOptimizationsClient:
27
30
  def __init__(self, *, client_wrapper: SyncClientWrapper):
28
31
  self._client_wrapper = client_wrapper
29
32
 
33
+ def cancel_studio_optimizations(
34
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
35
+ ) -> HttpResponse[None]:
36
+ """
37
+ Cancel Studio optimizations by id
38
+
39
+ Parameters
40
+ ----------
41
+ id : str
42
+
43
+ request_options : typing.Optional[RequestOptions]
44
+ Request-specific configuration.
45
+
46
+ Returns
47
+ -------
48
+ HttpResponse[None]
49
+ """
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}/cancel",
52
+ method="GET",
53
+ request_options=request_options,
54
+ )
55
+ try:
56
+ if 200 <= _response.status_code < 300:
57
+ return HttpResponse(response=_response, data=None)
58
+ if _response.status_code == 501:
59
+ raise NotImplementedError(
60
+ headers=dict(_response.headers),
61
+ body=typing.cast(
62
+ typing.Optional[typing.Any],
63
+ parse_obj_as(
64
+ type_=typing.Optional[typing.Any], # type: ignore
65
+ object_=_response.json(),
66
+ ),
67
+ ),
68
+ )
69
+ _response_json = _response.json()
70
+ except JSONDecodeError:
71
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
72
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
73
+
30
74
  def find_optimizations(
31
75
  self,
32
76
  *,
@@ -35,6 +79,7 @@ class RawOptimizationsClient:
35
79
  dataset_id: typing.Optional[str] = None,
36
80
  name: typing.Optional[str] = None,
37
81
  dataset_deleted: typing.Optional[bool] = None,
82
+ filters: typing.Optional[str] = None,
38
83
  request_options: typing.Optional[RequestOptions] = None,
39
84
  ) -> HttpResponse[OptimizationPagePublic]:
40
85
  """
@@ -52,6 +97,8 @@ class RawOptimizationsClient:
52
97
 
53
98
  dataset_deleted : typing.Optional[bool]
54
99
 
100
+ filters : typing.Optional[str]
101
+
55
102
  request_options : typing.Optional[RequestOptions]
56
103
  Request-specific configuration.
57
104
 
@@ -69,6 +116,7 @@ class RawOptimizationsClient:
69
116
  "dataset_id": dataset_id,
70
117
  "name": name,
71
118
  "dataset_deleted": dataset_deleted,
119
+ "filters": filters,
72
120
  },
73
121
  request_options=request_options,
74
122
  )
@@ -107,6 +155,7 @@ class RawOptimizationsClient:
107
155
  id: typing.Optional[str] = OMIT,
108
156
  name: typing.Optional[str] = OMIT,
109
157
  metadata: typing.Optional[JsonListStringWrite] = OMIT,
158
+ studio_config: typing.Optional[OptimizationStudioConfigWrite] = OMIT,
110
159
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
111
160
  request_options: typing.Optional[RequestOptions] = None,
112
161
  ) -> HttpResponse[None]:
@@ -127,6 +176,8 @@ class RawOptimizationsClient:
127
176
 
128
177
  metadata : typing.Optional[JsonListStringWrite]
129
178
 
179
+ studio_config : typing.Optional[OptimizationStudioConfigWrite]
180
+
130
181
  last_updated_at : typing.Optional[dt.datetime]
131
182
 
132
183
  request_options : typing.Optional[RequestOptions]
@@ -148,6 +199,9 @@ class RawOptimizationsClient:
148
199
  "metadata": convert_and_respect_annotation_metadata(
149
200
  object_=metadata, annotation=JsonListStringWrite, direction="write"
150
201
  ),
202
+ "studio_config": convert_and_respect_annotation_metadata(
203
+ object_=studio_config, annotation=OptimizationStudioConfigWrite, direction="write"
204
+ ),
151
205
  "last_updated_at": last_updated_at,
152
206
  },
153
207
  headers={
@@ -173,6 +227,7 @@ class RawOptimizationsClient:
173
227
  id: typing.Optional[str] = OMIT,
174
228
  name: typing.Optional[str] = OMIT,
175
229
  metadata: typing.Optional[JsonListStringWrite] = OMIT,
230
+ studio_config: typing.Optional[OptimizationStudioConfigWrite] = OMIT,
176
231
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
177
232
  request_options: typing.Optional[RequestOptions] = None,
178
233
  ) -> HttpResponse[None]:
@@ -193,6 +248,8 @@ class RawOptimizationsClient:
193
248
 
194
249
  metadata : typing.Optional[JsonListStringWrite]
195
250
 
251
+ studio_config : typing.Optional[OptimizationStudioConfigWrite]
252
+
196
253
  last_updated_at : typing.Optional[dt.datetime]
197
254
 
198
255
  request_options : typing.Optional[RequestOptions]
@@ -214,6 +271,9 @@ class RawOptimizationsClient:
214
271
  "metadata": convert_and_respect_annotation_metadata(
215
272
  object_=metadata, annotation=JsonListStringWrite, direction="write"
216
273
  ),
274
+ "studio_config": convert_and_respect_annotation_metadata(
275
+ object_=studio_config, annotation=OptimizationStudioConfigWrite, direction="write"
276
+ ),
217
277
  "last_updated_at": last_updated_at,
218
278
  },
219
279
  headers={
@@ -267,6 +327,81 @@ class RawOptimizationsClient:
267
327
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
268
328
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
269
329
 
330
+ def find_studio_optimizations(
331
+ self,
332
+ *,
333
+ page: typing.Optional[int] = None,
334
+ size: typing.Optional[int] = None,
335
+ dataset_id: typing.Optional[str] = None,
336
+ name: typing.Optional[str] = None,
337
+ dataset_deleted: typing.Optional[bool] = None,
338
+ filters: typing.Optional[str] = None,
339
+ request_options: typing.Optional[RequestOptions] = None,
340
+ ) -> HttpResponse[OptimizationPagePublic]:
341
+ """
342
+ Find Studio optimizations
343
+
344
+ Parameters
345
+ ----------
346
+ page : typing.Optional[int]
347
+
348
+ size : typing.Optional[int]
349
+
350
+ dataset_id : typing.Optional[str]
351
+
352
+ name : typing.Optional[str]
353
+
354
+ dataset_deleted : typing.Optional[bool]
355
+
356
+ filters : typing.Optional[str]
357
+
358
+ request_options : typing.Optional[RequestOptions]
359
+ Request-specific configuration.
360
+
361
+ Returns
362
+ -------
363
+ HttpResponse[OptimizationPagePublic]
364
+ Studio optimizations resource
365
+ """
366
+ _response = self._client_wrapper.httpx_client.request(
367
+ "v1/private/optimizations/studio",
368
+ method="GET",
369
+ params={
370
+ "page": page,
371
+ "size": size,
372
+ "dataset_id": dataset_id,
373
+ "name": name,
374
+ "dataset_deleted": dataset_deleted,
375
+ "filters": filters,
376
+ },
377
+ request_options=request_options,
378
+ )
379
+ try:
380
+ if 200 <= _response.status_code < 300:
381
+ _data = typing.cast(
382
+ OptimizationPagePublic,
383
+ parse_obj_as(
384
+ type_=OptimizationPagePublic, # type: ignore
385
+ object_=_response.json(),
386
+ ),
387
+ )
388
+ return HttpResponse(response=_response, data=_data)
389
+ if _response.status_code == 400:
390
+ raise BadRequestError(
391
+ headers=dict(_response.headers),
392
+ body=typing.cast(
393
+ typing.Optional[typing.Any],
394
+ parse_obj_as(
395
+ type_=typing.Optional[typing.Any], # type: ignore
396
+ object_=_response.json(),
397
+ ),
398
+ ),
399
+ )
400
+ _response_json = _response.json()
401
+ except JSONDecodeError:
402
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
403
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
404
+
270
405
  def get_optimization_by_id(
271
406
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
272
407
  ) -> HttpResponse[OptimizationPublic]:
@@ -363,11 +498,150 @@ class RawOptimizationsClient:
363
498
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
364
499
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
365
500
 
501
+ def get_studio_optimization_by_id(
502
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
503
+ ) -> HttpResponse[OptimizationPublic]:
504
+ """
505
+ Get Studio optimization with config included
506
+
507
+ Parameters
508
+ ----------
509
+ id : str
510
+
511
+ request_options : typing.Optional[RequestOptions]
512
+ Request-specific configuration.
513
+
514
+ Returns
515
+ -------
516
+ HttpResponse[OptimizationPublic]
517
+ Studio optimization resource
518
+ """
519
+ _response = self._client_wrapper.httpx_client.request(
520
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}",
521
+ method="GET",
522
+ request_options=request_options,
523
+ )
524
+ try:
525
+ if 200 <= _response.status_code < 300:
526
+ _data = typing.cast(
527
+ OptimizationPublic,
528
+ parse_obj_as(
529
+ type_=OptimizationPublic, # type: ignore
530
+ object_=_response.json(),
531
+ ),
532
+ )
533
+ return HttpResponse(response=_response, data=_data)
534
+ if _response.status_code == 404:
535
+ raise NotFoundError(
536
+ headers=dict(_response.headers),
537
+ body=typing.cast(
538
+ typing.Optional[typing.Any],
539
+ parse_obj_as(
540
+ type_=typing.Optional[typing.Any], # type: ignore
541
+ object_=_response.json(),
542
+ ),
543
+ ),
544
+ )
545
+ _response_json = _response.json()
546
+ except JSONDecodeError:
547
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
548
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
549
+
550
+ def get_studio_optimization_logs(
551
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
552
+ ) -> HttpResponse[OptimizationStudioLog]:
553
+ """
554
+ Get presigned S3 URL for downloading optimization logs
555
+
556
+ Parameters
557
+ ----------
558
+ id : str
559
+
560
+ request_options : typing.Optional[RequestOptions]
561
+ Request-specific configuration.
562
+
563
+ Returns
564
+ -------
565
+ HttpResponse[OptimizationStudioLog]
566
+ Logs response
567
+ """
568
+ _response = self._client_wrapper.httpx_client.request(
569
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}/logs",
570
+ method="GET",
571
+ request_options=request_options,
572
+ )
573
+ try:
574
+ if 200 <= _response.status_code < 300:
575
+ _data = typing.cast(
576
+ OptimizationStudioLog,
577
+ parse_obj_as(
578
+ type_=OptimizationStudioLog, # type: ignore
579
+ object_=_response.json(),
580
+ ),
581
+ )
582
+ return HttpResponse(response=_response, data=_data)
583
+ if _response.status_code == 404:
584
+ raise NotFoundError(
585
+ headers=dict(_response.headers),
586
+ body=typing.cast(
587
+ typing.Optional[typing.Any],
588
+ parse_obj_as(
589
+ type_=typing.Optional[typing.Any], # type: ignore
590
+ object_=_response.json(),
591
+ ),
592
+ ),
593
+ )
594
+ _response_json = _response.json()
595
+ except JSONDecodeError:
596
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
597
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
598
+
366
599
 
367
600
  class AsyncRawOptimizationsClient:
368
601
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
369
602
  self._client_wrapper = client_wrapper
370
603
 
604
+ async def cancel_studio_optimizations(
605
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
606
+ ) -> AsyncHttpResponse[None]:
607
+ """
608
+ Cancel Studio optimizations by id
609
+
610
+ Parameters
611
+ ----------
612
+ id : str
613
+
614
+ request_options : typing.Optional[RequestOptions]
615
+ Request-specific configuration.
616
+
617
+ Returns
618
+ -------
619
+ AsyncHttpResponse[None]
620
+ """
621
+ _response = await self._client_wrapper.httpx_client.request(
622
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}/cancel",
623
+ method="GET",
624
+ request_options=request_options,
625
+ )
626
+ try:
627
+ if 200 <= _response.status_code < 300:
628
+ return AsyncHttpResponse(response=_response, data=None)
629
+ if _response.status_code == 501:
630
+ raise NotImplementedError(
631
+ headers=dict(_response.headers),
632
+ body=typing.cast(
633
+ typing.Optional[typing.Any],
634
+ parse_obj_as(
635
+ type_=typing.Optional[typing.Any], # type: ignore
636
+ object_=_response.json(),
637
+ ),
638
+ ),
639
+ )
640
+ _response_json = _response.json()
641
+ except JSONDecodeError:
642
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
643
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
644
+
371
645
  async def find_optimizations(
372
646
  self,
373
647
  *,
@@ -376,6 +650,7 @@ class AsyncRawOptimizationsClient:
376
650
  dataset_id: typing.Optional[str] = None,
377
651
  name: typing.Optional[str] = None,
378
652
  dataset_deleted: typing.Optional[bool] = None,
653
+ filters: typing.Optional[str] = None,
379
654
  request_options: typing.Optional[RequestOptions] = None,
380
655
  ) -> AsyncHttpResponse[OptimizationPagePublic]:
381
656
  """
@@ -393,6 +668,8 @@ class AsyncRawOptimizationsClient:
393
668
 
394
669
  dataset_deleted : typing.Optional[bool]
395
670
 
671
+ filters : typing.Optional[str]
672
+
396
673
  request_options : typing.Optional[RequestOptions]
397
674
  Request-specific configuration.
398
675
 
@@ -410,6 +687,7 @@ class AsyncRawOptimizationsClient:
410
687
  "dataset_id": dataset_id,
411
688
  "name": name,
412
689
  "dataset_deleted": dataset_deleted,
690
+ "filters": filters,
413
691
  },
414
692
  request_options=request_options,
415
693
  )
@@ -448,6 +726,7 @@ class AsyncRawOptimizationsClient:
448
726
  id: typing.Optional[str] = OMIT,
449
727
  name: typing.Optional[str] = OMIT,
450
728
  metadata: typing.Optional[JsonListStringWrite] = OMIT,
729
+ studio_config: typing.Optional[OptimizationStudioConfigWrite] = OMIT,
451
730
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
452
731
  request_options: typing.Optional[RequestOptions] = None,
453
732
  ) -> AsyncHttpResponse[None]:
@@ -468,6 +747,8 @@ class AsyncRawOptimizationsClient:
468
747
 
469
748
  metadata : typing.Optional[JsonListStringWrite]
470
749
 
750
+ studio_config : typing.Optional[OptimizationStudioConfigWrite]
751
+
471
752
  last_updated_at : typing.Optional[dt.datetime]
472
753
 
473
754
  request_options : typing.Optional[RequestOptions]
@@ -489,6 +770,9 @@ class AsyncRawOptimizationsClient:
489
770
  "metadata": convert_and_respect_annotation_metadata(
490
771
  object_=metadata, annotation=JsonListStringWrite, direction="write"
491
772
  ),
773
+ "studio_config": convert_and_respect_annotation_metadata(
774
+ object_=studio_config, annotation=OptimizationStudioConfigWrite, direction="write"
775
+ ),
492
776
  "last_updated_at": last_updated_at,
493
777
  },
494
778
  headers={
@@ -514,6 +798,7 @@ class AsyncRawOptimizationsClient:
514
798
  id: typing.Optional[str] = OMIT,
515
799
  name: typing.Optional[str] = OMIT,
516
800
  metadata: typing.Optional[JsonListStringWrite] = OMIT,
801
+ studio_config: typing.Optional[OptimizationStudioConfigWrite] = OMIT,
517
802
  last_updated_at: typing.Optional[dt.datetime] = OMIT,
518
803
  request_options: typing.Optional[RequestOptions] = None,
519
804
  ) -> AsyncHttpResponse[None]:
@@ -534,6 +819,8 @@ class AsyncRawOptimizationsClient:
534
819
 
535
820
  metadata : typing.Optional[JsonListStringWrite]
536
821
 
822
+ studio_config : typing.Optional[OptimizationStudioConfigWrite]
823
+
537
824
  last_updated_at : typing.Optional[dt.datetime]
538
825
 
539
826
  request_options : typing.Optional[RequestOptions]
@@ -555,6 +842,9 @@ class AsyncRawOptimizationsClient:
555
842
  "metadata": convert_and_respect_annotation_metadata(
556
843
  object_=metadata, annotation=JsonListStringWrite, direction="write"
557
844
  ),
845
+ "studio_config": convert_and_respect_annotation_metadata(
846
+ object_=studio_config, annotation=OptimizationStudioConfigWrite, direction="write"
847
+ ),
558
848
  "last_updated_at": last_updated_at,
559
849
  },
560
850
  headers={
@@ -608,6 +898,81 @@ class AsyncRawOptimizationsClient:
608
898
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
609
899
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
610
900
 
901
+ async def find_studio_optimizations(
902
+ self,
903
+ *,
904
+ page: typing.Optional[int] = None,
905
+ size: typing.Optional[int] = None,
906
+ dataset_id: typing.Optional[str] = None,
907
+ name: typing.Optional[str] = None,
908
+ dataset_deleted: typing.Optional[bool] = None,
909
+ filters: typing.Optional[str] = None,
910
+ request_options: typing.Optional[RequestOptions] = None,
911
+ ) -> AsyncHttpResponse[OptimizationPagePublic]:
912
+ """
913
+ Find Studio optimizations
914
+
915
+ Parameters
916
+ ----------
917
+ page : typing.Optional[int]
918
+
919
+ size : typing.Optional[int]
920
+
921
+ dataset_id : typing.Optional[str]
922
+
923
+ name : typing.Optional[str]
924
+
925
+ dataset_deleted : typing.Optional[bool]
926
+
927
+ filters : typing.Optional[str]
928
+
929
+ request_options : typing.Optional[RequestOptions]
930
+ Request-specific configuration.
931
+
932
+ Returns
933
+ -------
934
+ AsyncHttpResponse[OptimizationPagePublic]
935
+ Studio optimizations resource
936
+ """
937
+ _response = await self._client_wrapper.httpx_client.request(
938
+ "v1/private/optimizations/studio",
939
+ method="GET",
940
+ params={
941
+ "page": page,
942
+ "size": size,
943
+ "dataset_id": dataset_id,
944
+ "name": name,
945
+ "dataset_deleted": dataset_deleted,
946
+ "filters": filters,
947
+ },
948
+ request_options=request_options,
949
+ )
950
+ try:
951
+ if 200 <= _response.status_code < 300:
952
+ _data = typing.cast(
953
+ OptimizationPagePublic,
954
+ parse_obj_as(
955
+ type_=OptimizationPagePublic, # type: ignore
956
+ object_=_response.json(),
957
+ ),
958
+ )
959
+ return AsyncHttpResponse(response=_response, data=_data)
960
+ if _response.status_code == 400:
961
+ raise BadRequestError(
962
+ headers=dict(_response.headers),
963
+ body=typing.cast(
964
+ typing.Optional[typing.Any],
965
+ parse_obj_as(
966
+ type_=typing.Optional[typing.Any], # type: ignore
967
+ object_=_response.json(),
968
+ ),
969
+ ),
970
+ )
971
+ _response_json = _response.json()
972
+ except JSONDecodeError:
973
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
974
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
975
+
611
976
  async def get_optimization_by_id(
612
977
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
613
978
  ) -> AsyncHttpResponse[OptimizationPublic]:
@@ -703,3 +1068,101 @@ class AsyncRawOptimizationsClient:
703
1068
  except JSONDecodeError:
704
1069
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
705
1070
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1071
+
1072
+ async def get_studio_optimization_by_id(
1073
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1074
+ ) -> AsyncHttpResponse[OptimizationPublic]:
1075
+ """
1076
+ Get Studio optimization with config included
1077
+
1078
+ Parameters
1079
+ ----------
1080
+ id : str
1081
+
1082
+ request_options : typing.Optional[RequestOptions]
1083
+ Request-specific configuration.
1084
+
1085
+ Returns
1086
+ -------
1087
+ AsyncHttpResponse[OptimizationPublic]
1088
+ Studio optimization resource
1089
+ """
1090
+ _response = await self._client_wrapper.httpx_client.request(
1091
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}",
1092
+ method="GET",
1093
+ request_options=request_options,
1094
+ )
1095
+ try:
1096
+ if 200 <= _response.status_code < 300:
1097
+ _data = typing.cast(
1098
+ OptimizationPublic,
1099
+ parse_obj_as(
1100
+ type_=OptimizationPublic, # type: ignore
1101
+ object_=_response.json(),
1102
+ ),
1103
+ )
1104
+ return AsyncHttpResponse(response=_response, data=_data)
1105
+ if _response.status_code == 404:
1106
+ raise NotFoundError(
1107
+ headers=dict(_response.headers),
1108
+ body=typing.cast(
1109
+ typing.Optional[typing.Any],
1110
+ parse_obj_as(
1111
+ type_=typing.Optional[typing.Any], # type: ignore
1112
+ object_=_response.json(),
1113
+ ),
1114
+ ),
1115
+ )
1116
+ _response_json = _response.json()
1117
+ except JSONDecodeError:
1118
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1119
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1120
+
1121
+ async def get_studio_optimization_logs(
1122
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1123
+ ) -> AsyncHttpResponse[OptimizationStudioLog]:
1124
+ """
1125
+ Get presigned S3 URL for downloading optimization logs
1126
+
1127
+ Parameters
1128
+ ----------
1129
+ id : str
1130
+
1131
+ request_options : typing.Optional[RequestOptions]
1132
+ Request-specific configuration.
1133
+
1134
+ Returns
1135
+ -------
1136
+ AsyncHttpResponse[OptimizationStudioLog]
1137
+ Logs response
1138
+ """
1139
+ _response = await self._client_wrapper.httpx_client.request(
1140
+ f"v1/private/optimizations/studio/{jsonable_encoder(id)}/logs",
1141
+ method="GET",
1142
+ request_options=request_options,
1143
+ )
1144
+ try:
1145
+ if 200 <= _response.status_code < 300:
1146
+ _data = typing.cast(
1147
+ OptimizationStudioLog,
1148
+ parse_obj_as(
1149
+ type_=OptimizationStudioLog, # type: ignore
1150
+ object_=_response.json(),
1151
+ ),
1152
+ )
1153
+ return AsyncHttpResponse(response=_response, data=_data)
1154
+ if _response.status_code == 404:
1155
+ raise NotFoundError(
1156
+ headers=dict(_response.headers),
1157
+ body=typing.cast(
1158
+ typing.Optional[typing.Any],
1159
+ parse_obj_as(
1160
+ type_=typing.Optional[typing.Any], # type: ignore
1161
+ object_=_response.json(),
1162
+ ),
1163
+ ),
1164
+ )
1165
+ _response_json = _response.json()
1166
+ except JSONDecodeError:
1167
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1168
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -2,4 +2,6 @@
2
2
 
3
3
  import typing
4
4
 
5
- OptimizationUpdateStatus = typing.Union[typing.Literal["running", "completed", "cancelled"], typing.Any]
5
+ OptimizationUpdateStatus = typing.Union[
6
+ typing.Literal["running", "completed", "cancelled", "initialized", "error"], typing.Any
7
+ ]
@@ -2,6 +2,6 @@
2
2
 
3
3
  # isort: skip_file
4
4
 
5
- from .types import PromptWriteType
5
+ from .types import CreatePromptVersionDetailTemplateStructure, PromptWriteTemplateStructure, PromptWriteType
6
6
 
7
- __all__ = ["PromptWriteType"]
7
+ __all__ = ["CreatePromptVersionDetailTemplateStructure", "PromptWriteTemplateStructure", "PromptWriteType"]