-
Notifications
You must be signed in to change notification settings - Fork 33
Add sub metrics for conversation correctly finished #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gabegma
wants to merge
12
commits into
main
Choose a base branch
from
pr/ggm/add-sub-metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cabcf3b
Merge remote-tracking branch 'origin/main' into pr/audio_llm_stream
gabegma a7786e3
Add sub-metrics for conversation correctly finished
gabegma d4afa98
Add sub-metrics for response speed
gabegma 0bc89ae
Fix config for old value in config
gabegma 39d5856
Fix empty double-quote for reasoning content
gabegma df6dff8
Improve reasoning sub-metrics
gabegma 1fef37b
Change denominator so rates include non-failures
gabegma 7baf250
Refactor code
gabegma 2f92cf7
Improve documentation
gabegma 5b2360a
Merge branch 'main' into pr/ggm/add-sub-metrics
gabegma b385411
Improve response speed
gabegma 9b7f2d7
Bump versions again
gabegma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """Classifier for `conversation_correctly_finished` failures — one primary cause per record. | ||
|
|
||
| Modules: ``signals`` (contract), ``classifier`` (extract → classify → build sub-metrics), | ||
| ``causes/*`` (per-cause detect + extract), ``final_turn`` (input-characteristic flags). Public API | ||
| re-exported below. | ||
| """ | ||
|
|
||
| from eva.utils.conversation_correctly_finished.classifier import ( | ||
| CATEGORY_PRIORITY, | ||
| build_conv_finish_sub_metrics, | ||
| build_final_turn_flag_sub_metrics, | ||
| classify_conv_finish_failure, | ||
| extract_conv_finish_signals, | ||
| ) | ||
| from eva.utils.conversation_correctly_finished.final_turn import final_turn_input_flags | ||
| from eva.utils.conversation_correctly_finished.signals import Classification, ConvFinishSignals | ||
|
|
||
| __all__ = [ | ||
| "CATEGORY_PRIORITY", | ||
| "Classification", | ||
| "ConvFinishSignals", | ||
| "build_conv_finish_sub_metrics", | ||
| "build_final_turn_flag_sub_metrics", | ||
| "classify_conv_finish_failure", | ||
| "extract_conv_finish_signals", | ||
| "final_turn_input_flags", | ||
| ] |
1 change: 1 addition & 0 deletions
1
src/eva/utils/conversation_correctly_finished/causes/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Per-cause modules — each owns one cause-family's log/CSV/pipecat parsing and its ``detect_*`` logic.""" |
89 changes: 89 additions & 0 deletions
89
src/eva/utils/conversation_correctly_finished/causes/api_errors.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| """Causes: infra API errors — TTS/STT service frames and fatal LLM API errors. | ||
|
|
||
| They invalidate the run, so the classifier ranks them ahead of any behavioral cause. | ||
| """ | ||
|
|
||
| import re | ||
| from typing import Any | ||
|
|
||
| from eva.utils.conversation_correctly_finished.signals import Classification, ConvFinishSignals | ||
| from eva.utils.log_processing import parse_log_message | ||
|
|
||
| # Fatal LLM API-error signatures — allowlist, not a broad `litellm.*Error` match. | ||
| _RE_LLM_ERR = re.compile( | ||
| r"MidStreamFallbackError|APIConnectionError|Retryable streaming error|RateLimitError|InternalServerError" | ||
| ) | ||
| _RE_SERVICE = re.compile(r"([A-Za-z0-9]+(?:TTS|STT)Service)") | ||
|
|
||
|
|
||
| def extract_service_errors(pipecat_events: list[dict], s: ConvFinishSignals) -> None: | ||
| """Set tts/stt service-error flags from pipecat error frames.""" | ||
| for e in pipecat_events: | ||
| if e.get("type") != "error": | ||
| continue | ||
| frame = str(e.get("data", {}).get("frame", "")) | ||
| m = _RE_SERVICE.search(frame) | ||
| if not m: | ||
| continue | ||
| s.num_service_error_frames += 1 | ||
| svc = m.group(1) | ||
| if "TTS" in svc: | ||
| s.tts_service_error = True | ||
| s.service_error_name = svc | ||
| elif "STT" in svc: | ||
| s.stt_service_error = True | ||
| s.service_error_name = svc | ||
| s.service_error_excerpt = frame[:160] | ||
|
|
||
|
|
||
| def extract_log_signals(lines: list[str], resp_idx: list[int], s: ConvFinishSignals) -> None: | ||
| """LLM API error: a fatal error with no non-empty response after the last error line.""" | ||
| err_idx = [i for i, ln in enumerate(lines) if _RE_LLM_ERR.search(ln)] | ||
| if not err_idx: | ||
| return | ||
| last_err = err_idx[-1] | ||
| s.num_llm_api_error_lines = len(err_idx) | ||
| s.llm_api_error_terminal = not any(i > last_err for i in resp_idx) | ||
| if s.llm_api_error_terminal: | ||
| m = _RE_LLM_ERR.search(lines[last_err]) | ||
| s.llm_error_type = m.group(0) if m else "" | ||
| s.llm_error_excerpt = parse_log_message(lines[last_err])[:160] | ||
|
|
||
|
|
||
| def _infra_details(component: str, s: ConvFinishSignals) -> dict[str, Any]: | ||
| """Shared details block for the tts/stt infra-error classifications.""" | ||
| return { | ||
| "invalid_run": True, | ||
| "component": component, | ||
| "service": s.service_error_name, | ||
| "error_excerpt": s.service_error_excerpt, | ||
| "num_error_frames": s.num_service_error_frames, | ||
| "assistant_audio_events": s.assistant_audio_events, | ||
| } | ||
|
|
||
|
|
||
| def detect_service_error(s: ConvFinishSignals, base: dict[str, Any]) -> Classification | None: | ||
| """Infra: a TTS/STT service raised an error frame — the agent was never exercised.""" | ||
| if s.tts_service_error: | ||
| return Classification("tts_api_error", {**base, **_infra_details("tts", s)}) | ||
| if s.stt_service_error: | ||
| return Classification("stt_api_error", {**base, **_infra_details("stt", s)}) | ||
| return None | ||
|
|
||
|
|
||
| def detect_llm_api_error(s: ConvFinishSignals, base: dict[str, Any]) -> Classification | None: | ||
| """Infra: a fatal LLM API error with no successful response after it (invalid run).""" | ||
| if not s.llm_api_error_terminal: | ||
| return None | ||
| return Classification( | ||
| "llm_api_error", | ||
| { | ||
| **base, | ||
| "invalid_run": True, | ||
| "component": "llm", | ||
| "error_type": s.llm_error_type, | ||
| "error_excerpt": s.llm_error_excerpt, | ||
| "num_api_error_lines": s.num_llm_api_error_lines, | ||
| "responses_after_last_error": 0, | ||
| }, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section should likely have it's own try-catch, otherwise if something fails in here, we lose the other calculated info like
details.reasonordetails.speaker