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.
- opik/__init__.py +10 -3
- opik/anonymizer/__init__.py +5 -0
- opik/anonymizer/anonymizer.py +12 -0
- opik/anonymizer/factory.py +80 -0
- opik/anonymizer/recursive_anonymizer.py +64 -0
- opik/anonymizer/rules.py +56 -0
- opik/anonymizer/rules_anonymizer.py +35 -0
- opik/api_objects/dataset/rest_operations.py +5 -0
- opik/api_objects/experiment/experiment.py +46 -49
- opik/api_objects/experiment/helpers.py +34 -10
- opik/api_objects/local_recording.py +8 -3
- opik/api_objects/opik_client.py +230 -48
- opik/api_objects/opik_query_language.py +9 -0
- opik/api_objects/prompt/__init__.py +11 -3
- opik/api_objects/prompt/base_prompt.py +69 -0
- opik/api_objects/prompt/base_prompt_template.py +29 -0
- opik/api_objects/prompt/chat/__init__.py +1 -0
- opik/api_objects/prompt/chat/chat_prompt.py +193 -0
- opik/api_objects/prompt/chat/chat_prompt_template.py +350 -0
- opik/api_objects/prompt/{chat_content_renderer_registry.py → chat/content_renderer_registry.py} +37 -35
- opik/api_objects/prompt/client.py +101 -30
- opik/api_objects/prompt/text/__init__.py +1 -0
- opik/api_objects/prompt/text/prompt.py +174 -0
- opik/api_objects/prompt/{prompt_template.py → text/prompt_template.py} +10 -6
- opik/api_objects/prompt/types.py +1 -1
- opik/cli/export.py +6 -2
- opik/cli/usage_report/charts.py +39 -10
- opik/cli/usage_report/cli.py +164 -45
- opik/cli/usage_report/pdf.py +14 -1
- opik/config.py +0 -5
- opik/decorator/base_track_decorator.py +37 -40
- opik/decorator/context_manager/span_context_manager.py +9 -0
- opik/decorator/context_manager/trace_context_manager.py +5 -0
- opik/dict_utils.py +3 -3
- opik/evaluation/__init__.py +13 -2
- opik/evaluation/engine/engine.py +195 -223
- opik/evaluation/engine/helpers.py +8 -7
- opik/evaluation/engine/metrics_evaluator.py +237 -0
- opik/evaluation/evaluation_result.py +35 -1
- opik/evaluation/evaluator.py +318 -30
- opik/evaluation/models/litellm/util.py +78 -6
- opik/evaluation/models/model_capabilities.py +33 -0
- opik/evaluation/report.py +14 -2
- opik/evaluation/rest_operations.py +36 -33
- opik/evaluation/test_case.py +2 -2
- opik/evaluation/types.py +9 -1
- opik/exceptions.py +17 -0
- opik/hooks/__init__.py +17 -1
- opik/hooks/anonymizer_hook.py +36 -0
- opik/id_helpers.py +18 -0
- opik/integrations/adk/helpers.py +16 -7
- opik/integrations/adk/legacy_opik_tracer.py +7 -4
- opik/integrations/adk/opik_tracer.py +3 -1
- opik/integrations/adk/patchers/adk_otel_tracer/opik_adk_otel_tracer.py +7 -3
- opik/integrations/adk/recursive_callback_injector.py +1 -6
- opik/integrations/dspy/callback.py +1 -4
- opik/integrations/haystack/opik_connector.py +2 -2
- opik/integrations/haystack/opik_tracer.py +2 -4
- opik/integrations/langchain/opik_tracer.py +273 -82
- opik/integrations/llama_index/callback.py +110 -108
- opik/integrations/openai/agents/opik_tracing_processor.py +1 -2
- opik/integrations/openai/opik_tracker.py +1 -1
- opik/message_processing/batching/batchers.py +11 -7
- opik/message_processing/encoder_helpers.py +79 -0
- opik/message_processing/messages.py +25 -1
- opik/message_processing/online_message_processor.py +23 -8
- opik/opik_context.py +7 -7
- opik/rest_api/__init__.py +188 -12
- opik/rest_api/client.py +3 -0
- opik/rest_api/dashboards/__init__.py +4 -0
- opik/rest_api/dashboards/client.py +462 -0
- opik/rest_api/dashboards/raw_client.py +648 -0
- opik/rest_api/datasets/client.py +893 -89
- opik/rest_api/datasets/raw_client.py +1328 -87
- opik/rest_api/experiments/client.py +30 -2
- opik/rest_api/experiments/raw_client.py +26 -0
- opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +1 -1
- opik/rest_api/optimizations/client.py +302 -0
- opik/rest_api/optimizations/raw_client.py +463 -0
- opik/rest_api/optimizations/types/optimization_update_status.py +3 -1
- opik/rest_api/prompts/__init__.py +2 -2
- opik/rest_api/prompts/client.py +34 -4
- opik/rest_api/prompts/raw_client.py +32 -2
- opik/rest_api/prompts/types/__init__.py +3 -1
- opik/rest_api/prompts/types/create_prompt_version_detail_template_structure.py +5 -0
- opik/rest_api/prompts/types/prompt_write_template_structure.py +5 -0
- opik/rest_api/spans/__init__.py +0 -2
- opik/rest_api/spans/client.py +148 -64
- opik/rest_api/spans/raw_client.py +210 -83
- opik/rest_api/spans/types/__init__.py +0 -2
- opik/rest_api/traces/client.py +241 -73
- opik/rest_api/traces/raw_client.py +344 -90
- opik/rest_api/types/__init__.py +200 -15
- opik/rest_api/types/aggregation_data.py +1 -0
- opik/rest_api/types/alert_trigger_config_public_type.py +6 -1
- opik/rest_api/types/alert_trigger_config_type.py +6 -1
- opik/rest_api/types/alert_trigger_config_write_type.py +6 -1
- opik/rest_api/types/automation_rule_evaluator.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +2 -0
- opik/rest_api/types/{automation_rule_evaluator_object_public.py → automation_rule_evaluator_object_object_public.py} +32 -10
- opik/rest_api/types/automation_rule_evaluator_page_public.py +2 -2
- opik/rest_api/types/automation_rule_evaluator_public.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_public.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_span_llm_as_judge_write.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_llm_as_judge_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_trace_thread_user_defined_metric_python_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update.py +23 -1
- opik/rest_api/types/automation_rule_evaluator_update_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_span_llm_as_judge.py +22 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_llm_as_judge.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_trace_thread_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_update_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_public.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_user_defined_metric_python_write.py +2 -0
- opik/rest_api/types/automation_rule_evaluator_write.py +23 -1
- opik/rest_api/types/boolean_feedback_definition.py +25 -0
- opik/rest_api/types/boolean_feedback_definition_create.py +20 -0
- opik/rest_api/types/boolean_feedback_definition_public.py +25 -0
- opik/rest_api/types/boolean_feedback_definition_update.py +20 -0
- opik/rest_api/types/boolean_feedback_detail.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_create.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_public.py +29 -0
- opik/rest_api/types/boolean_feedback_detail_update.py +29 -0
- opik/rest_api/types/dashboard_page_public.py +24 -0
- opik/rest_api/types/dashboard_public.py +30 -0
- opik/rest_api/types/dataset.py +2 -0
- opik/rest_api/types/dataset_item.py +2 -0
- opik/rest_api/types/dataset_item_compare.py +2 -0
- opik/rest_api/types/dataset_item_filter.py +23 -0
- opik/rest_api/types/dataset_item_filter_operator.py +21 -0
- opik/rest_api/types/dataset_item_page_compare.py +1 -0
- opik/rest_api/types/dataset_item_page_public.py +1 -0
- opik/rest_api/types/dataset_item_public.py +2 -0
- opik/rest_api/types/dataset_item_update.py +39 -0
- opik/rest_api/types/dataset_item_write.py +1 -0
- opik/rest_api/types/dataset_public.py +2 -0
- opik/rest_api/types/dataset_public_status.py +5 -0
- opik/rest_api/types/dataset_status.py +5 -0
- opik/rest_api/types/dataset_version_diff.py +22 -0
- opik/rest_api/types/dataset_version_diff_stats.py +24 -0
- opik/rest_api/types/dataset_version_page_public.py +23 -0
- opik/rest_api/types/dataset_version_public.py +49 -0
- opik/rest_api/types/experiment.py +2 -0
- opik/rest_api/types/experiment_public.py +2 -0
- opik/rest_api/types/experiment_score.py +20 -0
- opik/rest_api/types/experiment_score_public.py +20 -0
- opik/rest_api/types/experiment_score_write.py +20 -0
- opik/rest_api/types/feedback.py +20 -1
- opik/rest_api/types/feedback_create.py +16 -1
- opik/rest_api/types/feedback_object_public.py +22 -1
- opik/rest_api/types/feedback_public.py +20 -1
- opik/rest_api/types/feedback_score_public.py +4 -0
- opik/rest_api/types/feedback_update.py +16 -1
- opik/rest_api/types/image_url.py +20 -0
- opik/rest_api/types/image_url_public.py +20 -0
- opik/rest_api/types/image_url_write.py +20 -0
- opik/rest_api/types/llm_as_judge_message.py +5 -1
- opik/rest_api/types/llm_as_judge_message_content.py +24 -0
- opik/rest_api/types/llm_as_judge_message_content_public.py +24 -0
- opik/rest_api/types/llm_as_judge_message_content_write.py +24 -0
- opik/rest_api/types/llm_as_judge_message_public.py +5 -1
- opik/rest_api/types/llm_as_judge_message_write.py +5 -1
- opik/rest_api/types/llm_as_judge_model_parameters.py +2 -0
- opik/rest_api/types/llm_as_judge_model_parameters_public.py +2 -0
- opik/rest_api/types/llm_as_judge_model_parameters_write.py +2 -0
- opik/rest_api/types/optimization.py +2 -0
- opik/rest_api/types/optimization_public.py +2 -0
- opik/rest_api/types/optimization_public_status.py +3 -1
- opik/rest_api/types/optimization_status.py +3 -1
- opik/rest_api/types/optimization_studio_config.py +27 -0
- opik/rest_api/types/optimization_studio_config_public.py +27 -0
- opik/rest_api/types/optimization_studio_config_write.py +27 -0
- opik/rest_api/types/optimization_studio_log.py +22 -0
- opik/rest_api/types/optimization_write.py +2 -0
- opik/rest_api/types/optimization_write_status.py +3 -1
- opik/rest_api/types/prompt.py +6 -0
- opik/rest_api/types/prompt_detail.py +6 -0
- opik/rest_api/types/prompt_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_public.py +6 -0
- opik/rest_api/types/prompt_public_template_structure.py +5 -0
- opik/rest_api/types/prompt_template_structure.py +5 -0
- opik/rest_api/types/prompt_version.py +2 -0
- opik/rest_api/types/prompt_version_detail.py +2 -0
- opik/rest_api/types/prompt_version_detail_template_structure.py +5 -0
- opik/rest_api/types/prompt_version_public.py +2 -0
- opik/rest_api/types/prompt_version_public_template_structure.py +5 -0
- opik/rest_api/types/prompt_version_template_structure.py +5 -0
- opik/rest_api/types/score_name.py +1 -0
- opik/rest_api/types/service_toggles_config.py +6 -0
- opik/rest_api/types/span_enrichment_options.py +31 -0
- opik/rest_api/types/span_filter.py +23 -0
- opik/rest_api/types/span_filter_operator.py +21 -0
- opik/rest_api/types/span_filter_write.py +23 -0
- opik/rest_api/types/span_filter_write_operator.py +21 -0
- opik/rest_api/types/span_llm_as_judge_code.py +27 -0
- opik/rest_api/types/span_llm_as_judge_code_public.py +27 -0
- opik/rest_api/types/span_llm_as_judge_code_write.py +27 -0
- opik/rest_api/types/span_update.py +46 -0
- opik/rest_api/types/studio_evaluation.py +20 -0
- opik/rest_api/types/studio_evaluation_public.py +20 -0
- opik/rest_api/types/studio_evaluation_write.py +20 -0
- opik/rest_api/types/studio_llm_model.py +21 -0
- opik/rest_api/types/studio_llm_model_public.py +21 -0
- opik/rest_api/types/studio_llm_model_write.py +21 -0
- opik/rest_api/types/studio_message.py +20 -0
- opik/rest_api/types/studio_message_public.py +20 -0
- opik/rest_api/types/studio_message_write.py +20 -0
- opik/rest_api/types/studio_metric.py +21 -0
- opik/rest_api/types/studio_metric_public.py +21 -0
- opik/rest_api/types/studio_metric_write.py +21 -0
- opik/rest_api/types/studio_optimizer.py +21 -0
- opik/rest_api/types/studio_optimizer_public.py +21 -0
- opik/rest_api/types/studio_optimizer_write.py +21 -0
- opik/rest_api/types/studio_prompt.py +20 -0
- opik/rest_api/types/studio_prompt_public.py +20 -0
- opik/rest_api/types/studio_prompt_write.py +20 -0
- opik/rest_api/types/trace.py +6 -0
- opik/rest_api/types/trace_public.py +6 -0
- opik/rest_api/types/trace_thread_filter_write.py +23 -0
- opik/rest_api/types/trace_thread_filter_write_operator.py +21 -0
- opik/rest_api/types/trace_thread_update.py +19 -0
- opik/rest_api/types/trace_update.py +39 -0
- opik/rest_api/types/value_entry.py +2 -0
- opik/rest_api/types/value_entry_compare.py +2 -0
- opik/rest_api/types/value_entry_experiment_item_bulk_write_view.py +2 -0
- opik/rest_api/types/value_entry_public.py +2 -0
- opik/rest_api/types/video_url.py +19 -0
- opik/rest_api/types/video_url_public.py +19 -0
- opik/rest_api/types/video_url_write.py +19 -0
- opik/synchronization.py +5 -6
- opik/{decorator/tracing_runtime_config.py → tracing_runtime_config.py} +6 -7
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/METADATA +5 -4
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/RECORD +246 -151
- opik/api_objects/prompt/chat_prompt_template.py +0 -164
- opik/api_objects/prompt/prompt.py +0 -131
- /opik/rest_api/{spans/types → types}/span_update_type.py +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/WHEEL +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/entry_points.txt +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/licenses/LICENSE +0 -0
- {opik-1.9.5.dist-info → opik-1.9.39.dist-info}/top_level.txt +0 -0
opik/rest_api/prompts/client.py
CHANGED
|
@@ -10,6 +10,8 @@ from ..types.prompt_page_public import PromptPagePublic
|
|
|
10
10
|
from ..types.prompt_version_detail import PromptVersionDetail
|
|
11
11
|
from ..types.prompt_version_page_public import PromptVersionPagePublic
|
|
12
12
|
from .raw_client import AsyncRawPromptsClient, RawPromptsClient
|
|
13
|
+
from .types.create_prompt_version_detail_template_structure import CreatePromptVersionDetailTemplateStructure
|
|
14
|
+
from .types.prompt_write_template_structure import PromptWriteTemplateStructure
|
|
13
15
|
from .types.prompt_write_type import PromptWriteType
|
|
14
16
|
|
|
15
17
|
# this is used as the default value for optional parameters
|
|
@@ -85,6 +87,7 @@ class PromptsClient:
|
|
|
85
87
|
metadata: typing.Optional[JsonNodeWrite] = OMIT,
|
|
86
88
|
change_description: typing.Optional[str] = OMIT,
|
|
87
89
|
type: typing.Optional[PromptWriteType] = OMIT,
|
|
90
|
+
template_structure: typing.Optional[PromptWriteTemplateStructure] = OMIT,
|
|
88
91
|
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
89
92
|
request_options: typing.Optional[RequestOptions] = None,
|
|
90
93
|
) -> None:
|
|
@@ -107,6 +110,9 @@ class PromptsClient:
|
|
|
107
110
|
|
|
108
111
|
type : typing.Optional[PromptWriteType]
|
|
109
112
|
|
|
113
|
+
template_structure : typing.Optional[PromptWriteTemplateStructure]
|
|
114
|
+
Template structure type: 'text' or 'chat'. Immutable after creation.
|
|
115
|
+
|
|
110
116
|
tags : typing.Optional[typing.Sequence[str]]
|
|
111
117
|
|
|
112
118
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -130,13 +136,19 @@ class PromptsClient:
|
|
|
130
136
|
metadata=metadata,
|
|
131
137
|
change_description=change_description,
|
|
132
138
|
type=type,
|
|
139
|
+
template_structure=template_structure,
|
|
133
140
|
tags=tags,
|
|
134
141
|
request_options=request_options,
|
|
135
142
|
)
|
|
136
143
|
return _response.data
|
|
137
144
|
|
|
138
145
|
def create_prompt_version(
|
|
139
|
-
self,
|
|
146
|
+
self,
|
|
147
|
+
*,
|
|
148
|
+
name: str,
|
|
149
|
+
version: PromptVersionDetail,
|
|
150
|
+
template_structure: typing.Optional[CreatePromptVersionDetailTemplateStructure] = OMIT,
|
|
151
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
140
152
|
) -> PromptVersionDetail:
|
|
141
153
|
"""
|
|
142
154
|
Create prompt version
|
|
@@ -147,6 +159,9 @@ class PromptsClient:
|
|
|
147
159
|
|
|
148
160
|
version : PromptVersionDetail
|
|
149
161
|
|
|
162
|
+
template_structure : typing.Optional[CreatePromptVersionDetailTemplateStructure]
|
|
163
|
+
Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation.
|
|
164
|
+
|
|
150
165
|
request_options : typing.Optional[RequestOptions]
|
|
151
166
|
Request-specific configuration.
|
|
152
167
|
|
|
@@ -162,7 +177,9 @@ class PromptsClient:
|
|
|
162
177
|
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
163
178
|
client.prompts.create_prompt_version(name='name', version=PromptVersionDetail(template='template', ), )
|
|
164
179
|
"""
|
|
165
|
-
_response = self._raw_client.create_prompt_version(
|
|
180
|
+
_response = self._raw_client.create_prompt_version(
|
|
181
|
+
name=name, version=version, template_structure=template_structure, request_options=request_options
|
|
182
|
+
)
|
|
166
183
|
return _response.data
|
|
167
184
|
|
|
168
185
|
def get_prompt_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> PromptDetail:
|
|
@@ -474,6 +491,7 @@ class AsyncPromptsClient:
|
|
|
474
491
|
metadata: typing.Optional[JsonNodeWrite] = OMIT,
|
|
475
492
|
change_description: typing.Optional[str] = OMIT,
|
|
476
493
|
type: typing.Optional[PromptWriteType] = OMIT,
|
|
494
|
+
template_structure: typing.Optional[PromptWriteTemplateStructure] = OMIT,
|
|
477
495
|
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
478
496
|
request_options: typing.Optional[RequestOptions] = None,
|
|
479
497
|
) -> None:
|
|
@@ -496,6 +514,9 @@ class AsyncPromptsClient:
|
|
|
496
514
|
|
|
497
515
|
type : typing.Optional[PromptWriteType]
|
|
498
516
|
|
|
517
|
+
template_structure : typing.Optional[PromptWriteTemplateStructure]
|
|
518
|
+
Template structure type: 'text' or 'chat'. Immutable after creation.
|
|
519
|
+
|
|
499
520
|
tags : typing.Optional[typing.Sequence[str]]
|
|
500
521
|
|
|
501
522
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -522,13 +543,19 @@ class AsyncPromptsClient:
|
|
|
522
543
|
metadata=metadata,
|
|
523
544
|
change_description=change_description,
|
|
524
545
|
type=type,
|
|
546
|
+
template_structure=template_structure,
|
|
525
547
|
tags=tags,
|
|
526
548
|
request_options=request_options,
|
|
527
549
|
)
|
|
528
550
|
return _response.data
|
|
529
551
|
|
|
530
552
|
async def create_prompt_version(
|
|
531
|
-
self,
|
|
553
|
+
self,
|
|
554
|
+
*,
|
|
555
|
+
name: str,
|
|
556
|
+
version: PromptVersionDetail,
|
|
557
|
+
template_structure: typing.Optional[CreatePromptVersionDetailTemplateStructure] = OMIT,
|
|
558
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
532
559
|
) -> PromptVersionDetail:
|
|
533
560
|
"""
|
|
534
561
|
Create prompt version
|
|
@@ -539,6 +566,9 @@ class AsyncPromptsClient:
|
|
|
539
566
|
|
|
540
567
|
version : PromptVersionDetail
|
|
541
568
|
|
|
569
|
+
template_structure : typing.Optional[CreatePromptVersionDetailTemplateStructure]
|
|
570
|
+
Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation.
|
|
571
|
+
|
|
542
572
|
request_options : typing.Optional[RequestOptions]
|
|
543
573
|
Request-specific configuration.
|
|
544
574
|
|
|
@@ -558,7 +588,7 @@ class AsyncPromptsClient:
|
|
|
558
588
|
asyncio.run(main())
|
|
559
589
|
"""
|
|
560
590
|
_response = await self._raw_client.create_prompt_version(
|
|
561
|
-
name=name, version=version, request_options=request_options
|
|
591
|
+
name=name, version=version, template_structure=template_structure, request_options=request_options
|
|
562
592
|
)
|
|
563
593
|
return _response.data
|
|
564
594
|
|
|
@@ -19,6 +19,8 @@ from ..types.prompt_detail import PromptDetail
|
|
|
19
19
|
from ..types.prompt_page_public import PromptPagePublic
|
|
20
20
|
from ..types.prompt_version_detail import PromptVersionDetail
|
|
21
21
|
from ..types.prompt_version_page_public import PromptVersionPagePublic
|
|
22
|
+
from .types.create_prompt_version_detail_template_structure import CreatePromptVersionDetailTemplateStructure
|
|
23
|
+
from .types.prompt_write_template_structure import PromptWriteTemplateStructure
|
|
22
24
|
from .types.prompt_write_type import PromptWriteType
|
|
23
25
|
|
|
24
26
|
# this is used as the default value for optional parameters
|
|
@@ -99,6 +101,7 @@ class RawPromptsClient:
|
|
|
99
101
|
metadata: typing.Optional[JsonNodeWrite] = OMIT,
|
|
100
102
|
change_description: typing.Optional[str] = OMIT,
|
|
101
103
|
type: typing.Optional[PromptWriteType] = OMIT,
|
|
104
|
+
template_structure: typing.Optional[PromptWriteTemplateStructure] = OMIT,
|
|
102
105
|
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
103
106
|
request_options: typing.Optional[RequestOptions] = None,
|
|
104
107
|
) -> HttpResponse[None]:
|
|
@@ -121,6 +124,9 @@ class RawPromptsClient:
|
|
|
121
124
|
|
|
122
125
|
type : typing.Optional[PromptWriteType]
|
|
123
126
|
|
|
127
|
+
template_structure : typing.Optional[PromptWriteTemplateStructure]
|
|
128
|
+
Template structure type: 'text' or 'chat'. Immutable after creation.
|
|
129
|
+
|
|
124
130
|
tags : typing.Optional[typing.Sequence[str]]
|
|
125
131
|
|
|
126
132
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -141,6 +147,7 @@ class RawPromptsClient:
|
|
|
141
147
|
"metadata": metadata,
|
|
142
148
|
"change_description": change_description,
|
|
143
149
|
"type": type,
|
|
150
|
+
"template_structure": template_structure,
|
|
144
151
|
"tags": tags,
|
|
145
152
|
},
|
|
146
153
|
headers={
|
|
@@ -191,7 +198,12 @@ class RawPromptsClient:
|
|
|
191
198
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
192
199
|
|
|
193
200
|
def create_prompt_version(
|
|
194
|
-
self,
|
|
201
|
+
self,
|
|
202
|
+
*,
|
|
203
|
+
name: str,
|
|
204
|
+
version: PromptVersionDetail,
|
|
205
|
+
template_structure: typing.Optional[CreatePromptVersionDetailTemplateStructure] = OMIT,
|
|
206
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
195
207
|
) -> HttpResponse[PromptVersionDetail]:
|
|
196
208
|
"""
|
|
197
209
|
Create prompt version
|
|
@@ -202,6 +214,9 @@ class RawPromptsClient:
|
|
|
202
214
|
|
|
203
215
|
version : PromptVersionDetail
|
|
204
216
|
|
|
217
|
+
template_structure : typing.Optional[CreatePromptVersionDetailTemplateStructure]
|
|
218
|
+
Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation.
|
|
219
|
+
|
|
205
220
|
request_options : typing.Optional[RequestOptions]
|
|
206
221
|
Request-specific configuration.
|
|
207
222
|
|
|
@@ -218,6 +233,7 @@ class RawPromptsClient:
|
|
|
218
233
|
"version": convert_and_respect_annotation_metadata(
|
|
219
234
|
object_=version, annotation=PromptVersionDetail, direction="write"
|
|
220
235
|
),
|
|
236
|
+
"template_structure": template_structure,
|
|
221
237
|
},
|
|
222
238
|
headers={
|
|
223
239
|
"content-type": "application/json",
|
|
@@ -800,6 +816,7 @@ class AsyncRawPromptsClient:
|
|
|
800
816
|
metadata: typing.Optional[JsonNodeWrite] = OMIT,
|
|
801
817
|
change_description: typing.Optional[str] = OMIT,
|
|
802
818
|
type: typing.Optional[PromptWriteType] = OMIT,
|
|
819
|
+
template_structure: typing.Optional[PromptWriteTemplateStructure] = OMIT,
|
|
803
820
|
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
804
821
|
request_options: typing.Optional[RequestOptions] = None,
|
|
805
822
|
) -> AsyncHttpResponse[None]:
|
|
@@ -822,6 +839,9 @@ class AsyncRawPromptsClient:
|
|
|
822
839
|
|
|
823
840
|
type : typing.Optional[PromptWriteType]
|
|
824
841
|
|
|
842
|
+
template_structure : typing.Optional[PromptWriteTemplateStructure]
|
|
843
|
+
Template structure type: 'text' or 'chat'. Immutable after creation.
|
|
844
|
+
|
|
825
845
|
tags : typing.Optional[typing.Sequence[str]]
|
|
826
846
|
|
|
827
847
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -842,6 +862,7 @@ class AsyncRawPromptsClient:
|
|
|
842
862
|
"metadata": metadata,
|
|
843
863
|
"change_description": change_description,
|
|
844
864
|
"type": type,
|
|
865
|
+
"template_structure": template_structure,
|
|
845
866
|
"tags": tags,
|
|
846
867
|
},
|
|
847
868
|
headers={
|
|
@@ -892,7 +913,12 @@ class AsyncRawPromptsClient:
|
|
|
892
913
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
893
914
|
|
|
894
915
|
async def create_prompt_version(
|
|
895
|
-
self,
|
|
916
|
+
self,
|
|
917
|
+
*,
|
|
918
|
+
name: str,
|
|
919
|
+
version: PromptVersionDetail,
|
|
920
|
+
template_structure: typing.Optional[CreatePromptVersionDetailTemplateStructure] = OMIT,
|
|
921
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
896
922
|
) -> AsyncHttpResponse[PromptVersionDetail]:
|
|
897
923
|
"""
|
|
898
924
|
Create prompt version
|
|
@@ -903,6 +929,9 @@ class AsyncRawPromptsClient:
|
|
|
903
929
|
|
|
904
930
|
version : PromptVersionDetail
|
|
905
931
|
|
|
932
|
+
template_structure : typing.Optional[CreatePromptVersionDetailTemplateStructure]
|
|
933
|
+
Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation.
|
|
934
|
+
|
|
906
935
|
request_options : typing.Optional[RequestOptions]
|
|
907
936
|
Request-specific configuration.
|
|
908
937
|
|
|
@@ -919,6 +948,7 @@ class AsyncRawPromptsClient:
|
|
|
919
948
|
"version": convert_and_respect_annotation_metadata(
|
|
920
949
|
object_=version, annotation=PromptVersionDetail, direction="write"
|
|
921
950
|
),
|
|
951
|
+
"template_structure": template_structure,
|
|
922
952
|
},
|
|
923
953
|
headers={
|
|
924
954
|
"content-type": "application/json",
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# isort: skip_file
|
|
4
4
|
|
|
5
|
+
from .create_prompt_version_detail_template_structure import CreatePromptVersionDetailTemplateStructure
|
|
6
|
+
from .prompt_write_template_structure import PromptWriteTemplateStructure
|
|
5
7
|
from .prompt_write_type import PromptWriteType
|
|
6
8
|
|
|
7
|
-
__all__ = ["PromptWriteType"]
|
|
9
|
+
__all__ = ["CreatePromptVersionDetailTemplateStructure", "PromptWriteTemplateStructure", "PromptWriteType"]
|
opik/rest_api/spans/__init__.py
CHANGED
|
@@ -7,7 +7,6 @@ from .types import (
|
|
|
7
7
|
GetSpanStatsRequestType,
|
|
8
8
|
GetSpansByProjectRequestType,
|
|
9
9
|
SpanSearchStreamRequestPublicType,
|
|
10
|
-
SpanUpdateType,
|
|
11
10
|
)
|
|
12
11
|
|
|
13
12
|
__all__ = [
|
|
@@ -15,5 +14,4 @@ __all__ = [
|
|
|
15
14
|
"GetSpanStatsRequestType",
|
|
16
15
|
"GetSpansByProjectRequestType",
|
|
17
16
|
"SpanSearchStreamRequestPublicType",
|
|
18
|
-
"SpanUpdateType",
|
|
19
17
|
]
|
opik/rest_api/spans/client.py
CHANGED
|
@@ -16,6 +16,8 @@ from ..types.project_stats_public import ProjectStatsPublic
|
|
|
16
16
|
from ..types.span_filter_public import SpanFilterPublic
|
|
17
17
|
from ..types.span_page_public import SpanPagePublic
|
|
18
18
|
from ..types.span_public import SpanPublic
|
|
19
|
+
from ..types.span_update import SpanUpdate
|
|
20
|
+
from ..types.span_update_type import SpanUpdateType
|
|
19
21
|
from ..types.span_write import SpanWrite
|
|
20
22
|
from ..types.span_write_type import SpanWriteType
|
|
21
23
|
from ..types.value_entry import ValueEntry
|
|
@@ -24,7 +26,6 @@ from .types.find_feedback_score_names_1_request_type import FindFeedbackScoreNam
|
|
|
24
26
|
from .types.get_span_stats_request_type import GetSpanStatsRequestType
|
|
25
27
|
from .types.get_spans_by_project_request_type import GetSpansByProjectRequestType
|
|
26
28
|
from .types.span_search_stream_request_public_type import SpanSearchStreamRequestPublicType
|
|
27
|
-
from .types.span_update_type import SpanUpdateType
|
|
28
29
|
|
|
29
30
|
# this is used as the default value for optional parameters
|
|
30
31
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -173,6 +174,74 @@ class SpansClient:
|
|
|
173
174
|
)
|
|
174
175
|
return _response.data
|
|
175
176
|
|
|
177
|
+
def create_spans(
|
|
178
|
+
self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
|
|
179
|
+
) -> None:
|
|
180
|
+
"""
|
|
181
|
+
Create spans
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
----------
|
|
185
|
+
spans : typing.Sequence[SpanWrite]
|
|
186
|
+
|
|
187
|
+
request_options : typing.Optional[RequestOptions]
|
|
188
|
+
Request-specific configuration.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
None
|
|
193
|
+
|
|
194
|
+
Examples
|
|
195
|
+
--------
|
|
196
|
+
from Opik import OpikApi
|
|
197
|
+
from Opik import SpanWrite
|
|
198
|
+
import datetime
|
|
199
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
200
|
+
client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
|
|
201
|
+
"""
|
|
202
|
+
_response = self._raw_client.create_spans(spans=spans, request_options=request_options)
|
|
203
|
+
return _response.data
|
|
204
|
+
|
|
205
|
+
def batch_update_spans(
|
|
206
|
+
self,
|
|
207
|
+
*,
|
|
208
|
+
ids: typing.Sequence[str],
|
|
209
|
+
update: SpanUpdate,
|
|
210
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
211
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
212
|
+
) -> None:
|
|
213
|
+
"""
|
|
214
|
+
Update multiple spans
|
|
215
|
+
|
|
216
|
+
Parameters
|
|
217
|
+
----------
|
|
218
|
+
ids : typing.Sequence[str]
|
|
219
|
+
List of span IDs to update (max 1000)
|
|
220
|
+
|
|
221
|
+
update : SpanUpdate
|
|
222
|
+
|
|
223
|
+
merge_tags : typing.Optional[bool]
|
|
224
|
+
If true, merge tags with existing tags instead of replacing them. Default: false
|
|
225
|
+
|
|
226
|
+
request_options : typing.Optional[RequestOptions]
|
|
227
|
+
Request-specific configuration.
|
|
228
|
+
|
|
229
|
+
Returns
|
|
230
|
+
-------
|
|
231
|
+
None
|
|
232
|
+
|
|
233
|
+
Examples
|
|
234
|
+
--------
|
|
235
|
+
from Opik import OpikApi
|
|
236
|
+
from Opik import SpanUpdate
|
|
237
|
+
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
238
|
+
client.spans.batch_update_spans(ids=['ids'], update=SpanUpdate(trace_id='trace_id', ), )
|
|
239
|
+
"""
|
|
240
|
+
_response = self._raw_client.batch_update_spans(
|
|
241
|
+
ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
|
|
242
|
+
)
|
|
243
|
+
return _response.data
|
|
244
|
+
|
|
176
245
|
def get_spans_by_project(
|
|
177
246
|
self,
|
|
178
247
|
*,
|
|
@@ -360,34 +429,6 @@ class SpansClient:
|
|
|
360
429
|
)
|
|
361
430
|
return _response.data
|
|
362
431
|
|
|
363
|
-
def create_spans(
|
|
364
|
-
self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
|
|
365
|
-
) -> None:
|
|
366
|
-
"""
|
|
367
|
-
Create spans
|
|
368
|
-
|
|
369
|
-
Parameters
|
|
370
|
-
----------
|
|
371
|
-
spans : typing.Sequence[SpanWrite]
|
|
372
|
-
|
|
373
|
-
request_options : typing.Optional[RequestOptions]
|
|
374
|
-
Request-specific configuration.
|
|
375
|
-
|
|
376
|
-
Returns
|
|
377
|
-
-------
|
|
378
|
-
None
|
|
379
|
-
|
|
380
|
-
Examples
|
|
381
|
-
--------
|
|
382
|
-
from Opik import OpikApi
|
|
383
|
-
from Opik import SpanWrite
|
|
384
|
-
import datetime
|
|
385
|
-
client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
386
|
-
client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
|
|
387
|
-
"""
|
|
388
|
-
_response = self._raw_client.create_spans(spans=spans, request_options=request_options)
|
|
389
|
-
return _response.data
|
|
390
|
-
|
|
391
432
|
def get_span_by_id(
|
|
392
433
|
self,
|
|
393
434
|
id: str,
|
|
@@ -798,10 +839,10 @@ class SpansClient:
|
|
|
798
839
|
Truncate image included in either input, output or metadata
|
|
799
840
|
|
|
800
841
|
from_time : typing.Optional[dt.datetime]
|
|
801
|
-
Filter spans created from this time (ISO-8601 format).
|
|
842
|
+
Filter spans created from this time (ISO-8601 format).
|
|
802
843
|
|
|
803
844
|
to_time : typing.Optional[dt.datetime]
|
|
804
|
-
Filter spans created up to this time (ISO-8601 format).
|
|
845
|
+
Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
|
|
805
846
|
|
|
806
847
|
request_options : typing.Optional[RequestOptions]
|
|
807
848
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
@@ -1032,6 +1073,80 @@ class AsyncSpansClient:
|
|
|
1032
1073
|
)
|
|
1033
1074
|
return _response.data
|
|
1034
1075
|
|
|
1076
|
+
async def create_spans(
|
|
1077
|
+
self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
|
|
1078
|
+
) -> None:
|
|
1079
|
+
"""
|
|
1080
|
+
Create spans
|
|
1081
|
+
|
|
1082
|
+
Parameters
|
|
1083
|
+
----------
|
|
1084
|
+
spans : typing.Sequence[SpanWrite]
|
|
1085
|
+
|
|
1086
|
+
request_options : typing.Optional[RequestOptions]
|
|
1087
|
+
Request-specific configuration.
|
|
1088
|
+
|
|
1089
|
+
Returns
|
|
1090
|
+
-------
|
|
1091
|
+
None
|
|
1092
|
+
|
|
1093
|
+
Examples
|
|
1094
|
+
--------
|
|
1095
|
+
from Opik import AsyncOpikApi
|
|
1096
|
+
from Opik import SpanWrite
|
|
1097
|
+
import datetime
|
|
1098
|
+
import asyncio
|
|
1099
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1100
|
+
async def main() -> None:
|
|
1101
|
+
await client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
|
|
1102
|
+
asyncio.run(main())
|
|
1103
|
+
"""
|
|
1104
|
+
_response = await self._raw_client.create_spans(spans=spans, request_options=request_options)
|
|
1105
|
+
return _response.data
|
|
1106
|
+
|
|
1107
|
+
async def batch_update_spans(
|
|
1108
|
+
self,
|
|
1109
|
+
*,
|
|
1110
|
+
ids: typing.Sequence[str],
|
|
1111
|
+
update: SpanUpdate,
|
|
1112
|
+
merge_tags: typing.Optional[bool] = OMIT,
|
|
1113
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1114
|
+
) -> None:
|
|
1115
|
+
"""
|
|
1116
|
+
Update multiple spans
|
|
1117
|
+
|
|
1118
|
+
Parameters
|
|
1119
|
+
----------
|
|
1120
|
+
ids : typing.Sequence[str]
|
|
1121
|
+
List of span IDs to update (max 1000)
|
|
1122
|
+
|
|
1123
|
+
update : SpanUpdate
|
|
1124
|
+
|
|
1125
|
+
merge_tags : typing.Optional[bool]
|
|
1126
|
+
If true, merge tags with existing tags instead of replacing them. Default: false
|
|
1127
|
+
|
|
1128
|
+
request_options : typing.Optional[RequestOptions]
|
|
1129
|
+
Request-specific configuration.
|
|
1130
|
+
|
|
1131
|
+
Returns
|
|
1132
|
+
-------
|
|
1133
|
+
None
|
|
1134
|
+
|
|
1135
|
+
Examples
|
|
1136
|
+
--------
|
|
1137
|
+
from Opik import AsyncOpikApi
|
|
1138
|
+
from Opik import SpanUpdate
|
|
1139
|
+
import asyncio
|
|
1140
|
+
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1141
|
+
async def main() -> None:
|
|
1142
|
+
await client.spans.batch_update_spans(ids=['ids'], update=SpanUpdate(trace_id='trace_id', ), )
|
|
1143
|
+
asyncio.run(main())
|
|
1144
|
+
"""
|
|
1145
|
+
_response = await self._raw_client.batch_update_spans(
|
|
1146
|
+
ids=ids, update=update, merge_tags=merge_tags, request_options=request_options
|
|
1147
|
+
)
|
|
1148
|
+
return _response.data
|
|
1149
|
+
|
|
1035
1150
|
async def get_spans_by_project(
|
|
1036
1151
|
self,
|
|
1037
1152
|
*,
|
|
@@ -1225,37 +1340,6 @@ class AsyncSpansClient:
|
|
|
1225
1340
|
)
|
|
1226
1341
|
return _response.data
|
|
1227
1342
|
|
|
1228
|
-
async def create_spans(
|
|
1229
|
-
self, *, spans: typing.Sequence[SpanWrite], request_options: typing.Optional[RequestOptions] = None
|
|
1230
|
-
) -> None:
|
|
1231
|
-
"""
|
|
1232
|
-
Create spans
|
|
1233
|
-
|
|
1234
|
-
Parameters
|
|
1235
|
-
----------
|
|
1236
|
-
spans : typing.Sequence[SpanWrite]
|
|
1237
|
-
|
|
1238
|
-
request_options : typing.Optional[RequestOptions]
|
|
1239
|
-
Request-specific configuration.
|
|
1240
|
-
|
|
1241
|
-
Returns
|
|
1242
|
-
-------
|
|
1243
|
-
None
|
|
1244
|
-
|
|
1245
|
-
Examples
|
|
1246
|
-
--------
|
|
1247
|
-
from Opik import AsyncOpikApi
|
|
1248
|
-
from Opik import SpanWrite
|
|
1249
|
-
import datetime
|
|
1250
|
-
import asyncio
|
|
1251
|
-
client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
|
|
1252
|
-
async def main() -> None:
|
|
1253
|
-
await client.spans.create_spans(spans=[SpanWrite(start_time=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00", ), )], )
|
|
1254
|
-
asyncio.run(main())
|
|
1255
|
-
"""
|
|
1256
|
-
_response = await self._raw_client.create_spans(spans=spans, request_options=request_options)
|
|
1257
|
-
return _response.data
|
|
1258
|
-
|
|
1259
1343
|
async def get_span_by_id(
|
|
1260
1344
|
self,
|
|
1261
1345
|
id: str,
|
|
@@ -1693,10 +1777,10 @@ class AsyncSpansClient:
|
|
|
1693
1777
|
Truncate image included in either input, output or metadata
|
|
1694
1778
|
|
|
1695
1779
|
from_time : typing.Optional[dt.datetime]
|
|
1696
|
-
Filter spans created from this time (ISO-8601 format).
|
|
1780
|
+
Filter spans created from this time (ISO-8601 format).
|
|
1697
1781
|
|
|
1698
1782
|
to_time : typing.Optional[dt.datetime]
|
|
1699
|
-
Filter spans created up to this time (ISO-8601 format).
|
|
1783
|
+
Filter spans created up to this time (ISO-8601 format). If not provided, defaults to current time. Must be after 'from_time'.
|
|
1700
1784
|
|
|
1701
1785
|
request_options : typing.Optional[RequestOptions]
|
|
1702
1786
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|