i-dhilip commited on
Commit
2da0ef4
·
verified ·
1 Parent(s): 4985a8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -14,7 +14,7 @@ from langchain_community.tools.arxiv.tool import ArxivQueryRun
14
  from langchain_community.utilities.arxiv import ArxivAPIWrapper
15
 
16
  from langgraph.graph import StateGraph, END
17
- from langgraph.prebuilt import ToolInvocation
18
  from langchain_core.messages import BaseMessage, FunctionMessage, HumanMessage, AIMessage
19
  from langchain_openai import ChatOpenAI
20
 
@@ -31,11 +31,17 @@ if not OPENROUTER_API_KEY:
31
  print("Warning: OPENROUTER_API_KEY not found in .env file. The LLM will not function.")
32
 
33
  # --- Tool Setup ---
34
- tavily_tool = TavilySearchResults(max_results=3, api_key=TAVILY_API_KEY if TAVILY_API_KEY else "placeholder_tavily_key") # Add placeholder if not found
 
 
 
 
 
 
35
  wikipedia_tool = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=2, doc_content_chars_max=2000))
 
36
  arxiv_tool = ArxivQueryRun(api_wrapper=ArxivAPIWrapper(top_k_results=2, doc_content_chars_max=2000))
37
-
38
- tools = [tavily_tool, wikipedia_tool, arxiv_tool]
39
 
40
  # --- LangGraph Agent Definition ---
41
  class AgentState(TypedDict):
@@ -341,5 +347,4 @@ if __name__ == "__main__":
341
  print("-"*(60 + len(" App Starting ")) + "\n")
342
 
343
  print("Launching Gradio Interface for LangGraph GAIA Agent Evaluation...")
344
- demo.launch(debug=True, share=False)
345
-
 
14
  from langchain_community.utilities.arxiv import ArxivAPIWrapper
15
 
16
  from langgraph.graph import StateGraph, END
17
+
18
  from langchain_core.messages import BaseMessage, FunctionMessage, HumanMessage, AIMessage
19
  from langchain_openai import ChatOpenAI
20
 
 
31
  print("Warning: OPENROUTER_API_KEY not found in .env file. The LLM will not function.")
32
 
33
  # --- Tool Setup ---
34
+ tools = []
35
+ if TAVILY_API_KEY:
36
+ tavily_tool = TavilySearchResults(max_results=3, api_key=TAVILY_API_KEY)
37
+ tools.append(tavily_tool)
38
+ else:
39
+ print("Warning: TAVILY_API_KEY not found in .env file. TavilySearchResults tool will not be available.")
40
+
41
  wikipedia_tool = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=2, doc_content_chars_max=2000))
42
+ tools.append(wikipedia_tool)
43
  arxiv_tool = ArxivQueryRun(api_wrapper=ArxivAPIWrapper(top_k_results=2, doc_content_chars_max=2000))
44
+ tools.append(arxiv_tool)
 
45
 
46
  # --- LangGraph Agent Definition ---
47
  class AgentState(TypedDict):
 
347
  print("-"*(60 + len(" App Starting ")) + "\n")
348
 
349
  print("Launching Gradio Interface for LangGraph GAIA Agent Evaluation...")
350
+ demo.launch(debug=True, share=False)