AksharaSachin commited on
Commit
c3eec90
·
verified ·
1 Parent(s): 9142765

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -23
app.py CHANGED
@@ -11,6 +11,7 @@ from langchain.prompts.chat import SystemMessagePromptTemplate, ChatPromptTempla
11
  from langchain_huggingface import HuggingFaceEndpoint
12
  from huggingface_hub import login
13
  from langchain.llms import HuggingFaceHub
 
14
 
15
 
16
 
@@ -51,29 +52,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
51
  # 1. Instantiate Agent ( modify this part to create your agent)
52
  try:
53
  # llm = ChatOllama(model="llama3.1")
54
- login(token=os.getenv('HF_TOKEN'))
55
-
56
- # Use a Hugging Face cloud model
57
- llm = HuggingFaceHub(
58
- repo_id="google/flan-t5-base", # Example cloud model; change as needed,
59
- task="text-generation"
60
- )
61
-
62
- search = DuckDuckGoSearchRun()
63
- tools = [
64
- Tool(
65
- name="DuckDuckGo Search",
66
- func=search.run,
67
- description="Useful for answering questions about current events or the web."
68
- )
69
- ]
70
- agent = initialize_agent(
71
- tools,
72
- llm,
73
- agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
74
- verbose=True,
75
- handle_parsing_errors=True
76
- )
77
  except Exception as e:
78
  print(f"Error instantiating agent: {e}")
79
  return f"Error initializing agent: {e}", None
 
11
  from langchain_huggingface import HuggingFaceEndpoint
12
  from huggingface_hub import login
13
  from langchain.llms import HuggingFaceHub
14
+ from agent import build_agent
15
 
16
 
17
 
 
52
  # 1. Instantiate Agent ( modify this part to create your agent)
53
  try:
54
  # llm = ChatOllama(model="llama3.1")
55
+ agent = build_agent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  except Exception as e:
57
  print(f"Error instantiating agent: {e}")
58
  return f"Error initializing agent: {e}", None