MCPcopy Create free account
hub / github.com/TIGER-AI-Lab/TheoremExplainAgent / evaluate_text

Function evaluate_text

eval_suite/text_utils.py:54–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

52
53
54def 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

Callers 1

evaluate_text_fileFunction · 0.90

Calls 3

_prepare_text_inputsFunction · 0.90
extract_jsonFunction · 0.90
convert_score_fieldsFunction · 0.90

Tested by

no test coverage detected