manjeetverma commited on
Commit
4945cc9
·
verified ·
1 Parent(s): 0c099c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -2,22 +2,16 @@ import os
2
  import gradio as gr
3
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
4
 
5
- # 1. Setup the Model
6
- # model = InferenceClientModel(
7
- # model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
8
- # token=os.getenv("HF_TOKEN")
9
- # )
10
- # Change the model initialization to this:
11
  model = InferenceClientModel(
12
- model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
13
- token=os.getenv("HF_TOKEN"),
14
- # This provider line is the key to bypassing nscale
15
- provider="hf-inference"
16
  )
 
17
  # 2. Setup the Tools
18
  search_tool = DuckDuckGoSearchTool()
19
 
20
- # 3. Create the Agent with STRICT GAIA instructions
21
  agent = CodeAgent(
22
  tools=[search_tool],
23
  model=model,
@@ -29,9 +23,7 @@ agent = CodeAgent(
29
 
30
  def handle_query(query, history=None):
31
  try:
32
- # Run agent
33
  raw_result = agent.run(query)
34
- # Clean the result for the grader
35
  result = str(raw_result).strip()
36
  if "FINAL ANSWER:" in result:
37
  result = result.split("FINAL ANSWER:")[-1].strip()
 
2
  import gradio as gr
3
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
4
 
5
+ # 1. Setup the Model (7B is the best choice to bypass payment/not found errors)
 
 
 
 
 
6
  model = InferenceClientModel(
7
+ model_id="Qwen/Qwen2.5-7B-Instruct",
8
+ token=os.getenv("HF_TOKEN")
 
 
9
  )
10
+
11
  # 2. Setup the Tools
12
  search_tool = DuckDuckGoSearchTool()
13
 
14
+ # 3. Create the Agent
15
  agent = CodeAgent(
16
  tools=[search_tool],
17
  model=model,
 
23
 
24
  def handle_query(query, history=None):
25
  try:
 
26
  raw_result = agent.run(query)
 
27
  result = str(raw_result).strip()
28
  if "FINAL ANSWER:" in result:
29
  result = result.split("FINAL ANSWER:")[-1].strip()