Files changed (1) hide show
  1. agent.py +39 -0
agent.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import InferenceClient
3
+
4
+ HF_TOKEN = os.getenv("HF_TOKEN")
5
+
6
+ client = InferenceClient(
7
+ model="Qwen/Qwen2.5-7B-Instruct",
8
+ token=HF_TOKEN
9
+ ) if HF_TOKEN else None
10
+
11
+
12
+ def agent(task):
13
+ """
14
+ Robust agent for GAIA-style evaluation.
15
+ Accepts dict OR string safely.
16
+ """
17
+
18
+ # Extract input safely
19
+ if isinstance(task, dict):
20
+ query = task.get("input") or task.get("question") or str(task)
21
+ else:
22
+ query = str(task)
23
+
24
+ if client is None:
25
+ return ""
26
+
27
+ try:
28
+ response = client.chat_completion(
29
+ messages=[
30
+ {"role": "user", "content": query}
31
+ ],
32
+ max_tokens=512,
33
+ temperature=0.1
34
+ )
35
+
36
+ return response.choices[0].message.content.strip()
37
+
38
+ except:
39
+ return ""