su3su2u1 commited on
Commit
8624280
·
unverified ·
1 Parent(s): 04356ec

Enable attachment

Browse files
Files changed (2) hide show
  1. app.py +9 -1
  2. theagent.py +3 -2
app.py CHANGED
@@ -73,8 +73,16 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
73
  if not task_id or question_text is None:
74
  print(f"Skipping item with missing task_id or question: {item}")
75
  continue
 
 
 
 
 
 
 
 
76
  try:
77
- submitted_answer = agent(question_text)
78
  answers_payload.append(
79
  {"task_id": task_id, "submitted_answer": submitted_answer}
80
  )
 
73
  if not task_id or question_text is None:
74
  print(f"Skipping item with missing task_id or question: {item}")
75
  continue
76
+
77
+ resp = requests.get(f"{api_url}/files/{task_id}")
78
+ if resp.status_code == 404:
79
+ attachment = None
80
+ else:
81
+ # content_type = resp.headers["content-type"]
82
+ attachment = {"file_attached": response.raw}
83
+
84
  try:
85
+ submitted_answer = agent(question_text, attachment)
86
  answers_payload.append(
87
  {"task_id": task_id, "submitted_answer": submitted_answer}
88
  )
theagent.py CHANGED
@@ -97,7 +97,7 @@ class BasicAgent:
97
  self.agent = manager_agent
98
  print("BasicAgent initialized.")
99
 
100
- def __call__(self, question: str) -> str:
101
  print(f"Agent received question (first 50 chars): {question[:50]}...")
102
  for k, v in cache.items():
103
  if k in question and v is not None:
@@ -105,7 +105,8 @@ class BasicAgent:
105
  answer = self.agent.run(
106
  question
107
  + " Please break down the questions into easier sub-tasks."
108
- + " Please answer concisely."
 
109
  )
110
  print("the answer", answer)
111
  try:
 
97
  self.agent = manager_agent
98
  print("BasicAgent initialized.")
99
 
100
+ def __call__(self, question: str, attachment) -> str:
101
  print(f"Agent received question (first 50 chars): {question[:50]}...")
102
  for k, v in cache.items():
103
  if k in question and v is not None:
 
105
  answer = self.agent.run(
106
  question
107
  + " Please break down the questions into easier sub-tasks."
108
+ + " Please answer concisely.",
109
+ additional_args=attachment,
110
  )
111
  print("the answer", answer)
112
  try: