Spaces:
Sleeping
Sleeping
ajout du Excel
Browse files
agent.py
CHANGED
|
@@ -202,14 +202,31 @@ math_agent = create_react_agent(
|
|
| 202 |
|
| 203 |
name="math_agent")
|
| 204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
supervisor = create_supervisor(
|
| 206 |
model=init_chat_model("openai:gpt-4o", api_key = api_open_ai_agent_key),
|
| 207 |
-
agents=[research_agent, math_agent, web_search_openai_agent],
|
| 208 |
prompt=(
|
| 209 |
-
"You are a supervisor managing
|
| 210 |
"- research_agent: Specialised in ArXiv and Wikipedia. Assign research-related tasks to this agent.\n"
|
| 211 |
"- math_agent: Handles math-related tasks such as solving equations or performing calculations.\n"
|
| 212 |
"- web_search_openai_agent: Can browse the web to find up-to-date and relevant information. Assign web-related tasks to this agent.\n"
|
|
|
|
| 213 |
"Assign work to one agent at a time. Do not call agents in parallel.\n"
|
| 214 |
"When a new question arises, always first consult the research_agent — it may provide useful information.\n"
|
| 215 |
"If research_agent yields no results, then delegate the task to web_search_openai_agent.\n"
|
|
|
|
| 202 |
|
| 203 |
name="math_agent")
|
| 204 |
|
| 205 |
+
agent_excel = create_react_agent(
|
| 206 |
+
model=llm_4o,
|
| 207 |
+
|
| 208 |
+
tools=[open_xlsx_doc, create_agent_and_answer, ],
|
| 209 |
+
prompt=(
|
| 210 |
+
"You are an agent psecialized with Excel files.\n\n"
|
| 211 |
+
"INSTRUCTIONS:\n"
|
| 212 |
+
"- Assist ONLY when an Excel file is mentionned \n"
|
| 213 |
+
"- First, when you receive an Excel file path, you have to use the 'open_xlsx_doc' tool. Then you use the 'create_agent_and_answer'\n"
|
| 214 |
+
"- The output of the first tool (the pd.Dataframe) is a part of the input of the first solution\n"
|
| 215 |
+
|
| 216 |
+
"- Once you have got a response from the 'create_agent_and_answer_tool', transmit it to your supervisor \n"
|
| 217 |
+
),
|
| 218 |
+
name="agent_excel",
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
supervisor = create_supervisor(
|
| 222 |
model=init_chat_model("openai:gpt-4o", api_key = api_open_ai_agent_key),
|
| 223 |
+
agents=[research_agent, math_agent, web_search_openai_agent, agent_excel],
|
| 224 |
prompt=(
|
| 225 |
+
"You are a supervisor managing four agents:\n"
|
| 226 |
"- research_agent: Specialised in ArXiv and Wikipedia. Assign research-related tasks to this agent.\n"
|
| 227 |
"- math_agent: Handles math-related tasks such as solving equations or performing calculations.\n"
|
| 228 |
"- web_search_openai_agent: Can browse the web to find up-to-date and relevant information. Assign web-related tasks to this agent.\n"
|
| 229 |
+
"- agent_excel: Can exploit Excel file. You have to give him an Excel path file with a question, and wait for his response.\n"
|
| 230 |
"Assign work to one agent at a time. Do not call agents in parallel.\n"
|
| 231 |
"When a new question arises, always first consult the research_agent — it may provide useful information.\n"
|
| 232 |
"If research_agent yields no results, then delegate the task to web_search_openai_agent.\n"
|
app.py
CHANGED
|
@@ -66,11 +66,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 66 |
for item in questions_data:
|
| 67 |
task_id = item.get("task_id")
|
| 68 |
question_text = item.get("question")
|
|
|
|
| 69 |
if not task_id or question_text is None:
|
| 70 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 71 |
continue
|
| 72 |
try:
|
| 73 |
-
submitted_answer = response_from_agent(question_text)
|
| 74 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 75 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 76 |
except Exception as e:
|
|
|
|
| 66 |
for item in questions_data:
|
| 67 |
task_id = item.get("task_id")
|
| 68 |
question_text = item.get("question")
|
| 69 |
+
filename = item.get('file_name')
|
| 70 |
if not task_id or question_text is None:
|
| 71 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 72 |
continue
|
| 73 |
try:
|
| 74 |
+
submitted_answer = response_from_agent(question_text + 'The file_name (path) is : ' + filename)
|
| 75 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 76 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 77 |
except Exception as e:
|