-
[OPIK-1833]: [P SDK] Implement evaluation engine for threads (#2514)
发布于
2025-07-07 14:08:20 +00:00 -
[OPIK-1833]: Added threads evaluation engine stub
-
[OPIK-1833]: Added ThreadsClient stub with core methods for thread search and feedback logging
-
[OPIK-1833]: Added ThreadsClient stub with core methods for thread search and feedback logging
-
[OPIK-1833]: Implemented threads evaluation engine with multi-threading support
- Added
ThreadsEvaluationEnginefor evaluating threads and logging feedback scores. - Integrated
ThreadsEvaluationResultmodel for structured evaluation outputs. - Developed
executefunction with ThreadPoolExecutor for parallel task processing. - Added types and utilities to support thread evaluation tasks.
-
[OPIK-1833]: Implemented proper handling of score results
-
[OPIK-1833]: Refactored
ThreadsEvaluationEngineconstructor to accept an instance ofthreads_client.ThreadsClientto allow easy mocking during testing. -
[OPIK-1833]: Refactored conversation imports to use a centralized
typesmodule
Streamlined
Conversationand related type imports by using the newly centralizedtypesmodule. Updated method signatures and replaced inline type definitions for better maintainability.- [OPIK-1833]: Enhanced error handling and logging in
ThreadsEvaluationEngine
- Added a logging framework for better traceability.
- Introduced specific exceptions to handle empty metrics and thread data scenarios.
- Improved conversation trace validation to skip evaluation for threads without conversation traces.
- Enhanced span and trace outputs to include detailed evaluation results.
- [OPIK-1833]: Added unit tests for
ThreadsEvaluationEngine
- Implemented comprehensive test coverage for
ThreadsEvaluationEnginemethods. - Added tests for conversation trace retrieval, feedback score logging, and thread evaluation.
- Verified concurrency behavior with multiple threads and workers.
- Ensured proper exception handling and logging for edge cases.
- [OPIK-1833]: Added
evaluate_threadsfunction and updated__init__.pyexports
- Implemented
evaluate_threadsto enable conversation thread evaluation with custom metrics. - Updated
__all__in__init__.pyfor proper module export of the new function.
-
[OPIK-1833]: Wrapped threads evaluation by
async_http_connections_expire_immediatelycontext manager -
[OPIK-1833]: Replaced
MetricComputationErrorwithEvaluationErrorin thread evaluation logic
- Introduced
EvaluationErrorfor better exception clarity. - Updated exception handling in
ThreadsEvaluationEngineand corresponding unit tests.
- [OPIK-1833]: Fixed typo in
_get_conversation_threadmethod name and updated logic to handle scoring failures
- Renamed
_get_conversation_treadto_get_conversation_threadacross implementation and tests. - Enhanced scoring logic to exclude failed scores from feedback logging in
ThreadsEvaluationEngine.
- [OPIK-1833]: Refactored
ThreadsEvaluationEnginemethods and added context management for evaluations
- Renamed
_evaluate_threadtoevaluate_threadfor better clarity. - Introduced
evaluate_llm_conversation_contextto manage context and trace data during evaluations. - Moved trace and span logic into
context_helperfor cleaner code organization. - Updated unit tests to reflect method renaming and added context mock handling.
- General improvement to exception handling and error logging mechanisms across evaluation flows.
- [OPIK-1833]: Refactored threads evaluation to align with the shared engine framework
- Replaced
_types.ThreadTestResultwithevaluation_result.ThreadEvaluationResultfor consistency. - Merged evaluation logic into
evaluation_tasks_executorfromevaluation_executor. - Updated thread evaluation tasks to use generic
EvaluationTaskwith TypeVar to improve type safety. - Simplified
ThreadsEvaluationResultstructure for clearer results handling. - Refactored tests to reflect the updated structure and improve validation of evaluation results.
- [OPIK-1833]: Added better type annotations and comments
- Introduced
Literalfor type hintingconversationkeys, improving clarity and type safety. - Included comments to enhance code readability and maintainability.
- [OPIK-1833]: Refactored threading helpers and removed redundant methods
- Extracted
_get_conversation_threadand_log_feedback_scoresintohelpersmodule, improving modularity and reusability. - Updated
ThreadsEvaluationEngineto use new helper methods and streamlined logic. - Added unit tests for
helpers.pyto ensure correctness of extracted functionality.
-
[OPIK-1833]: Fixed coment
-
[OPIK-1834] [P SDK] ConversationalCoherence conversation metric (#2579)
-
[OPIK-1834]: Fixed imports
-
[OPIK-1834]: Added synchronous Conversational Coherence Metric implementation.
- Introduced
ConversationalCoherenceMetricfor evaluating coherence of conversation exchanges within sliding windows. - Implemented templates and schema for constructing evaluation queries and parsing responses.
- Added helper methods to generate sliding windows of conversation turns.
- Included Pydantic models for validating and handling evaluation responses.
- Integrated scoring calculation and irrelevancy extraction logic for detailed analysis.
- [OPIK-1834]: Enhanced Conversational Coherence and Session Completeness metrics.
- Added
ConversationTurnclass for structured representation of conversation exchanges. - Implemented
build_conversation_turnsandmerge_turnsutilities for processing conversational data. - Refactored window-based scoring logic to use conversation turns, improving clarity and modularity.
- Introduced comprehensive tests for conversational coherence and session completeness metrics, covering error scenarios and ensuring robustness.
- Improved error handling and logging across metric computation functions.
- [OPIK-1834]: Added and tested conversation turn utilities
- Introduced
test_build_conversation_turns__happy_pathfor validating thebuild_conversation_turnsutility. - Rewrote
test_window_sizeastest_get_turns_in_sliding_windowto align with the updated sliding window logic. - Enhanced test coverage for sliding window generation and conversation turn processing functions.
- [OPIK-1834]: Added asynchronous support for Conversational Coherence Metric
- Introduced
ascoremethods for asynchronous scoring and evaluation. - Added
_a_calculate_score,_a_reason_from_verdicts, and_a_evaluate_conversationto handle async operations seamlessly. - Extracted common logic into
_extract_turns_windows_from_conversationto reduce redundancy and improve readability. - Extended test suite with async tests to ensure correctness of async metric computation and error handling.
- Updated logging and exception handling for async workflows.
- [OPIK-1834]: Updated imports and added tests for Conversation Coherence Metric.
- Refactored imports for Session Completeness Metric to improve maintainability.
- Introduced tests for Conversation Coherence Metric, including synchronous and asynchronous scenarios.
- Adjusted
trackparameter in Session Completeness Metric tests to avoid delays while trying to log metric to not running server. - Verified integration with real model outputs through expanded test coverage.
-
[OPIK-1834]: Fixed imports
-
[OPIK-1834]: Added another example of irrelevant response reason
-
[OPIK-1834]: Simplified conversation turn extraction logic.
-
[OPIK-1834]: Added documentation to the ConversationalCoherenceMetric and exposed it as export from
opik.evaluation.metrics -
[P SDK] UserFrustration conversation metric (#2603)
-
[OPIK-1835]: Implemented User Frustration Score Metric - synchronous mode.
- Added
UserFrustrationMetricto evaluate user frustration in conversations based on sliding window analysis. - Introduced templates and schema for constructing LLM queries and parsing frustration-related responses.
- Implemented scoring and reasoning generation, leveraging context and per-message analysis.
- Refactored common sliding window logic to
helpers.pyfor reusability. - Updated
ConversationTurnutilities to handle cases whereoutputis absent.
- [OPIK-1835]: Added comprehensive tests for User Frustration Metric
- Implemented unit tests for
UserFrustrationMetriccovering various scenarios: no frustration, mixed responses, all frustration, and error handling. - Added support for asynchronous test cases (
test_score__async) ensuring correctness of async methods. - Updated logic in
metric.pyto fix the calculation of frustrated counts. - Ensured detailed validation of edge cases such as empty conversations and invalid response formats.
- [OPIK-1835]: Added asynchronous support for User Frustration Metric
- Introduced
ascoremethod for asynchronous frustration score evaluation. - Added
_a_calculate_score,_a_reason_from_verdicts, and_a_evaluate_conversationmethods to handle async operations. - Leveraged
asyncio.gatherfor efficient asynchronous processing of conversation sliding windows. - Enhanced logging and error handling for async workflows, ensuring robustness.
- [OPIK-1835]: Updated User Frustration Metric with documentation and integration tests.
- Detailed class documentation for
UserFrustrationMetric, explaining arguments, behavior, and scoring. - Integrated metric into the library's exports for seamless access.
- Added integration tests to validate real model outputs for both synchronous and asynchronous methods.
-
[OPIK-1772]: [P SDK] Implement API class for threads (#2633)
-
[OPIK-1772]: Implement thread operations and add tests.
- Extended thread client functionality with support for searching threads using filter expressions.
- Added
parse_filter_expressionsutility for translating filter strings to filter objects. - Introduced end-to-end tests for threads, validating search functionality and active thread handling.
- Updated filter and truncation handling logic across related API calls for consistency.
- [OPIK-1772]: Refactor ThreadsClient instantiation and add utility to OpikClient.
- Replaced direct
ThreadsClientinstantiation in tests withget_threads_clientutility method inOpikClient. - Added
get_threads_clientto facilitate cleaner and context-respective creation ofThreadsClient. - Updated related test cases and adjusted import statements for consistency.
- [OPIK-1772]: Add support for thread feedback score processing.
- Introduced
ThreadsFeedbackScoreMessageandAddThreadsFeedbackScoresBatchMessagefor handling thread-specific feedback scores. - Added
_process_add_threads_feedback_scores_batch_messageinMessageProcessorto process batch messages related to thread feedback scores. - Implemented
log_threads_feedback_scoresinThreadsClientfor logging thread feedback scores. - Refactored feedback score handling logic into
parse_feedback_score_messagesutility.
-
[OPIK-1772]: Added unit test cases for
AddThreadsFeedbackScoresBatchMessageBatcher -
[OPIK-1772]: Add warning for rejected AddThreadsFeedbackScoresBatchMessage and update supported query operators.
- Log warning when AddThreadsFeedbackScoresBatchMessage is rejected due to unclosed threads.
- Extend SUPPORTED_OPERATORS to include "id" and "status".
- [OPIK-1772]: Add verification of thread feedback scores and end-to-end test for logging threads feedback scores.
- Added
verify_threadand_assert_feedback_scoresutilities to validate feedback scores. - Introduced E2E test for logging and verifying logging thread feedback scores.
- Refactored duplicated feedback score verification logic for reuse.
-
[OPIK-1772]: Updated search_threads documentation to include description of filter string format.
-
[OPIK-1772]: Update error handling for AddThreadsFeedbackScoresBatchMessage rejection.
- Moved the warning log for rejected AddThreadsFeedbackScoresBatchMessage to
_process_add_threads_feedback_scores_batch_message.
-
[OPIK-1772]: Increased timeout to avoid flaky test failures
-
[OPIK-1772]: Modified unit tests workflow to list installed dependencies
-
[OPIK-1833]: Replace
evaluate_llm_conversation_contextwithtrace_contextfor thread evaluations.
- Removed
context_helperand migrated context management logic intotrace_contextinopik_context.py. - Updated
evaluation_engine.pyto utilizetrace_context, ensuring consistent trace handling. - Refactored tracing-related imports for cleanup and better organization.
-
[OPIK-1833]: Added additional columns to the OpikQueryLanguage to support filtering of threads.
-
[OPIK-1943]: [P SDK] Integrate ThreadsClient into evaluation engine (#2660)
-
[OPIK-1833]: Add E2E tests for threads evaluation.
- Introduced E2E test cases for thread evaluation in
test_threads_evaluate.pyto validate evaluation metrics and feedback score processing. - Enhanced
create_conversation_from_tracesto sort traces by start time, ensuring a proper sequence of messages. - Updated OpikQueryLanguage to support filtering by
thread_id. - Fixed
filter_stringusage in evaluation helpers to quote thread IDs correctly. - Refactored and adjusted imports in tests for consistency and structure.
-
[OPIK-1943]: Fixed failing unit tests.
-
[OPIK-1948]: Handle missing input/output in conversation traces after transformation, which allows filtering.
- Updated
create_conversation_from_tracesto skip traces with missing or invalid input/output. - Added unit tests to validate trace filtering logic and ensure robustness.
- [OPIK-1955]: Standardized score formatting in conversation metric templates.
- Updated templates for
session_completeness,user_frustration, andconversational_coherenceto format scores with 1 decimal place.
- [OPIK-1943]: Refactored thread evaluation E2E tests for better thread status handling.
- Introduced
_all_threads_closedand_one_thread_is_activehelper functions for thread status verification. - Updated imports to remove unused
datetime_helpersand includethreads_client. - Improved thread closing and evaluation workflows in
test_evaluate_threads__happy_pathto ensure proper propagation and error handling.
- [OPIK-1943]: Enhanced thread evaluation to handle active vs inactive thread filtering.
- Fixed to evaluate only inactive (closed) threads.
- Added logic to verify and log warnings for active threads during evaluation.
- Introduced
_mock_evaluate_thread_two_test_resultsfor test consistency. - Updated tests to handle inactive threads and exceptions for all-active scenarios.
-
[OPIK-1943]: Removed obsolete unit test. Added comments for clarity.
-
[OPIK-1933]: Fixed prompt for better clarity.
-
[OPIK-1833]: Updated documentation to use the correct filter string.
-
[OPIK-1833]: Fixed linter errors
下载附件
-