skkjodhpur commited on
Commit
6d34563
·
verified ·
1 Parent(s): ddb08c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import gradio as gr
3
  from langchain_google_genai import GoogleGenerativeAIEmbeddings, ChatGoogleGenerativeAI
4
  from langchain_community.agent_toolkits.load_tools import load_tools
5
- from langchain.agents import create_react_agent # Updated import
6
 
7
  # Set up Google API keys from environment variables
8
  GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')
@@ -19,8 +19,11 @@ llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro")
19
  # Load tools
20
  tools = load_tools(["serpapi", "llm-math"], llm=llm, serpapi_api_key=SERPER_API_KEY)
21
 
22
- # Initialize the agent without the verbose argument
23
- agent = create_react_agent(tools, llm)
 
 
 
24
 
25
  # Function to run the agent
26
  def search(query):
 
2
  import gradio as gr
3
  from langchain_google_genai import GoogleGenerativeAIEmbeddings, ChatGoogleGenerativeAI
4
  from langchain_community.agent_toolkits.load_tools import load_tools
5
+ from langchain.agents import create_react_agent
6
 
7
  # Set up Google API keys from environment variables
8
  GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')
 
19
  # Load tools
20
  tools = load_tools(["serpapi", "llm-math"], llm=llm, serpapi_api_key=SERPER_API_KEY)
21
 
22
+ # Define a prompt for the agent
23
+ prompt = "You are a helpful assistant that answers questions based on the provided tools."
24
+
25
+ # Initialize the agent with the prompt
26
+ agent = create_react_agent(tools, llm, prompt)
27
 
28
  # Function to run the agent
29
  def search(query):