Spaces:
Runtime error
Runtime error
Fix regex pattern in `prepare_submission_data` for accurate answer extraction
Browse files
src/gaia_solving_agent/agent.py
CHANGED
|
@@ -27,14 +27,20 @@ from gaia_solving_agent.utils import extract_pattern
|
|
| 27 |
cheap_model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
| 28 |
light_model_name = "Qwen/Qwen2.5-32B-Instruct"
|
| 29 |
balanced_model_name = "meta-llama/Meta-Llama-3.1-70B-Instruct"
|
| 30 |
-
reasoning_model_name = "
|
| 31 |
vlm_model_name = "mistralai/Mistral-Small-3.1-24B-Instruct-2503" # For VLM needs
|
| 32 |
-
|
| 33 |
model="gpt-4.1",
|
| 34 |
api_key=OPENAI_API_KEY,
|
| 35 |
temperature=.1,
|
| 36 |
max_retries=5,
|
| 37 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
mistral_llm = MistralAI(
|
| 39 |
model="mistral-small-latest",
|
| 40 |
api_key=MISTRAL_API_KEY,
|
|
@@ -80,8 +86,7 @@ class GaiaWorkflow(Workflow):
|
|
| 80 |
additional_file_path = await ctx.store.get("additional_file_path")
|
| 81 |
user_msg = await ctx.store.get("user_msg")
|
| 82 |
|
| 83 |
-
llm =
|
| 84 |
-
# llm = get_llm(reasoning_model_name)
|
| 85 |
prompt_template = RichPromptTemplate(PLANING_PROMPT)
|
| 86 |
file_extension = Path(additional_file_path).suffix if additional_file_path else ""
|
| 87 |
prompt = prompt_template.format(
|
|
@@ -182,7 +187,7 @@ gaia_solving_agent = FunctionAgent(
|
|
| 182 |
*research_paper_reader_toolspec.to_tool_list(),
|
| 183 |
text_content_analysis,
|
| 184 |
],
|
| 185 |
-
llm=
|
| 186 |
system_prompt="""
|
| 187 |
You are a helpful assistant that uses tools to browse additional information and resources on the web to answer questions.
|
| 188 |
|
|
|
|
| 27 |
cheap_model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
| 28 |
light_model_name = "Qwen/Qwen2.5-32B-Instruct"
|
| 29 |
balanced_model_name = "meta-llama/Meta-Llama-3.1-70B-Instruct"
|
| 30 |
+
reasoning_model_name = "Qwen/Qwen3-235B-A22B"
|
| 31 |
vlm_model_name = "mistralai/Mistral-Small-3.1-24B-Instruct-2503" # For VLM needs
|
| 32 |
+
openai_reasoning = OpenAI(
|
| 33 |
model="gpt-4.1",
|
| 34 |
api_key=OPENAI_API_KEY,
|
| 35 |
temperature=.1,
|
| 36 |
max_retries=5,
|
| 37 |
)
|
| 38 |
+
openai_llm = OpenAI(
|
| 39 |
+
model="gpt-4.1-nano",
|
| 40 |
+
api_key=OPENAI_API_KEY,
|
| 41 |
+
temperature=.1,
|
| 42 |
+
max_retries=5,
|
| 43 |
+
)
|
| 44 |
mistral_llm = MistralAI(
|
| 45 |
model="mistral-small-latest",
|
| 46 |
api_key=MISTRAL_API_KEY,
|
|
|
|
| 86 |
additional_file_path = await ctx.store.get("additional_file_path")
|
| 87 |
user_msg = await ctx.store.get("user_msg")
|
| 88 |
|
| 89 |
+
llm = openai_reasoning
|
|
|
|
| 90 |
prompt_template = RichPromptTemplate(PLANING_PROMPT)
|
| 91 |
file_extension = Path(additional_file_path).suffix if additional_file_path else ""
|
| 92 |
prompt = prompt_template.format(
|
|
|
|
| 187 |
*research_paper_reader_toolspec.to_tool_list(),
|
| 188 |
text_content_analysis,
|
| 189 |
],
|
| 190 |
+
llm=get_llm(reasoning_model_name),
|
| 191 |
system_prompt="""
|
| 192 |
You are a helpful assistant that uses tools to browse additional information and resources on the web to answer questions.
|
| 193 |
|
src/gaia_solving_agent/hf_submission_api.py
CHANGED
|
@@ -150,7 +150,7 @@ async def run_agent(agent, questions_data, additional_files):
|
|
| 150 |
|
| 151 |
def prepare_submission_data(username:str, agent_code: str, answers_payload: list[dict]):
|
| 152 |
def extract_answer(answer: str) -> str | int:
|
| 153 |
-
pattern = r"FINAL ANSWER:\s*(.*)
|
| 154 |
search = re.search(pattern, answer)
|
| 155 |
extracted_answer = search.group(1).strip() if search else ""
|
| 156 |
try:
|
|
|
|
| 150 |
|
| 151 |
def prepare_submission_data(username:str, agent_code: str, answers_payload: list[dict]):
|
| 152 |
def extract_answer(answer: str) -> str | int:
|
| 153 |
+
pattern = r"FINAL ANSWER:\s*([^`.]*)"
|
| 154 |
search = re.search(pattern, answer)
|
| 155 |
extracted_answer = search.group(1).strip() if search else ""
|
| 156 |
try:
|