Evaluate transcript text using an LLM model with retry logic. Args: text_eval_model: The LLM model wrapper to use for evaluation. transcript: The transcript text to evaluate. retry_limit: Maximum number of retry attempts on failure. Returns: dict: The e
(text_eval_model: LiteLLMWrapper, transcript: str, retry_limit: int)
| 52 | |
| 53 | |
| 54 | def evaluate_text(text_eval_model: LiteLLMWrapper, transcript: str, retry_limit: int) -> dict: |
| 55 | """ |
| 56 | Evaluate transcript text using an LLM model with retry logic. |
| 57 | |
| 58 | Args: |
| 59 | text_eval_model: The LLM model wrapper to use for evaluation. |
| 60 | transcript: The transcript text to evaluate. |
| 61 | retry_limit: Maximum number of retry attempts on failure. |
| 62 | |
| 63 | Returns: |
| 64 | dict: The evaluation results as a JSON object. |
| 65 | |
| 66 | Raises: |
| 67 | ValueError: If all retry attempts fail. |
| 68 | """ |
| 69 | # prompt = _text_eval.format(transcript=transcript) |
| 70 | prompt = _text_eval_new.format(transcript=transcript) |
| 71 | for attempt in range(retry_limit): |
| 72 | try: |
| 73 | evaluation = text_eval_model(_prepare_text_inputs(prompt)) |
| 74 | evaluation_json = extract_json(evaluation) |
| 75 | evaluation_json = convert_score_fields(evaluation_json) |
| 76 | return evaluation_json |
| 77 | except Exception as e: |
| 78 | print(f"Attempt {attempt + 1} failed: {e.__class__.__name__}: {e}") |
| 79 | if attempt + 1 == retry_limit: |
| 80 | raise ValueError("Reached maximum retry limit. Evaluation failed.") from None |
no test coverage detected