Spaces:
Sleeping
Sleeping
| 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() |