feat: add AgentEvaluator class

This class will evaluate Agent' results and report to user
This commit is contained in:
Lucas Gomide
2025-07-09 16:32:40 -03:00
parent 80bd23a8a9
commit 6d7c7d940e
6 changed files with 883 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
"""Robust JSON parsing utilities for evaluation responses."""
import json
import re
from typing import Dict, Any
def extract_json_from_llm_response(text: str) -> Dict[str, Any]:
try:
return json.loads(text)
except json.JSONDecodeError:
pass
json_patterns = [
# Standard markdown code blocks with json
r'```json\s*([\s\S]*?)\s*```',
# Code blocks without language specifier
r'```\s*([\s\S]*?)\s*```',
# Inline code with JSON
r'`([{\\[].*[}\]])`',
]
for pattern in json_patterns:
matches = re.findall(pattern, text, re.IGNORECASE | re.DOTALL)
for match in matches:
try:
return json.loads(match.strip())
except json.JSONDecodeError:
continue
return text