Ragulvasanth66 commited on
Commit
c459374
·
verified ·
1 Parent(s): 4cbded8
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
7
 
8
  # (Keep Constants and BasicAgent class as is)
9
  # --- Constants ---
@@ -13,7 +13,13 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
- self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
 
 
 
 
 
 
17
 
18
  SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
19
  finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
@@ -27,7 +33,7 @@ class BasicAgent:
27
  to be put in the list is a number or a string.
28
  """
29
  self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + SYSTEM_PROMPT
30
-
31
  def __call__(self, question: str) -> str:
32
  print(f"Agent received question (first 50 chars): {question[:50]}...")
33
  final_answer = self.agent.run(question)
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
7
 
8
  # (Keep Constants and BasicAgent class as is)
9
  # --- Constants ---
 
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
+ self.agent = CodeAgent(
17
+ tools=[DuckDuckGoSearchTool()],
18
+ model=InferenceClientModel(
19
+ model_id="mistralai/Mistral-7B-Instruct-v0.1",
20
+ provider="huggingface"
21
+ )
22
+ )
23
 
24
  SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
25
  finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
 
33
  to be put in the list is a number or a string.
34
  """
35
  self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + SYSTEM_PROMPT
36
+
37
  def __call__(self, question: str) -> str:
38
  print(f"Agent received question (first 50 chars): {question[:50]}...")
39
  final_answer = self.agent.run(question)