File size: 953 Bytes
f06e15d ef78ad1 f06e15d ef78ad1 f06e15d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
from dotenv import load_dotenv
import gradio as gr
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain.agents import load_tools, initialize_agent
# Load environment variables
_ = load_dotenv()
llm = ChatGoogleGenerativeAI(
model="gemini-pro",
temperature=0.0, # temperature=0.7 (default)
# top_p=0.5,
)
tools = load_tools(["google-search"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
def main(query):
return agent.run(query)
if __name__ == "__main__":
try:
app = gr.Interface(
fn=main,
# inputs=["text", "text"],
inputs=[gr.Textbox(label="Search Query (γ―γ¨γͺγε
₯εγγ¦γγ γγ)")],
outputs=[gr.Textbox(label="Search Result (ζ€η΄’η΅ζ)")],
title="Google Search enhanced by LLM"
)
app.launch(share=True)
except Exception as e:
raise e |