File size: 656 Bytes
6646be1
 
 
 
 
6a42314
6646be1
 
 
 
 
 
 
 
 
 
 
6a42314
6646be1
 
 
 
 
 
 
 
 
 
 
 
6a42314
6646be1
 
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
31
32
33
#import os
#exec(os.environ.get('CODE'))


import gradio as gr
import os
import google.generativeai as genai

def gemini_chat(message, history):
    response = chat.send_message(message)
    return response.text

API_KEY = os.getenv('GOOGLE_API_KEY')
genai.configure(api_key=API_KEY)

model = genai.GenerativeModel('gemini-pro')
chat = model.start_chat()

iface = gr.ChatInterface(
    fn=gemini_chat, 
    title='Gemini Chat',
    chatbot=gr.Chatbot(height=1000),
    textbox=gr.Textbox(
        placeholder="Message Gemini",
        scale=7
    ),
    retry_btn=None,
    undo_btn=None,
    clear_btn=None
)

if __name__ == '__main__':
    iface.launch()