Spaces:
Runtime error
Runtime error
linting
Browse files
src/gaia_solving_agent/agent.py
CHANGED
|
@@ -42,12 +42,13 @@ openai_llm = OpenAI(
|
|
| 42 |
max_retries=5,
|
| 43 |
)
|
| 44 |
mistral_llm = MistralAI(
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
def get_llm(model_name=cheap_model_name):
|
| 53 |
return NebiusLLM(
|
|
@@ -60,14 +61,17 @@ def get_llm(model_name=cheap_model_name):
|
|
| 60 |
max_retries=5,
|
| 61 |
)
|
| 62 |
|
|
|
|
| 63 |
class PlanEvent(Event):
|
| 64 |
to_do: Literal["Initialize", "Format", "Replan"] = "Initialize"
|
| 65 |
plan: str | None = None
|
| 66 |
n_retries: int = 0
|
| 67 |
|
|
|
|
| 68 |
class QueryEvent(Event):
|
| 69 |
pass
|
| 70 |
|
|
|
|
| 71 |
class AnswerEvent(Event):
|
| 72 |
plan: str
|
| 73 |
answer: str
|
|
@@ -177,7 +181,7 @@ The sub-tasks are :
|
|
| 177 |
|
| 178 |
|
| 179 |
gaia_solving_agent = FunctionAgent(
|
| 180 |
-
tools
|
| 181 |
get_text_representation_of_additional_file,
|
| 182 |
vllm_ask_image_tool,
|
| 183 |
tavily_search_web,
|
|
@@ -190,17 +194,17 @@ gaia_solving_agent = FunctionAgent(
|
|
| 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 |
-
|
| 194 |
Tools you have are of three types:
|
| 195 |
- External resources getter: get text, images, video, etc. from the internet
|
| 196 |
- Resource querier and transformer: query, summarize or transform a resource into a more digestible format.
|
| 197 |
- Analyse or compute : specialized tools to provide a specific analysis or computation.
|
| 198 |
-
|
| 199 |
Try to get resources before querying them.
|
| 200 |
If it is an additional file, you can access its content through the get_text_representation_of_additional_file tool.
|
| 201 |
If you need the original Document, you can use the llamaindex context with ctx.store.get("additional_file").
|
| 202 |
If the analysis require a new external resource get it first.(e.g. a set of rules or a process)
|
| 203 |
-
|
| 204 |
You will be provided a question, some known facts summarizing the user provided context and some sub-tasks to complete.
|
| 205 |
You should follow the order of the sub-tasks.
|
| 206 |
If the tools provides facts that go against your knowledge, you should not use them.
|
|
|
|
| 42 |
max_retries=5,
|
| 43 |
)
|
| 44 |
mistral_llm = MistralAI(
|
| 45 |
+
model="mistral-small-latest",
|
| 46 |
+
api_key=MISTRAL_API_KEY,
|
| 47 |
+
temperature=.1,
|
| 48 |
+
max_retries=5,
|
| 49 |
+
# is_function_calling_model=True,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
|
| 53 |
def get_llm(model_name=cheap_model_name):
|
| 54 |
return NebiusLLM(
|
|
|
|
| 61 |
max_retries=5,
|
| 62 |
)
|
| 63 |
|
| 64 |
+
|
| 65 |
class PlanEvent(Event):
|
| 66 |
to_do: Literal["Initialize", "Format", "Replan"] = "Initialize"
|
| 67 |
plan: str | None = None
|
| 68 |
n_retries: int = 0
|
| 69 |
|
| 70 |
+
|
| 71 |
class QueryEvent(Event):
|
| 72 |
pass
|
| 73 |
|
| 74 |
+
|
| 75 |
class AnswerEvent(Event):
|
| 76 |
plan: str
|
| 77 |
answer: str
|
|
|
|
| 181 |
|
| 182 |
|
| 183 |
gaia_solving_agent = FunctionAgent(
|
| 184 |
+
tools=[
|
| 185 |
get_text_representation_of_additional_file,
|
| 186 |
vllm_ask_image_tool,
|
| 187 |
tavily_search_web,
|
|
|
|
| 194 |
llm=get_llm(reasoning_model_name),
|
| 195 |
system_prompt="""
|
| 196 |
You are a helpful assistant that uses tools to browse additional information and resources on the web to answer questions.
|
| 197 |
+
|
| 198 |
Tools you have are of three types:
|
| 199 |
- External resources getter: get text, images, video, etc. from the internet
|
| 200 |
- Resource querier and transformer: query, summarize or transform a resource into a more digestible format.
|
| 201 |
- Analyse or compute : specialized tools to provide a specific analysis or computation.
|
| 202 |
+
|
| 203 |
Try to get resources before querying them.
|
| 204 |
If it is an additional file, you can access its content through the get_text_representation_of_additional_file tool.
|
| 205 |
If you need the original Document, you can use the llamaindex context with ctx.store.get("additional_file").
|
| 206 |
If the analysis require a new external resource get it first.(e.g. a set of rules or a process)
|
| 207 |
+
|
| 208 |
You will be provided a question, some known facts summarizing the user provided context and some sub-tasks to complete.
|
| 209 |
You should follow the order of the sub-tasks.
|
| 210 |
If the tools provides facts that go against your knowledge, you should not use them.
|
src/gaia_solving_agent/hf_submission_api.py
CHANGED
|
@@ -154,7 +154,11 @@ def prepare_submission_data(username:str, agent_code: str, answers_payload: list
|
|
| 154 |
search = re.search(pattern, answer)
|
| 155 |
extracted_answer = search.group(1).strip() if search else ""
|
| 156 |
try:
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
except:
|
| 159 |
return extracted_answer
|
| 160 |
|
|
|
|
| 154 |
search = re.search(pattern, answer)
|
| 155 |
extracted_answer = search.group(1).strip() if search else ""
|
| 156 |
try:
|
| 157 |
+
evaluated_answer = eval(extracted_answer)
|
| 158 |
+
if isinstance(evaluated_answer, tuple):
|
| 159 |
+
return ', '.join(evaluated_answer)
|
| 160 |
+
else:
|
| 161 |
+
return evaluated_answer
|
| 162 |
except:
|
| 163 |
return extracted_answer
|
| 164 |
|