Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
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 |
-
#
|
23 |
-
|
|
|
|
|
|
|
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):
|