Geminichatbot / app.py
PRSHNTKUMR's picture
Update app.py
a992207 verified
raw
history blame contribute delete
839 Bytes
import os
import google.generativeai as genai
import gradio as gr
# Set your API key (you'll set this in Hugging Face Secrets)
genai.configure(api_key=os.environ.get("GOOGLE_API_KEY"))
def generate(input, slider):
response = genai.chat(model='models/chat-bison-002',
messages=[{"role": "user", "content": input}])
output = response.text
return output
demo = gr.ChatInterface(
fn=generate,
chatbot=gr.Chatbot(height=300,type='messages'),
textbox=gr.Textbox(placeholder="Ask me anything", container=False, scale=7),
title="Your Gemini Pro Chat Bot",
description="Powered by Google Gemini Pro",
theme="soft",
examples=["Hello", "What's the weather like?", "Tell me a story"],
cache_examples=True,
)
# For Hugging Face Spaces deployment
demo.queue().launch(share=True)