Visionkambanje commited on
Commit
2faef85
·
verified ·
1 Parent(s): 28ac8cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -5,7 +5,7 @@ import inspect
5
  import pandas as pd
6
  import re
7
 
8
- from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, PythonInterpreterTool, WikipediaSearchTool, FinalAnswerTool
9
 
10
  # (Keep Constants as is)
11
  # --- Constants ---
@@ -14,6 +14,21 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  try:
18
  import ddgs
19
  except ImportError:
@@ -28,7 +43,7 @@ class BasicAgent:
28
  print("Did not receive API key.")
29
  else:
30
  print(f"First 5 characters of the provided API key: {api_key[:5]}")
31
- os.environ["OPENAI_API_KEY"] = api_key
32
  print("BasicAgent initialized.")
33
  def __call__(self, question: str) -> str:
34
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
5
  import pandas as pd
6
  import re
7
 
8
+ from smolagents import CodeAgent, DuckDuckGoSearchTool,HfApiModel , PythonInterpreterTool, WikipediaSearchTool, FinalAnswerTool
9
 
10
  # (Keep Constants as is)
11
  # --- Constants ---
 
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
16
 
17
+ agent = CodeAgent(
18
+ tools=tools,
19
+ model=model,
20
+ max_steps=10,
21
+ verbosity=2
22
+ )
23
+
24
+ import os
25
+ from smolagents import HfApiModel
26
+
27
+ model = HfApiModel(
28
+ model_id="Qwen/Qwen1.5-1.8B-Chat", # example HF chat model
29
+ token=os.getenv("HF_TOKEN") # only needed if private model
30
+ )
31
+
32
  try:
33
  import ddgs
34
  except ImportError:
 
43
  print("Did not receive API key.")
44
  else:
45
  print(f"First 5 characters of the provided API key: {api_key[:5]}")
46
+ os.environ["HF_TOKEN"] = api_key
47
  print("BasicAgent initialized.")
48
  def __call__(self, question: str) -> str:
49
  print(f"Agent received question (first 50 chars): {question[:50]}...")