Spaces:
Running
Running
File size: 818 Bytes
b0397d2 a602ed1 b0397d2 e01406b b0397d2 |
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 |
import os
import gradio as gr
from langchain_google_genai.chat_models import ChatGoogleGenerativeAI
# Set the path to the service account key
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./firm-catalyst-437006-s4-407500537db5.json"
# Initialize the LLM
llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro")
def chat_with_gemini(user_input):
try:
# Prepare the prompt in the expected format
response = llm.predict(user_input) # Using the 'predict' method
return response
except Exception as e:
return f"Error: {str(e)}"
# Create a Gradio interface
iface = gr.Interface(
fn=chat_with_gemini,
inputs="text",
outputs="text",
title="Chatbot with Gemini 1.5",
description="Ask me anything!"
)
# Launch the interface with debugging
iface.launch(debug=True)
|