Spaces:
Sleeping
Sleeping
import gradio as gr | |
import google.generativeai as genai | |
genai.configure(api_key="KEY") | |
# Set up the model | |
generation_config = { | |
"temperature": 0.9, | |
"top_p": 1, | |
"top_k": 1, | |
"max_output_tokens": 2048, | |
} | |
model = genai.GenerativeModel(model_name="gemini-pro", | |
generation_config=generation_config) | |
def chat(prompt): | |
convo = model.start_chat(history=[]) | |
convo.send_message(prompt) | |
return convo.last.text | |
# Create the Gradio interface | |
chat_interface = gr.Interface( | |
fn=chat, | |
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."), | |
outputs=gr.Textbox(lines=2, placeholder="Bot response..."), | |
) | |
chat_interface.launch() |