File size: 685 Bytes
41bf46a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()