lopera47 commited on
Commit
518a7d0
·
verified ·
1 Parent(s): 61d3db3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -3,15 +3,15 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from langchain.agents import initialize_agent, Tool
7
- from langchain.agents.agent_types import AgentType
8
- from langchain.chat_models import ChatOpenAI
9
- from langchain.tools import DuckDuckGoSearchRun
10
- from langchain_community.llms import HuggingFaceHub
11
- from langchain_huggingface import HuggingFaceEndpoint
12
- from langchain_community.chat_models import ChatHuggingFace
13
- from langchain.llms.base import LLM
14
- from huggingface_hub import InferenceClient
15
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
16
 
17
 
@@ -30,21 +30,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
30
 
31
  # --- Basic Agent Definition ---
32
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
33
-
34
-
35
  class BasicAgent:
36
  def __init__(self):
37
  print("BasicAgent initialized.")
38
 
39
- # Initialize the Agent with a text generation model (Falcon 7B instruct)
40
- self.agent = CodeAgent(
41
- tools=[DuckDuckGoSearchTool()],
42
- model=InferenceClientModel(
43
- "tiiuae/falcon-7b-instruct",
44
- temperature=0
45
- )
46
- )
47
-
48
 
49
  def __call__(self, question: str) -> str:
50
  print(f"Agent received question (first 50 chars): {question[:50]}...")
@@ -54,6 +45,7 @@ class BasicAgent:
54
  # Return the answer stripped (no extra spaces/newlines)
55
  return answer.strip()
56
 
 
57
  def run_and_submit_all( profile: gr.OAuthProfile | None):
58
  """
59
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ # from langchain.agents import initialize_agent, Tool
7
+ # from langchain.agents.agent_types import AgentType
8
+ # from langchain.chat_models import ChatOpenAI
9
+ # from langchain.tools import DuckDuckGoSearchRun
10
+ # from langchain_community.llms import HuggingFaceHub
11
+ # from langchain_huggingface import HuggingFaceEndpoint
12
+ # from langchain_community.chat_models import ChatHuggingFace
13
+ # from langchain.llms.base import LLM
14
+ # from huggingface_hub import InferenceClient
15
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
16
 
17
 
 
30
 
31
  # --- Basic Agent Definition ---
32
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
33
  class BasicAgent:
34
  def __init__(self):
35
  print("BasicAgent initialized.")
36
 
37
+ # Initialize the Agent
38
+ self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel())
 
 
 
 
 
 
 
39
 
40
  def __call__(self, question: str) -> str:
41
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
45
  # Return the answer stripped (no extra spaces/newlines)
46
  return answer.strip()
47
 
48
+ # Put it all together
49
  def run_and_submit_all( profile: gr.OAuthProfile | None):
50
  """
51
  Fetches all questions, runs the BasicAgent on them, submits all answers,