Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files125 unmodified lines126127128129130131132129130131132133134135136137138139140141142143144145146147148149150135136137138139140141142143144145146147148149150151152153125 unmodified lines print("CodeAgent initialized with LiteLLMModel.")
def _clean_exact_match_answer(raw_answer: str) -> str: import re
text = (raw_answer or "").strip() if not text or text.startswith("AGENT ERROR:"): import re text = (raw_answer or "").strip() if not text or text.startswith("AGENT ERROR:"): return text text = re.sub(r"(?im)^\s*(final\s*answer|answer)\s*:\s*", "", text).strip() lines = [line.strip() for line in text.splitlines() if line.strip()] if lines: text = lines[-1] if text.startswith("```") and text.endswith("```"): text = text.strip("`").strip() if len(text) >= 2 and ((text[0] == '"' and text[-1] == '"') or (text[0] == "'" and text[-1] == "'")): text = text[1:-1].strip() if len(text) > 1 and text.endswith(".") and not re.search(r"\d\.$", text): text = text[:-1].strip() return text
text = re.sub(r"(?im)^\s*(final\s*answer|answer)\s*:\s*", "", text).strip() lines = [line.strip() for line in text.splitlines() if line.strip()] if lines: text = lines[-1]
if text.startswith("```") and text.endswith("```"): text = text.strip("`").strip()
if len(text) >= 2 and ((text[0] == '"' and text[-1] == '"') or (text[0] == "'" and text[-1] == "'")): text = text[1:-1].strip()
if len(text) > 1 and text.endswith(".") and not re.search(r"\d\.$", text): text = text[:-1].strip()
return text
def __call__(self, question: str, task_id: str = "") -> str: prompt = question.strip()app.py+20-20