Spaces:
Runtime error
Runtime error
Update `setup` method to handle additional files with extensions, adapt prompt template for new variable
Browse files
src/gaia_solving_agent/agent.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
import re
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from llama_index.core.agent.workflow import FunctionAgent, AgentWorkflow
|
| 4 |
from llama_index.core.prompts import RichPromptTemplate
|
|
@@ -31,6 +33,8 @@ def get_llm(model_name=model_name):
|
|
| 31 |
|
| 32 |
class QueryEvent(Event):
|
| 33 |
query: str
|
|
|
|
|
|
|
| 34 |
plan: str
|
| 35 |
|
| 36 |
class AnswerEvent(Event):
|
|
@@ -42,12 +46,12 @@ class GaiaWorkflow(Workflow):
|
|
| 42 |
@step
|
| 43 |
async def setup(self, ev: StartEvent) -> QueryEvent:
|
| 44 |
llm = get_llm()
|
| 45 |
-
prompt_template = RichPromptTemplate(
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
return QueryEvent(query=ev.query, plan=plan.text)
|
| 51 |
|
| 52 |
@step()
|
| 53 |
async def multi_agent_process(self, ev: QueryEvent) -> AnswerEvent:
|
|
|
|
| 1 |
import re
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import Any
|
| 4 |
|
| 5 |
from llama_index.core.agent.workflow import FunctionAgent, AgentWorkflow
|
| 6 |
from llama_index.core.prompts import RichPromptTemplate
|
|
|
|
| 33 |
|
| 34 |
class QueryEvent(Event):
|
| 35 |
query: str
|
| 36 |
+
additional_file: Any | None
|
| 37 |
+
additional_file_path: str = ""
|
| 38 |
plan: str
|
| 39 |
|
| 40 |
class AnswerEvent(Event):
|
|
|
|
| 46 |
@step
|
| 47 |
async def setup(self, ev: StartEvent) -> QueryEvent:
|
| 48 |
llm = get_llm()
|
| 49 |
+
prompt_template = RichPromptTemplate(PLANING_PROMPT)
|
| 50 |
+
plan = llm.complete(prompt_template.format(
|
| 51 |
+
user_request=ev.query,
|
| 52 |
+
additional_file_extension=Path(ev.additional_file_name).suffix,
|
| 53 |
+
))
|
| 54 |
+
return QueryEvent(query=ev.query, additional_file=ev.additional_file, plan=plan.text)
|
| 55 |
|
| 56 |
@step()
|
| 57 |
async def multi_agent_process(self, ev: QueryEvent) -> AnswerEvent:
|
src/gaia_solving_agent/prompts.py
CHANGED
|
@@ -30,6 +30,9 @@ Respond with exactly:
|
|
| 30 |
- xxxxxxx
|
| 31 |
- xxxxxxx
|
| 32 |
3. Sub-tasks:
|
|
|
|
|
|
|
|
|
|
| 33 |
- xxxxxxx
|
| 34 |
- xxxxxxx
|
| 35 |
'''
|
|
|
|
| 30 |
- xxxxxxx
|
| 31 |
- xxxxxxx
|
| 32 |
3. Sub-tasks:
|
| 33 |
+
{% if additional_file_extension|length -%}
|
| 34 |
+
- There is an additional file to analyse. It's file extension is {{ additional_file_extension }}. You must analyse it to find out
|
| 35 |
+
{%- else %}
|
| 36 |
- xxxxxxx
|
| 37 |
- xxxxxxx
|
| 38 |
'''
|