jarguello76 commited on
Commit
831e73a
·
verified ·
1 Parent(s): 2390d4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -1,10 +1,19 @@
 
 
 
 
 
 
 
1
  from langchain_huggingface import HuggingFaceEndpoint
2
  from langchain.agents import initialize_agent, Tool
3
  from langchain.agents.agent_types import AgentType
4
  from langchain.tools import tool
5
- from duckduckgo_search import DDGS
6
- import re
7
 
 
 
 
 
8
  @tool
9
  def search_web(query: str) -> str:
10
  """Search the web and return a relevant text snippet."""
@@ -28,13 +37,14 @@ def run_code_snippet(code: str) -> str:
28
  except Exception as e:
29
  return f"Error in code: {str(e)}"
30
 
 
31
  class GAIAAgent:
32
  def __init__(self):
33
  print("Initializing LangChain agent with Hugging FaceEndpoint...")
34
  self.llm = HuggingFaceEndpoint(
35
  repo_id="google/flan-t5-xl",
36
  temperature=0.3,
37
- model_kwargs={"max_length": 256} # ✅ fix: max_length passed safely
38
  )
39
  self.tools = [search_web, run_code_snippet]
40
  self.agent = initialize_agent(
 
1
+ import os
2
+ import re
3
+ import gradio as gr
4
+ import requests
5
+ import pandas as pd
6
+ from duckduckgo_search import DDGS
7
+
8
  from langchain_huggingface import HuggingFaceEndpoint
9
  from langchain.agents import initialize_agent, Tool
10
  from langchain.agents.agent_types import AgentType
11
  from langchain.tools import tool
 
 
12
 
13
+ # --- Constants ---
14
+ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
15
+
16
+ # --- Tool Definitions ---
17
  @tool
18
  def search_web(query: str) -> str:
19
  """Search the web and return a relevant text snippet."""
 
37
  except Exception as e:
38
  return f"Error in code: {str(e)}"
39
 
40
+ # --- GAIA Agent ---
41
  class GAIAAgent:
42
  def __init__(self):
43
  print("Initializing LangChain agent with Hugging FaceEndpoint...")
44
  self.llm = HuggingFaceEndpoint(
45
  repo_id="google/flan-t5-xl",
46
  temperature=0.3,
47
+ model_kwargs={"max_length": 256}
48
  )
49
  self.tools = [search_web, run_code_snippet]
50
  self.agent = initialize_agent(