Spaces:
Runtime error
Runtime error
feat: extract spans and HF_TOKEN import
Browse files6 unmodified lines789101112107 unmodified lines1201211221231241256 unmodified linesimport gradio as grfrom leptonai import ClientLEPTON_API_TOKEN = os.environ.get("LEPTON_API_TOKEN", None)client = Client("https://yb15a7dy-glider.tin.lepton.run", "glider", LEPTON_API_TOKEN)107 unmodified linesparts.append(f"<GOLD ANSWER>\n{gold_answer}\n</GOLD ANSWER>")return "\n".join(parts)def model_call(model_output, user_input, gold_answer, retrieved_context, pass_criteria, rubric):if model_output == "" or user_input == "" or pass_criteria == "":return "", "", ""6 unmodified lines78910111213107 unmodified lines1211221231241251261271281291301311321331341351361371381391401411421431446 unmodified linesimport gradio as grfrom leptonai import ClientHF_TOKEN = os.environ.get("HF_TOKEN", None)LEPTON_API_TOKEN = os.environ.get("LEPTON_API_TOKEN", None)client = Client("https://yb15a7dy-glider.tin.lepton.run", "glider", LEPTON_API_TOKEN)107 unmodified linesparts.append(f"<GOLD ANSWER>\n{gold_answer}\n</GOLD ANSWER>")return "\n".join(parts)def extract_spans(input_string):# Regex patterns to extract content within the reasoning, highlight, and score tagsreasoning_pattern = r"<reasoning>\s*(.*?)\s*</reasoning>"highlight_pattern = r"<highlight>\s*(.*?)\s*</highlight>"score_pattern = r"<score>\s*(\d+)\s*</score(?:\>|)"# Using re.search to extract the contents based on our defined patternsreasoning_match = re.search(reasoning_pattern, input_string, re.DOTALL)highlight_match = re.search(highlight_pattern, input_string)score_match = re.search(score_pattern, input_string)# Extracting the matched groups if presentreasoning = reasoning_match.group(1) if reasoning_match else Nonehighlight = highlight_match.group(1).strip() if highlight_match else Nonescore = int(score_match.group(1)) if score_match else None# Return a dictionary with the extracted contentreturn score, reasoning, highlightdef model_call(model_output, user_input, gold_answer, retrieved_context, pass_criteria, rubric):if model_output == "" or user_input == "" or pass_criteria == "":return "", "", ""
app.py+19