File size: 782 Bytes
7505fbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from langchain_google_genai import ChatGoogleGenerativeAI
from dotenv import load_dotenv
import os
import gradio as gr

# Load environment variables
load_dotenv()
api_key = os.getenv("GOOGLE_API_KEY")
model = "gemini-2.5-flash"

# Define function to call Gemini model
def hello_langchain(prompt):
    llm = ChatGoogleGenerativeAI(api_key=api_key, model=model)
    response = llm.invoke(prompt)
    return response.content

# Gradio UI setup
interface = gr.Interface(
    fn=hello_langchain,
    inputs=gr.Textbox(lines=3, placeholder="Enter your prompt here..."),
    outputs="text",
    title="Gemini Chat with LangChain",
    description="Enter a prompt to get a response from Gemini 2.5 Flash using LangChain."
)

# Launch the UI
if __name__ == "__main__":
    interface.launch()