opik 1.3.6__tar.gz
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-1.3.6/PKG-INFO +249 -0
- opik-1.3.6/README.md +3 -0
- opik-1.3.6/pyproject.toml +6 -0
- opik-1.3.6/setup.cfg +4 -0
- opik-1.3.6/setup.py +72 -0
- opik-1.3.6/src/opik/__init__.py +45 -0
- opik-1.3.6/src/opik/_logging.py +81 -0
- opik-1.3.6/src/opik/api_key/__init__.py +13 -0
- opik-1.3.6/src/opik/api_key/base64_helper.py +27 -0
- opik-1.3.6/src/opik/api_key/opik_api_key.py +97 -0
- opik-1.3.6/src/opik/api_objects/__init__.py +0 -0
- opik-1.3.6/src/opik/api_objects/constants.py +6 -0
- opik-1.3.6/src/opik/api_objects/dataset/__init__.py +4 -0
- opik-1.3.6/src/opik/api_objects/dataset/converters.py +106 -0
- opik-1.3.6/src/opik/api_objects/dataset/dataset.py +323 -0
- opik-1.3.6/src/opik/api_objects/dataset/dataset_item.py +46 -0
- opik-1.3.6/src/opik/api_objects/experiment/__init__.py +4 -0
- opik-1.3.6/src/opik/api_objects/experiment/experiment.py +112 -0
- opik-1.3.6/src/opik/api_objects/experiment/experiment_item.py +44 -0
- opik-1.3.6/src/opik/api_objects/experiment/helpers.py +61 -0
- opik-1.3.6/src/opik/api_objects/helpers.py +54 -0
- opik-1.3.6/src/opik/api_objects/opik_client.py +784 -0
- opik-1.3.6/src/opik/api_objects/opik_query_language.py +220 -0
- opik-1.3.6/src/opik/api_objects/prompt/__init__.py +5 -0
- opik-1.3.6/src/opik/api_objects/prompt/client.py +109 -0
- opik-1.3.6/src/opik/api_objects/prompt/prompt.py +107 -0
- opik-1.3.6/src/opik/api_objects/prompt/prompt_template.py +35 -0
- opik-1.3.6/src/opik/api_objects/span.py +335 -0
- opik-1.3.6/src/opik/api_objects/trace.py +292 -0
- opik-1.3.6/src/opik/api_objects/validation_helpers.py +42 -0
- opik-1.3.6/src/opik/cli.py +69 -0
- opik-1.3.6/src/opik/config.py +286 -0
- opik-1.3.6/src/opik/configurator/__init__.py +0 -0
- opik-1.3.6/src/opik/configurator/configure.py +473 -0
- opik-1.3.6/src/opik/configurator/interactive_helpers.py +151 -0
- opik-1.3.6/src/opik/configurator/opik_rest_helpers.py +102 -0
- opik-1.3.6/src/opik/context_storage.py +78 -0
- opik-1.3.6/src/opik/datetime_helpers.py +10 -0
- opik-1.3.6/src/opik/decorator/__init__.py +0 -0
- opik-1.3.6/src/opik/decorator/arguments_helpers.py +93 -0
- opik-1.3.6/src/opik/decorator/base_track_decorator.py +523 -0
- opik-1.3.6/src/opik/decorator/error_info_collector.py +17 -0
- opik-1.3.6/src/opik/decorator/generator_wrappers.py +127 -0
- opik-1.3.6/src/opik/decorator/inspect_helpers.py +37 -0
- opik-1.3.6/src/opik/decorator/tracker.py +83 -0
- opik-1.3.6/src/opik/dict_utils.py +55 -0
- opik-1.3.6/src/opik/environment.py +131 -0
- opik-1.3.6/src/opik/error_tracking/__init__.py +11 -0
- opik-1.3.6/src/opik/error_tracking/api.py +60 -0
- opik-1.3.6/src/opik/error_tracking/before_send.py +46 -0
- opik-1.3.6/src/opik/error_tracking/environment_details.py +64 -0
- opik-1.3.6/src/opik/error_tracking/error_filtering/__init__.py +3 -0
- opik-1.3.6/src/opik/error_tracking/error_filtering/event_filter.py +9 -0
- opik-1.3.6/src/opik/error_tracking/error_filtering/filter_by_count.py +21 -0
- opik-1.3.6/src/opik/error_tracking/error_filtering/filter_chain.py +24 -0
- opik-1.3.6/src/opik/error_tracking/error_filtering/filter_chain_builder.py +23 -0
- opik-1.3.6/src/opik/error_tracking/logger_setup.py +40 -0
- opik-1.3.6/src/opik/error_tracking/shutdown_hooks.py +41 -0
- opik-1.3.6/src/opik/error_tracking/types.py +4 -0
- opik-1.3.6/src/opik/error_tracking/user_details.py +34 -0
- opik-1.3.6/src/opik/evaluation/__init__.py +3 -0
- opik-1.3.6/src/opik/evaluation/evaluation_result.py +12 -0
- opik-1.3.6/src/opik/evaluation/evaluator.py +315 -0
- opik-1.3.6/src/opik/evaluation/exception_analyzer.py +15 -0
- opik-1.3.6/src/opik/evaluation/metrics/__init__.py +32 -0
- opik-1.3.6/src/opik/evaluation/metrics/arguments_helpers.py +62 -0
- opik-1.3.6/src/opik/evaluation/metrics/base_metric.py +58 -0
- opik-1.3.6/src/opik/evaluation/metrics/exceptions.py +4 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/contains.py +63 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/equals.py +62 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/is_json.py +48 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/levenshtein_ratio.py +66 -0
- opik-1.3.6/src/opik/evaluation/metrics/heuristics/regex_match.py +60 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/answer_relevance/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/answer_relevance/metric.py +135 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/answer_relevance/template.py +132 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_precision/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_precision/metric.py +156 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_precision/template.py +124 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_recall/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_recall/metric.py +155 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/context_recall/template.py +141 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/factuality/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/factuality/metric.py +143 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/factuality/template.py +123 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/g_eval/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/g_eval/metric.py +198 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/g_eval/template.py +35 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/hallucination/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/hallucination/metric.py +144 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/hallucination/template.py +114 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/moderation/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/moderation/metric.py +125 -0
- opik-1.3.6/src/opik/evaluation/metrics/llm_judges/moderation/template.py +79 -0
- opik-1.3.6/src/opik/evaluation/metrics/models.py +8 -0
- opik-1.3.6/src/opik/evaluation/metrics/score_result.py +11 -0
- opik-1.3.6/src/opik/evaluation/models/__init__.py +7 -0
- opik-1.3.6/src/opik/evaluation/models/base_model.py +77 -0
- opik-1.3.6/src/opik/evaluation/models/litellm/__init__.py +0 -0
- opik-1.3.6/src/opik/evaluation/models/litellm/litellm_chat_model.py +220 -0
- opik-1.3.6/src/opik/evaluation/models/litellm/opik_monitor.py +74 -0
- opik-1.3.6/src/opik/evaluation/models/litellm/warning_filters.py +27 -0
- opik-1.3.6/src/opik/evaluation/models/models_factory.py +13 -0
- opik-1.3.6/src/opik/evaluation/report.py +94 -0
- opik-1.3.6/src/opik/evaluation/scorer.py +257 -0
- opik-1.3.6/src/opik/evaluation/scores_logger.py +30 -0
- opik-1.3.6/src/opik/evaluation/test_case.py +10 -0
- opik-1.3.6/src/opik/evaluation/test_result.py +12 -0
- opik-1.3.6/src/opik/evaluation/types.py +3 -0
- opik-1.3.6/src/opik/evaluation/utils.py +71 -0
- opik-1.3.6/src/opik/exceptions.py +42 -0
- opik-1.3.6/src/opik/hooks.py +13 -0
- opik-1.3.6/src/opik/httpx_client.py +46 -0
- opik-1.3.6/src/opik/id_helpers.py +43 -0
- opik-1.3.6/src/opik/integrations/__init__.py +0 -0
- opik-1.3.6/src/opik/integrations/aisuite/__init__.py +4 -0
- opik-1.3.6/src/opik/integrations/aisuite/aisuite_decorator.py +147 -0
- opik-1.3.6/src/opik/integrations/aisuite/opik_tracker.py +43 -0
- opik-1.3.6/src/opik/integrations/anthropic/__init__.py +4 -0
- opik-1.3.6/src/opik/integrations/anthropic/messages_batch_decorator.py +16 -0
- opik-1.3.6/src/opik/integrations/anthropic/messages_create_decorator.py +126 -0
- opik-1.3.6/src/opik/integrations/anthropic/opik_tracker.py +120 -0
- opik-1.3.6/src/opik/integrations/anthropic/stream_patchers.py +347 -0
- opik-1.3.6/src/opik/integrations/bedrock/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/bedrock/chunks_aggregator.py +37 -0
- opik-1.3.6/src/opik/integrations/bedrock/converse_decorator.py +118 -0
- opik-1.3.6/src/opik/integrations/bedrock/opik_tracker.py +39 -0
- opik-1.3.6/src/opik/integrations/bedrock/stream_wrappers.py +51 -0
- opik-1.3.6/src/opik/integrations/crewai/__init__.py +4 -0
- opik-1.3.6/src/opik/integrations/crewai/crewai_decorator.py +211 -0
- opik-1.3.6/src/opik/integrations/crewai/opik_tracker.py +43 -0
- opik-1.3.6/src/opik/integrations/dspy/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/dspy/callback.py +246 -0
- opik-1.3.6/src/opik/integrations/guardrails/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/guardrails/guardrails_decorator.py +86 -0
- opik-1.3.6/src/opik/integrations/guardrails/guardrails_tracker.py +39 -0
- opik-1.3.6/src/opik/integrations/haystack/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/haystack/opik_connector.py +125 -0
- opik-1.3.6/src/opik/integrations/haystack/opik_tracer.py +273 -0
- opik-1.3.6/src/opik/integrations/langchain/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/langchain/base_llm_patcher.py +20 -0
- opik-1.3.6/src/opik/integrations/langchain/openai_run_helpers.py +90 -0
- opik-1.3.6/src/opik/integrations/langchain/opik_encoder_extension.py +13 -0
- opik-1.3.6/src/opik/integrations/langchain/opik_tracer.py +316 -0
- opik-1.3.6/src/opik/integrations/llama_index/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/llama_index/callback.py +168 -0
- opik-1.3.6/src/opik/integrations/llama_index/event_parsing_utils.py +157 -0
- opik-1.3.6/src/opik/integrations/openai/__init__.py +3 -0
- opik-1.3.6/src/opik/integrations/openai/chat_completion_chunks_aggregator.py +59 -0
- opik-1.3.6/src/opik/integrations/openai/openai_decorator.py +174 -0
- opik-1.3.6/src/opik/integrations/openai/opik_tracker.py +62 -0
- opik-1.3.6/src/opik/integrations/openai/stream_patchers.py +151 -0
- opik-1.3.6/src/opik/integrations/sagemaker/__init__.py +0 -0
- opik-1.3.6/src/opik/integrations/sagemaker/auth.py +46 -0
- opik-1.3.6/src/opik/jsonable_encoder.py +92 -0
- opik-1.3.6/src/opik/logging_messages.py +56 -0
- opik-1.3.6/src/opik/message_processing/__init__.py +0 -0
- opik-1.3.6/src/opik/message_processing/api.py +0 -0
- opik-1.3.6/src/opik/message_processing/batching/__init__.py +0 -0
- opik-1.3.6/src/opik/message_processing/batching/base_batcher.py +50 -0
- opik-1.3.6/src/opik/message_processing/batching/batch_manager.py +44 -0
- opik-1.3.6/src/opik/message_processing/batching/batch_manager_constuctors.py +55 -0
- opik-1.3.6/src/opik/message_processing/batching/batchers.py +86 -0
- opik-1.3.6/src/opik/message_processing/batching/flushing_thread.py +30 -0
- opik-1.3.6/src/opik/message_processing/batching/sequence_splitter.py +58 -0
- opik-1.3.6/src/opik/message_processing/message_processors.py +210 -0
- opik-1.3.6/src/opik/message_processing/messages.py +138 -0
- opik-1.3.6/src/opik/message_processing/queue_consumer.py +48 -0
- opik-1.3.6/src/opik/message_processing/streamer.py +83 -0
- opik-1.3.6/src/opik/message_processing/streamer_constructors.py +47 -0
- opik-1.3.6/src/opik/opik_context.py +123 -0
- opik-1.3.6/src/opik/package_version.py +11 -0
- opik-1.3.6/src/opik/plugins/__init__.py +0 -0
- opik-1.3.6/src/opik/plugins/pytest/__init__.py +0 -0
- opik-1.3.6/src/opik/plugins/pytest/decorator.py +128 -0
- opik-1.3.6/src/opik/plugins/pytest/experiment_runner.py +81 -0
- opik-1.3.6/src/opik/plugins/pytest/hooks.py +94 -0
- opik-1.3.6/src/opik/plugins/pytest/summary.py +41 -0
- opik-1.3.6/src/opik/plugins/pytest/test_run_content.py +13 -0
- opik-1.3.6/src/opik/plugins/pytest/test_runs_storage.py +16 -0
- opik-1.3.6/src/opik/py.typed +0 -0
- opik-1.3.6/src/opik/rest_api/__init__.py +446 -0
- opik-1.3.6/src/opik/rest_api/automation_rule_evaluators/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/automation_rule_evaluators/client.py +724 -0
- opik-1.3.6/src/opik/rest_api/chat_completions/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/chat_completions/client.py +344 -0
- opik-1.3.6/src/opik/rest_api/check/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/check/client.py +168 -0
- opik-1.3.6/src/opik/rest_api/client.py +412 -0
- opik-1.3.6/src/opik/rest_api/core/__init__.py +47 -0
- opik-1.3.6/src/opik/rest_api/core/api_error.py +17 -0
- opik-1.3.6/src/opik/rest_api/core/client_wrapper.py +85 -0
- opik-1.3.6/src/opik/rest_api/core/datetime_utils.py +30 -0
- opik-1.3.6/src/opik/rest_api/core/file.py +70 -0
- opik-1.3.6/src/opik/rest_api/core/http_client.py +575 -0
- opik-1.3.6/src/opik/rest_api/core/jsonable_encoder.py +103 -0
- opik-1.3.6/src/opik/rest_api/core/pydantic_utilities.py +323 -0
- opik-1.3.6/src/opik/rest_api/core/query_encoder.py +60 -0
- opik-1.3.6/src/opik/rest_api/core/remove_none_from_dict.py +11 -0
- opik-1.3.6/src/opik/rest_api/core/request_options.py +35 -0
- opik-1.3.6/src/opik/rest_api/core/serialization.py +276 -0
- opik-1.3.6/src/opik/rest_api/datasets/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/datasets/client.py +1887 -0
- opik-1.3.6/src/opik/rest_api/environment.py +7 -0
- opik-1.3.6/src/opik/rest_api/errors/__init__.py +19 -0
- opik-1.3.6/src/opik/rest_api/errors/bad_request_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/conflict_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/forbidden_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/not_found_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/not_implemented_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/unauthorized_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/errors/unprocessable_entity_error.py +9 -0
- opik-1.3.6/src/opik/rest_api/experiments/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/experiments/client.py +1323 -0
- opik-1.3.6/src/opik/rest_api/feedback_definitions/__init__.py +5 -0
- opik-1.3.6/src/opik/rest_api/feedback_definitions/client.py +693 -0
- opik-1.3.6/src/opik/rest_api/feedback_definitions/types/__init__.py +5 -0
- opik-1.3.6/src/opik/rest_api/feedback_definitions/types/find_feedback_definitions_request_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/llm_provider_key/__init__.py +5 -0
- opik-1.3.6/src/opik/rest_api/llm_provider_key/client.py +718 -0
- opik-1.3.6/src/opik/rest_api/llm_provider_key/types/__init__.py +5 -0
- opik-1.3.6/src/opik/rest_api/llm_provider_key/types/provider_api_key_write_provider.py +7 -0
- opik-1.3.6/src/opik/rest_api/projects/__init__.py +8 -0
- opik-1.3.6/src/opik/rest_api/projects/client.py +1316 -0
- opik-1.3.6/src/opik/rest_api/projects/types/__init__.py +8 -0
- opik-1.3.6/src/opik/rest_api/projects/types/project_metric_request_public_interval.py +7 -0
- opik-1.3.6/src/opik/rest_api/projects/types/project_metric_request_public_metric_type.py +8 -0
- opik-1.3.6/src/opik/rest_api/prompts/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/prompts/client.py +1569 -0
- opik-1.3.6/src/opik/rest_api/spans/__init__.py +13 -0
- opik-1.3.6/src/opik/rest_api/spans/client.py +1797 -0
- opik-1.3.6/src/opik/rest_api/spans/types/__init__.py +11 -0
- opik-1.3.6/src/opik/rest_api/spans/types/find_feedback_score_names_1_request_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/spans/types/get_span_stats_request_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/spans/types/get_spans_by_project_request_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/system_usage/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/system_usage/client.py +413 -0
- opik-1.3.6/src/opik/rest_api/traces/__init__.py +2 -0
- opik-1.3.6/src/opik/rest_api/traces/client.py +1673 -0
- opik-1.3.6/src/opik/rest_api/types/__init__.py +401 -0
- opik-1.3.6/src/opik/rest_api/types/assistant_message.py +29 -0
- opik-1.3.6/src/opik/rest_api/types/assistant_message_role.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/auth_details_holder.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator.py +65 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_llm_as_judge.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_llm_as_judge_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_llm_as_judge_write.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_object_public.py +65 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_public.py +65 -0
- opik-1.3.6/src/opik/rest_api/types/automation_rule_evaluator_write.py +48 -0
- opik-1.3.6/src/opik/rest_api/types/avg_value_stat_public.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/batch_delete.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/bi_information.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/bi_information_response.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_definition.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_definition_create.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_definition_public.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_definition_update.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_detail.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_detail_create.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_detail_public.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/categorical_feedback_detail_update.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/chat_completion_choice.py +26 -0
- opik-1.3.6/src/opik/rest_api/types/chat_completion_response.py +28 -0
- opik-1.3.6/src/opik/rest_api/types/chunked_output_json_node.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/chunked_output_json_node_type.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/column.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/column_compare.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/column_compare_types_item.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/column_public.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/column_public_types_item.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/column_types_item.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/completion_tokens_details.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/count_value_stat_public.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/data_point_number_public.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/dataset.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_batch.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_compare.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_compare_source.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_page_compare.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_page_public.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_public.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_public_source.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_source.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_write.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_item_write_source.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/dataset_public.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/delete_feedback_score.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/delta.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/delta_role.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/error_info.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/error_info_public.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/error_info_write.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/error_message.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/error_message_detail.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/error_message_public.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/experiment.py +36 -0
- opik-1.3.6/src/opik/rest_api/types/experiment_item.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/experiment_item_compare.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/experiment_item_public.py +29 -0
- opik-1.3.6/src/opik/rest_api/types/experiment_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/experiment_public.py +36 -0
- opik-1.3.6/src/opik/rest_api/types/feedback.py +83 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_create.py +60 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_definition_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_object_public.py +85 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_public.py +83 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_average.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_average_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_batch.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_batch_item.py +32 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_batch_item_source.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_compare.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_compare_source.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_names.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_public.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_public_source.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_score_source.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/feedback_update.py +60 -0
- opik-1.3.6/src/opik/rest_api/types/function.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/function_call.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/json_node.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/json_node_compare.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/json_node_detail.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/json_node_public.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/json_node_write.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/json_object_schema.py +34 -0
- opik-1.3.6/src/opik/rest_api/types/json_schema.py +28 -0
- opik-1.3.6/src/opik/rest_api/types/json_schema_element.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_code.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_code_public.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_code_write.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message_public.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message_public_role.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message_role.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message_write.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_message_write_role.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_model_parameters.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_model_parameters_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_model_parameters_write.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema.py +24 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema_public.py +24 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema_public_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema_write.py +24 -0
- opik-1.3.6/src/opik/rest_api/types/llm_as_judge_output_schema_write_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/message.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_definition.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_definition_create.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_definition_public.py +27 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_definition_update.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_detail.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_detail_create.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_detail_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/numerical_feedback_detail_update.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/page_columns.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/percentage_value_stat_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/percentage_values.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/percentage_values_public.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/project.py +35 -0
- opik-1.3.6/src/opik/rest_api/types/project_metric_response_public.py +29 -0
- opik-1.3.6/src/opik/rest_api/types/project_metric_response_public_interval.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/project_metric_response_public_metric_type.py +8 -0
- opik-1.3.6/src/opik/rest_api/types/project_page_public.py +30 -0
- opik-1.3.6/src/opik/rest_api/types/project_public.py +35 -0
- opik-1.3.6/src/opik/rest_api/types/project_stat_item_object_public.py +78 -0
- opik-1.3.6/src/opik/rest_api/types/project_stats_public.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/prompt.py +35 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_detail.py +31 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_public.py +29 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version.py +39 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_detail.py +39 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_link.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_link_public.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_link_write.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/prompt_version_public.py +38 -0
- opik-1.3.6/src/opik/rest_api/types/provider_api_key.py +30 -0
- opik-1.3.6/src/opik/rest_api/types/provider_api_key_provider.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/provider_api_key_public.py +30 -0
- opik-1.3.6/src/opik/rest_api/types/provider_api_key_public_provider.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/response_format.py +24 -0
- opik-1.3.6/src/opik/rest_api/types/response_format_type.py +7 -0
- opik-1.3.6/src/opik/rest_api/types/results_number_public.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/score_name.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/span.py +57 -0
- opik-1.3.6/src/opik/rest_api/types/span_batch.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/span_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/span_public.py +52 -0
- opik-1.3.6/src/opik/rest_api/types/span_public_type.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/span_type.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/span_write.py +46 -0
- opik-1.3.6/src/opik/rest_api/types/span_write_type.py +5 -0
- opik-1.3.6/src/opik/rest_api/types/stream_options.py +21 -0
- opik-1.3.6/src/opik/rest_api/types/tool.py +23 -0
- opik-1.3.6/src/opik/rest_api/types/tool_call.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/trace.py +50 -0
- opik-1.3.6/src/opik/rest_api/types/trace_batch.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/trace_count_response.py +22 -0
- opik-1.3.6/src/opik/rest_api/types/trace_page_public.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/trace_public.py +45 -0
- opik-1.3.6/src/opik/rest_api/types/trace_write.py +37 -0
- opik-1.3.6/src/opik/rest_api/types/usage.py +25 -0
- opik-1.3.6/src/opik/rest_api/types/workspace_trace_count.py +22 -0
- opik-1.3.6/src/opik/rest_client_configurator/__init__.py +3 -0
- opik-1.3.6/src/opik/rest_client_configurator/api.py +21 -0
- opik-1.3.6/src/opik/rest_client_configurator/public_methods_patcher.py +10 -0
- opik-1.3.6/src/opik/rest_client_configurator/retry_decorators.py +14 -0
- opik-1.3.6/src/opik/semantic_version.py +240 -0
- opik-1.3.6/src/opik/synchronization.py +66 -0
- opik-1.3.6/src/opik/types.py +79 -0
- opik-1.3.6/src/opik/url_helpers.py +84 -0
- opik-1.3.6/src/opik/validation/__init__.py +0 -0
- opik-1.3.6/src/opik/validation/feedback_score.py +47 -0
- opik-1.3.6/src/opik/validation/result.py +28 -0
- opik-1.3.6/src/opik/validation/usage.py +79 -0
- opik-1.3.6/src/opik/validation/validator.py +9 -0
- opik-1.3.6/src/opik.egg-info/PKG-INFO +249 -0
- opik-1.3.6/src/opik.egg-info/SOURCES.txt +430 -0
- opik-1.3.6/src/opik.egg-info/dependency_links.txt +1 -0
- opik-1.3.6/src/opik.egg-info/entry_points.txt +5 -0
- opik-1.3.6/src/opik.egg-info/not-zip-safe +1 -0
- opik-1.3.6/src/opik.egg-info/requires.txt +16 -0
- opik-1.3.6/src/opik.egg-info/top_level.txt +1 -0
opik-1.3.6/PKG-INFO
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: opik
|
|
3
|
+
Version: 1.3.6
|
|
4
|
+
Summary: Comet tool for logging and evaluating LLM traces
|
|
5
|
+
Home-page: https://www.comet.com
|
|
6
|
+
Author: Comet ML Inc.
|
|
7
|
+
Author-email: mail@comet.com
|
|
8
|
+
License: Apache 2.0 License
|
|
9
|
+
Project-URL: Source code, https://github.com/comet-ml/opik
|
|
10
|
+
Keywords: opik
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: click
|
|
25
|
+
Requires-Dist: httpx<0.28.0
|
|
26
|
+
Requires-Dist: levenshtein<1.0.0
|
|
27
|
+
Requires-Dist: litellm
|
|
28
|
+
Requires-Dist: openai<2.0.0
|
|
29
|
+
Requires-Dist: pydantic-settings<3.0.0,>=2.0.0
|
|
30
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
31
|
+
Requires-Dist: pytest
|
|
32
|
+
Requires-Dist: rich
|
|
33
|
+
Requires-Dist: sentry_sdk>=2.0.0
|
|
34
|
+
Requires-Dist: tenacity
|
|
35
|
+
Requires-Dist: tokenizers<0.21.0; python_version < "3.9.0"
|
|
36
|
+
Requires-Dist: tqdm
|
|
37
|
+
Requires-Dist: uuid6
|
|
38
|
+
Dynamic: author
|
|
39
|
+
Dynamic: author-email
|
|
40
|
+
Dynamic: classifier
|
|
41
|
+
Dynamic: description
|
|
42
|
+
Dynamic: description-content-type
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: keywords
|
|
45
|
+
Dynamic: license
|
|
46
|
+
Dynamic: project-url
|
|
47
|
+
Dynamic: requires-dist
|
|
48
|
+
Dynamic: requires-python
|
|
49
|
+
Dynamic: summary
|
|
50
|
+
|
|
51
|
+
<h1 align="center" style="border-bottom: none">
|
|
52
|
+
<div>
|
|
53
|
+
<a href="https://www.comet.com/site/products/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=header_img&utm_campaign=opik"><picture>
|
|
54
|
+
<source media="(prefers-color-scheme: dark)" srcset="/apps/opik-documentation/documentation/static/img/logo-dark-mode.svg">
|
|
55
|
+
<source media="(prefers-color-scheme: light)" srcset="/apps/opik-documentation/documentation/static/img/opik-logo.svg">
|
|
56
|
+
<img alt="Comet Opik logo" src="/apps/opik-documentation/documentation/static/img/opik-logo.svg" width="200" />
|
|
57
|
+
</picture></a>
|
|
58
|
+
<br>
|
|
59
|
+
Opik
|
|
60
|
+
</div>
|
|
61
|
+
Open source LLM evaluation framework<br>
|
|
62
|
+
</h1>
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
From RAG chatbots to code assistants to complex agentic pipelines and beyond, build LLM systems that run better, faster, and cheaper with tracing, evaluations, and dashboards.
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
<div align="center">
|
|
69
|
+
|
|
70
|
+
[](https://pypi.org/project/opik/)
|
|
71
|
+
[](https://github.com/comet-ml/opik/blob/main/LICENSE)
|
|
72
|
+
[](https://github.com/comet-ml/opik/actions/workflows/build_apps.yml)
|
|
73
|
+
<a target="_blank" href="https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/opik_quickstart.ipynb">
|
|
74
|
+
|
|
75
|
+
<!-- <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open Quickstart In Colab"/> -->
|
|
76
|
+
</a>
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<p align="center">
|
|
81
|
+
<a href="https://www.comet.com/site/products/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=website_button&utm_campaign=opik"><b>Website</b></a> •
|
|
82
|
+
<a href="https://chat.comet.com"><b>Slack community</b></a> •
|
|
83
|
+
<a href="https://x.com/Cometml"><b>Twitter</b></a> •
|
|
84
|
+
<a href="https://www.comet.com/docs/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=docs_button&utm_campaign=opik"><b>Documentation</b></a>
|
|
85
|
+
</p>
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
## 🚀 What is Opik?
|
|
90
|
+
|
|
91
|
+
Opik is an open-source platform for evaluating, testing and monitoring LLM applications. Built by [Comet](https://www.comet.com?from=llm&utm_source=opik&utm_medium=github&utm_content=what_is_opik_link&utm_campaign=opik).
|
|
92
|
+
|
|
93
|
+
<br>
|
|
94
|
+
|
|
95
|
+
You can use Opik for:
|
|
96
|
+
* **Development:**
|
|
97
|
+
|
|
98
|
+
* **Tracing:** Track all LLM calls and traces during development and production ([Quickstart](https://www.comet.com/docs/opik/quickstart/?from=llm&utm_source=opik&utm_medium=github&utm_content=quickstart_link&utm_campaign=opik), [Integrations](https://www.comet.com/docs/opik/tracing/integrations/overview/?from=llm&utm_source=opik&utm_medium=github&utm_content=integrations_link&utm_campaign=opik)
|
|
99
|
+
|
|
100
|
+
* **Annotations:** Annotate your LLM calls by logging feedback scores using the [Python SDK](https://www.comet.com/docs/opik/tracing/annotate_traces/#annotating-traces-and-spans-using-the-sdk?from=llm&utm_source=opik&utm_medium=github&utm_content=sdk_link&utm_campaign=opik) or the [UI](https://www.comet.com/docs/opik/tracing/annotate_traces/#annotating-traces-through-the-ui?from=llm&utm_source=opik&utm_medium=github&utm_content=ui_link&utm_campaign=opik).
|
|
101
|
+
|
|
102
|
+
* **Playground:**: Try out different prompts and models in the [prompt playground](https://www.comet.com/docs/opik/evaluation/playground/?from=llm&utm_source=opik&utm_medium=github&utm_content=playground_link&utm_campaign=opik)
|
|
103
|
+
|
|
104
|
+
* **Evaluation**: Automate the evaluation process of your LLM application:
|
|
105
|
+
|
|
106
|
+
* **Datasets and Experiments**: Store test cases and run experiments ([Datasets](https://www.comet.com/docs/opik/evaluation/manage_datasets/?from=llm&utm_source=opik&utm_medium=github&utm_content=datasets_link&utm_campaign=opik), [Evaluate your LLM Application](https://www.comet.com/docs/opik/evaluation/evaluate_your_llm/?from=llm&utm_source=opik&utm_medium=github&utm_content=eval_link&utm_campaign=opik))
|
|
107
|
+
|
|
108
|
+
* **LLM as a judge metrics**: Use Opik's LLM as a judge metric for complex issues like [hallucination detection](https://www.comet.com/docs/opik/evaluation/metrics/hallucination/?from=llm&utm_source=opik&utm_medium=github&utm_content=hallucination_link&utm_campaign=opik), [moderation](https://www.comet.com/docs/opik/evaluation/metrics/moderation/?from=llm&utm_source=opik&utm_medium=github&utm_content=moderation_link&utm_campaign=opik) and RAG evaluation ([Answer Relevance](https://www.comet.com/docs/opik/evaluation/metrics/answer_relevance/?from=llm&utm_source=opik&utm_medium=github&utm_content=alex_link&utm_campaign=opik), [Context Precision](https://www.comet.com/docs/opik/evaluation/metrics/context_precision/?from=llm&utm_source=opik&utm_medium=github&utm_content=context_link&utm_campaign=opik)
|
|
109
|
+
|
|
110
|
+
* **CI/CD integration**: Run evaluations as part of your CI/CD pipeline using our [PyTest integration](https://www.comet.com/docs/opik/testing/pytest_integration/?from=llm&utm_source=opik&utm_medium=github&utm_content=pytest_link&utm_campaign=opik)
|
|
111
|
+
|
|
112
|
+
* **Production Monitoring**:
|
|
113
|
+
|
|
114
|
+
* **Log all your production traces**: Opik has been designed to support high volumes of traces, making it easy to monitor your production applications.
|
|
115
|
+
|
|
116
|
+
* **Monitoring dashboards**: Review your feedback scores, trace count and tokens over time in the [Opik Dashboard](https://www.comet.com/docs/opik/self-host/opik_dashboard/?from=llm&utm_source=opik&utm_medium=github&utm_content=dashboard_link&utm_campaign=opik).
|
|
117
|
+
|
|
118
|
+
> [!TIP]
|
|
119
|
+
> If you are looking for features that Opik doesn't have today, please raise a new [Feature request](https://github.com/comet-ml/opik/issues/new/choose) 🚀
|
|
120
|
+
|
|
121
|
+
<br>
|
|
122
|
+
|
|
123
|
+
## 🛠️ Installation
|
|
124
|
+
Opik is available as a fully open source local installation or using Comet.com as a hosted solution.
|
|
125
|
+
The easiest way to get started with Opik is by creating a free Comet account at [comet.com](https://www.comet.com/signup?from=llm&utm_source=opik&utm_medium=github&utm_content=install&utm_campaign=opik).
|
|
126
|
+
|
|
127
|
+
If you'd like to self-host Opik, you can do so by cloning the repository and starting the platform using Docker Compose:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Clone the Opik repository
|
|
131
|
+
git clone https://github.com/comet-ml/opik.git
|
|
132
|
+
|
|
133
|
+
# Navigate to the opik/deployment/docker-compose directory
|
|
134
|
+
cd opik/deployment/docker-compose
|
|
135
|
+
|
|
136
|
+
# Start the Opik platform
|
|
137
|
+
docker compose up --detach
|
|
138
|
+
|
|
139
|
+
# You can now visit http://localhost:5173 on your browser!
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For more information about the different deployment options, please see our deployment guides:
|
|
143
|
+
|
|
144
|
+
| Installation methods | Docs link |
|
|
145
|
+
| ------------------- | --------- |
|
|
146
|
+
| Local instance | [](https://www.comet.com/docs/opik/self-host/local_deployment?from=llm&utm_source=opik&utm_medium=github&utm_content=self_host_link&utm_campaign=opik)
|
|
147
|
+
| Kubernetes | [](https://www.comet.com/docs/opik/self-host/kubernetes/#kubernetes-installation?from=llm&utm_source=opik&utm_medium=github&utm_content=kubernetes_link&utm_campaign=opik)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## 🏁 Get Started
|
|
151
|
+
|
|
152
|
+
To get started, you will need to first install the Python SDK:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pip install opik
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Once the SDK is installed, you can configure it by running the `opik configure` command:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
opik configure
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This will allow you to configure Opik locally by setting the correct local server address or if you're using the Cloud platform by setting the API Key
|
|
165
|
+
|
|
166
|
+
> [!TIP]
|
|
167
|
+
> You can also call the `opik.configure(use_local=True)` method from your Python code to configure the SDK to run on the local installation.
|
|
168
|
+
|
|
169
|
+
You are now ready to start logging traces using the [Python SDK](https://www.comet.com/docs/opik/python-sdk-reference/?from=llm&utm_source=opik&utm_medium=github&utm_content=sdk_link2&utm_campaign=opik).
|
|
170
|
+
|
|
171
|
+
### 📝 Logging Traces
|
|
172
|
+
|
|
173
|
+
The easiest way to get started is to use one of our integrations. Opik supports:
|
|
174
|
+
|
|
175
|
+
| Integration | Description | Documentation | Try in Colab |
|
|
176
|
+
|-------------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
177
|
+
| OpenAI | Log traces for all OpenAI LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/openai/?utm_source=opik&utm_medium=github&utm_content=openai_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/openai.ipynb) |
|
|
178
|
+
| LiteLLM | Call any LLM model using the OpenAI format | [Documentation](/tracing/integrations/litellm.md) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/litellm.ipynb) |
|
|
179
|
+
| LangChain | Log traces for all LangChain LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/langchain/?utm_source=opik&utm_medium=github&utm_content=langchain_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/langchain.ipynb) |
|
|
180
|
+
| Haystack | Log traces for all Haystack calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/haystack/?utm_source=opik&utm_medium=github&utm_content=haystack_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/haystack.ipynb) |
|
|
181
|
+
| Anthropic | Log traces for all Anthropic LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/anthropic?utm_source=opik&utm_medium=github&utm_content=anthropic_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/anthropic.ipynb) |
|
|
182
|
+
| Bedrock | Log traces for all Bedrock LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/bedrock?utm_source=opik&utm_medium=github&utm_content=bedrock_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/bedrock.ipynb) |
|
|
183
|
+
| CrewAI | Log traces for all CrewAI calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/crewai?utm_source=opik&utm_medium=github&utm_content=crewai_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/crewai.ipynb) |
|
|
184
|
+
| DSPy | Log traces for all DSPy runs | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/dspy?utm_source=opik&utm_medium=github&utm_content=dspy_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb) |
|
|
185
|
+
| Gemini | Log traces for all Gemini LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/gemini?utm_source=opik&utm_medium=github&utm_content=gemini_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/gemini.ipynb) |
|
|
186
|
+
| Groq | Log traces for all Groq LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/groq?utm_source=opik&utm_medium=github&utm_content=groq_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/groq.ipynb) |
|
|
187
|
+
| LangGraph | Log traces for all LangGraph executions | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/langgraph/?utm_source=opik&utm_medium=github&utm_content=langchain_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/langgraph.ipynb) |
|
|
188
|
+
| LlamaIndex | Log traces for all LlamaIndex LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/llama_index?utm_source=opik&utm_medium=github&utm_content=llama_index_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/llama-index.ipynb) |
|
|
189
|
+
| Ollama | Log traces for all Ollama LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/ollama?utm_source=opik&utm_medium=github&utm_content=ollama_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/ollama.ipynb) |
|
|
190
|
+
| Predibase | Fine-tune and serve open-source Large Language Models | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/predibase?utm_source=opik&utm_medium=github&utm_content=predibase_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/predibase.ipynb) |
|
|
191
|
+
| Ragas | Evaluation framework for your Retrieval Augmented Generation (RAG) pipelines | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/ragas?utm_source=opik&utm_medium=github&utm_content=ragas_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/ragas.ipynb) |
|
|
192
|
+
| watsonx | Log traces for all watsonx LLM calls | [Documentation](https://www.comet.com/docs/opik/tracing/integrations/watsonx?utm_source=opik&utm_medium=github&utm_content=watsonx_link&utm_campaign=opik) | [](https://colab.research.google.com/github/comet-ml/opik/blob/master/apps/opik-documentation/documentation/docs/cookbook/watsonx.ipynb) |
|
|
193
|
+
|
|
194
|
+
> [!TIP]
|
|
195
|
+
> If the framework you are using is not listed above, feel free to [open an issue](https://github.com/comet-ml/opik/issues) or submit a PR with the integration.
|
|
196
|
+
|
|
197
|
+
If you are not using any of the frameworks above, you can also use the `track` function decorator to [log traces](https://www.comet.com/docs/opik/tracing/log_traces/?from=llm&utm_source=opik&utm_medium=github&utm_content=traces_link&utm_campaign=opik):
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
import opik
|
|
201
|
+
|
|
202
|
+
opik.configure(use_local=True) # Run locally
|
|
203
|
+
|
|
204
|
+
@opik.track
|
|
205
|
+
def my_llm_function(user_question: str) -> str:
|
|
206
|
+
# Your LLM code here
|
|
207
|
+
|
|
208
|
+
return "Hello"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
> [!TIP]
|
|
212
|
+
> The track decorator can be used in conjunction with any of our integrations and can also be used to track nested function calls.
|
|
213
|
+
|
|
214
|
+
### 🧑⚖️ LLM as a Judge metrics
|
|
215
|
+
|
|
216
|
+
The Python Opik SDK includes a number of LLM as a judge metrics to help you evaluate your LLM application. Learn more about it in the [metrics documentation](https://www.comet.com/docs/opik/evaluation/metrics/overview/?from=llm&utm_source=opik&utm_medium=github&utm_content=metrics_2_link&utm_campaign=opik).
|
|
217
|
+
|
|
218
|
+
To use them, simply import the relevant metric and use the `score` function:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from opik.evaluation.metrics import Hallucination
|
|
222
|
+
|
|
223
|
+
metric = Hallucination()
|
|
224
|
+
score = metric.score(
|
|
225
|
+
input="What is the capital of France?",
|
|
226
|
+
output="Paris",
|
|
227
|
+
context=["France is a country in Europe."]
|
|
228
|
+
)
|
|
229
|
+
print(score)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Opik also includes a number of pre-built heuristic metrics as well as the ability to create your own. Learn more about it in the [metrics documentation](https://www.comet.com/docs/opik/evaluation/metrics/overview?from=llm&utm_source=opik&utm_medium=github&utm_content=metrics_3_link&utm_campaign=opik).
|
|
233
|
+
|
|
234
|
+
### 🔍 Evaluating your LLM Application
|
|
235
|
+
|
|
236
|
+
Opik allows you to evaluate your LLM application during development through [Datasets](https://www.comet.com/docs/opik/evaluation/manage_datasets/?from=llm&utm_source=opik&utm_medium=github&utm_content=datasets_2_link&utm_campaign=opik) and [Experiments](https://www.comet.com/docs/opik/evaluation/evaluate_your_llm/?from=llm&utm_source=opik&utm_medium=github&utm_content=experiments_link&utm_campaign=opik).
|
|
237
|
+
|
|
238
|
+
You can also run evaluations as part of your CI/CD pipeline using our [PyTest integration](https://www.comet.com/docs/opik/testing/pytest_integration/?from=llm&utm_source=opik&utm_medium=github&utm_content=pytest_2_link&utm_campaign=opik).
|
|
239
|
+
|
|
240
|
+
## 🤝 Contributing
|
|
241
|
+
|
|
242
|
+
There are many ways to contribute to Opik:
|
|
243
|
+
|
|
244
|
+
* Submit [bug reports](https://github.com/comet-ml/opik/issues) and [feature requests](https://github.com/comet-ml/opik/issues)
|
|
245
|
+
* Review the documentation and submit [Pull Requests](https://github.com/comet-ml/opik/pulls) to improve it
|
|
246
|
+
* Speaking or writing about Opik and [letting us know](https://chat.comet.com)
|
|
247
|
+
* Upvoting [popular feature requests](https://github.com/comet-ml/opik/issues?q=is%3Aissue+is%3Aopen+label%3A%22enhancement%22) to show your support
|
|
248
|
+
|
|
249
|
+
To learn more about how to contribute to Opik, please see our [contributing guidelines](CONTRIBUTING.md).
|
opik-1.3.6/README.md
ADDED
opik-1.3.6/setup.cfg
ADDED
opik-1.3.6/setup.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from setuptools import find_packages, setup
|
|
4
|
+
|
|
5
|
+
project_urls = {"Source code": "https://github.com/comet-ml/opik"}
|
|
6
|
+
|
|
7
|
+
HERE = os.path.abspath(os.path.dirname(__file__))
|
|
8
|
+
version = os.environ.get("VERSION")
|
|
9
|
+
if version is None:
|
|
10
|
+
version_file = os.path.join(HERE, "..", "..", "version.txt")
|
|
11
|
+
if os.path.exists(version_file):
|
|
12
|
+
with open(version_file) as fp:
|
|
13
|
+
version = fp.read().strip()
|
|
14
|
+
else:
|
|
15
|
+
version = "0.0.1"
|
|
16
|
+
|
|
17
|
+
setup(
|
|
18
|
+
author="Comet ML Inc.",
|
|
19
|
+
author_email="mail@comet.com",
|
|
20
|
+
python_requires=">=3.8",
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: Apache Software License",
|
|
25
|
+
"Natural Language :: English",
|
|
26
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.8",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
],
|
|
34
|
+
description="Comet tool for logging and evaluating LLM traces",
|
|
35
|
+
long_description=open(
|
|
36
|
+
os.path.join(HERE, "..", "..", "README.md"), encoding="utf-8"
|
|
37
|
+
).read(),
|
|
38
|
+
long_description_content_type="text/markdown",
|
|
39
|
+
install_requires=[
|
|
40
|
+
"click",
|
|
41
|
+
"httpx<0.28.0",
|
|
42
|
+
"levenshtein<1.0.0",
|
|
43
|
+
"litellm",
|
|
44
|
+
"openai<2.0.0",
|
|
45
|
+
"pydantic-settings>=2.0.0,<3.0.0",
|
|
46
|
+
"pydantic>=2.0.0,<3.0.0",
|
|
47
|
+
"pytest",
|
|
48
|
+
"rich",
|
|
49
|
+
"sentry_sdk>=2.0.0",
|
|
50
|
+
"tenacity",
|
|
51
|
+
"tokenizers<0.21.0 ; python_version<'3.9.0'", # no 3.8 support starting from 0.21.0
|
|
52
|
+
"tqdm",
|
|
53
|
+
"uuid6",
|
|
54
|
+
],
|
|
55
|
+
entry_points={
|
|
56
|
+
"pytest11": [
|
|
57
|
+
"opik = opik.plugins.pytest.hooks",
|
|
58
|
+
],
|
|
59
|
+
"console_scripts": ["opik = opik.cli:cli"],
|
|
60
|
+
},
|
|
61
|
+
keywords="opik",
|
|
62
|
+
name="opik",
|
|
63
|
+
include_package_data=True,
|
|
64
|
+
package_data={"opik": ["py.typed"]},
|
|
65
|
+
packages=find_packages("src"),
|
|
66
|
+
package_dir={"": "src"},
|
|
67
|
+
url="https://www.comet.com",
|
|
68
|
+
project_urls=project_urls,
|
|
69
|
+
version=version,
|
|
70
|
+
zip_safe=False,
|
|
71
|
+
license="Apache 2.0 License",
|
|
72
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from . import _logging, error_tracking, package_version
|
|
2
|
+
from .api_objects.dataset import Dataset
|
|
3
|
+
from .api_objects.experiment.experiment_item import (
|
|
4
|
+
ExperimentItemContent,
|
|
5
|
+
ExperimentItemReferences,
|
|
6
|
+
)
|
|
7
|
+
from .api_objects.opik_client import Opik
|
|
8
|
+
from .api_objects.prompt import Prompt
|
|
9
|
+
from .api_objects.span import Span
|
|
10
|
+
from .api_objects.trace import Trace
|
|
11
|
+
from .configurator.configure import configure
|
|
12
|
+
from .decorator.tracker import flush_tracker, track
|
|
13
|
+
from .evaluation import evaluate, evaluate_experiment, evaluate_prompt
|
|
14
|
+
from .integrations.sagemaker import auth as sagemaker_auth
|
|
15
|
+
from .plugins.pytest.decorator import llm_unit
|
|
16
|
+
|
|
17
|
+
_logging.setup()
|
|
18
|
+
|
|
19
|
+
__version__ = package_version.VERSION
|
|
20
|
+
__all__ = [
|
|
21
|
+
"__version__",
|
|
22
|
+
"evaluate",
|
|
23
|
+
"evaluate_prompt",
|
|
24
|
+
"evaluate_experiment",
|
|
25
|
+
"ExperimentItemContent",
|
|
26
|
+
"ExperimentItemReferences",
|
|
27
|
+
"track",
|
|
28
|
+
"flush_tracker",
|
|
29
|
+
"Opik",
|
|
30
|
+
"Trace",
|
|
31
|
+
"Span",
|
|
32
|
+
"Dataset",
|
|
33
|
+
"llm_unit",
|
|
34
|
+
"configure",
|
|
35
|
+
"Prompt",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
sagemaker_auth.setup_aws_sagemaker_session_hook()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if (
|
|
42
|
+
error_tracking.enabled_in_config()
|
|
43
|
+
and error_tracking.randomized_should_enable_reporting()
|
|
44
|
+
):
|
|
45
|
+
error_tracking.setup_sentry_error_tracker()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from typing import Callable, Any, Optional
|
|
2
|
+
import functools
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from . import config
|
|
7
|
+
|
|
8
|
+
CONSOLE_MSG_FORMAT = "OPIK: %(message)s"
|
|
9
|
+
DEBUG_MSG_FORMAT = "%(asctime)s [%(process)d-%(processName)s:%(thread)d] %(relativeCreated)d OPIK %(levelname)s [%(filename)s:%(lineno)d]: %(message)s"
|
|
10
|
+
# 1MB, to prevent logger from frequent writing hundreds of megabytes in DEBUG mode
|
|
11
|
+
# when batches are big and payloads are heavy (e.g. base64 encoded data)
|
|
12
|
+
MAX_MESSAGE_LENGTH = 1024 * 1024
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TruncateFormatter(logging.Formatter):
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
fmt: str,
|
|
19
|
+
datefmt: Optional[str] = None,
|
|
20
|
+
max_length: int = MAX_MESSAGE_LENGTH,
|
|
21
|
+
) -> None:
|
|
22
|
+
super().__init__(fmt, datefmt)
|
|
23
|
+
self.max_length = max_length
|
|
24
|
+
|
|
25
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
26
|
+
result = super().format(record)
|
|
27
|
+
|
|
28
|
+
if len(result) > self.max_length:
|
|
29
|
+
result = result[: self.max_length] + "... (truncated)."
|
|
30
|
+
|
|
31
|
+
return result
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def setup() -> None:
|
|
35
|
+
opik_root_logger = logging.getLogger("opik")
|
|
36
|
+
opik_root_logger.propagate = False
|
|
37
|
+
|
|
38
|
+
config_ = config.OpikConfig()
|
|
39
|
+
|
|
40
|
+
console_handler = logging.StreamHandler()
|
|
41
|
+
console_level = config_.console_logging_level
|
|
42
|
+
console_handler.setLevel(console_level)
|
|
43
|
+
message_format = (
|
|
44
|
+
DEBUG_MSG_FORMAT if console_level == "DEBUG" else CONSOLE_MSG_FORMAT
|
|
45
|
+
)
|
|
46
|
+
console_handler.setFormatter(TruncateFormatter(message_format))
|
|
47
|
+
opik_root_logger.addHandler(console_handler)
|
|
48
|
+
|
|
49
|
+
root_level = console_handler.level
|
|
50
|
+
|
|
51
|
+
if config_.file_logging_level is not None:
|
|
52
|
+
file_handler = logging.FileHandler(config_.logging_file)
|
|
53
|
+
file_level = config_.file_logging_level
|
|
54
|
+
file_handler.setLevel(file_level)
|
|
55
|
+
file_handler.setFormatter(TruncateFormatter(DEBUG_MSG_FORMAT))
|
|
56
|
+
opik_root_logger.addHandler(file_handler)
|
|
57
|
+
|
|
58
|
+
root_level = min(root_level, file_handler.level)
|
|
59
|
+
|
|
60
|
+
opik_root_logger.setLevel(level=root_level)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def convert_exception_to_log_message(
|
|
64
|
+
message: str,
|
|
65
|
+
logger: logging.Logger,
|
|
66
|
+
return_on_exception: Any = None,
|
|
67
|
+
logging_level: int = logging.ERROR,
|
|
68
|
+
**log_kwargs: Any,
|
|
69
|
+
) -> Callable:
|
|
70
|
+
def decorator(function: Callable) -> Any:
|
|
71
|
+
@functools.wraps(function)
|
|
72
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
73
|
+
try:
|
|
74
|
+
return function(*args, **kwargs)
|
|
75
|
+
except Exception:
|
|
76
|
+
logger.log(logging_level, message, **log_kwargs)
|
|
77
|
+
return return_on_exception
|
|
78
|
+
|
|
79
|
+
return wrapper
|
|
80
|
+
|
|
81
|
+
return decorator
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# *******************************************************
|
|
3
|
+
# ____ _ _
|
|
4
|
+
# / ___|___ _ __ ___ ___| |_ _ __ ___ | |
|
|
5
|
+
# | | / _ \| '_ ` _ \ / _ \ __| | '_ ` _ \| |
|
|
6
|
+
# | |__| (_) | | | | | | __/ |_ _| | | | | | |
|
|
7
|
+
# \____\___/|_| |_| |_|\___|\__(_)_| |_| |_|_|
|
|
8
|
+
#
|
|
9
|
+
# Sign up for free at https://www.comet.com
|
|
10
|
+
# Copyright (C) 2015-2024 Comet ML INC
|
|
11
|
+
# This file can not be copied and/or distributed
|
|
12
|
+
# without the express permission of Comet ML Inc.
|
|
13
|
+
# *******************************************************
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# *******************************************************
|
|
3
|
+
# ____ _ _
|
|
4
|
+
# / ___|___ _ __ ___ ___| |_ _ __ ___ | |
|
|
5
|
+
# | | / _ \| '_ ` _ \ / _ \ __| | '_ ` _ \| |
|
|
6
|
+
# | |__| (_) | | | | | | __/ |_ _| | | | | | |
|
|
7
|
+
# \____\___/|_| |_| |_|\___|\__(_)_| |_| |_|_|
|
|
8
|
+
#
|
|
9
|
+
# Sign up for free at https://www.comet.com
|
|
10
|
+
# Copyright (C) 2015-2024 Comet ML INC
|
|
11
|
+
# This file can not be copied and/or distributed
|
|
12
|
+
# without the express permission of Comet ML Inc.
|
|
13
|
+
# *******************************************************
|
|
14
|
+
import base64
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def decode_base64(data: str, fix_padding: bool = True) -> bytes:
|
|
18
|
+
if fix_padding:
|
|
19
|
+
missing_padding = len(data) % 4
|
|
20
|
+
if missing_padding and data.endswith("="):
|
|
21
|
+
# wrong padding
|
|
22
|
+
data = data.replace("=", "")
|
|
23
|
+
return decode_base64(data)
|
|
24
|
+
|
|
25
|
+
if missing_padding:
|
|
26
|
+
data += "=" * (4 - missing_padding)
|
|
27
|
+
return base64.b64decode(data, validate=True)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# *******************************************************
|
|
3
|
+
# ____ _ _
|
|
4
|
+
# / ___|___ _ __ ___ ___| |_ _ __ ___ | |
|
|
5
|
+
# | | / _ \| '_ ` _ \ / _ \ __| | '_ ` _ \| |
|
|
6
|
+
# | |__| (_) | | | | | | __/ |_ _| | | | | | |
|
|
7
|
+
# \____\___/|_| |_| |_|\___|\__(_)_| |_| |_|_|
|
|
8
|
+
#
|
|
9
|
+
# Sign up for free at https://www.comet.com
|
|
10
|
+
# Copyright (C) 2015-2024 Comet ML INC
|
|
11
|
+
# This file can not be copied and/or distributed
|
|
12
|
+
# without the express permission of Comet ML Inc.
|
|
13
|
+
# *******************************************************
|
|
14
|
+
import json
|
|
15
|
+
import logging
|
|
16
|
+
from typing import Any, Dict, Optional
|
|
17
|
+
|
|
18
|
+
from ..logging_messages import (
|
|
19
|
+
PARSE_API_KEY_EMPTY_EXPECTED_ATTRIBUTES,
|
|
20
|
+
PARSE_API_KEY_EMPTY_KEY,
|
|
21
|
+
PARSE_API_KEY_TOO_MANY_PARTS,
|
|
22
|
+
)
|
|
23
|
+
from .base64_helper import decode_base64
|
|
24
|
+
|
|
25
|
+
LOGGER = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
DELIMITER_CHAR = "*"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class OpikApiKey:
|
|
31
|
+
"""
|
|
32
|
+
This is Opik API key parser module which is able to parse enhanced API key format. The format as following:
|
|
33
|
+
initial 25 chars apiKey + DELIMITER_CHAR + base64 encoded OPIK_BASE_URL and other attributes as JSON dictionary.
|
|
34
|
+
|
|
35
|
+
The logic of this module is shared among comet_ml, comet_mpm, and opik projects.
|
|
36
|
+
Please do not change this module without synchronization with mentioned projects.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
api_key_raw: str,
|
|
42
|
+
api_key: Optional[str] = None,
|
|
43
|
+
attributes: Optional[Dict[str, Any]] = None,
|
|
44
|
+
):
|
|
45
|
+
self._api_key_raw = api_key_raw
|
|
46
|
+
self._api_key = api_key
|
|
47
|
+
self._attributes = attributes
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def api_key(self) -> Optional[str]:
|
|
51
|
+
return self._api_key_raw
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def short_api_key(self) -> Optional[str]:
|
|
55
|
+
if self._api_key is not None:
|
|
56
|
+
return self._api_key
|
|
57
|
+
return self._api_key_raw
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def base_url(self) -> Optional[str]:
|
|
61
|
+
if self["baseUrl"] is not None:
|
|
62
|
+
return str(self["baseUrl"])
|
|
63
|
+
else:
|
|
64
|
+
return None
|
|
65
|
+
|
|
66
|
+
def __getitem__(self, key: str) -> Any:
|
|
67
|
+
if self._attributes is not None:
|
|
68
|
+
return self._attributes.get(key, None)
|
|
69
|
+
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def parse_api_key(raw_key: str) -> Optional[OpikApiKey]:
|
|
74
|
+
if raw_key is None or len(raw_key) == 0:
|
|
75
|
+
LOGGER.debug(PARSE_API_KEY_EMPTY_KEY)
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
parts = raw_key.split(DELIMITER_CHAR)
|
|
79
|
+
size = len(parts)
|
|
80
|
+
if size == 1:
|
|
81
|
+
LOGGER.debug("Opik API key doesn't have attributes associated")
|
|
82
|
+
return OpikApiKey(api_key_raw=raw_key)
|
|
83
|
+
elif size == 2:
|
|
84
|
+
attr_string = parts[1]
|
|
85
|
+
if len(attr_string) > 0:
|
|
86
|
+
data = decode_base64(attr_string)
|
|
87
|
+
attributes = json.loads(data)
|
|
88
|
+
else:
|
|
89
|
+
# edge case - delimiter found but no encoded JSON afterward
|
|
90
|
+
LOGGER.warning(PARSE_API_KEY_EMPTY_EXPECTED_ATTRIBUTES % raw_key)
|
|
91
|
+
raw_key = parts[0] # remove obsolete delimiter
|
|
92
|
+
attributes = None
|
|
93
|
+
|
|
94
|
+
return OpikApiKey(api_key_raw=raw_key, api_key=parts[0], attributes=attributes)
|
|
95
|
+
|
|
96
|
+
LOGGER.warning(PARSE_API_KEY_TOO_MANY_PARTS, size, raw_key)
|
|
97
|
+
return None
|
|
File without changes
|