Papireddy commited on
Commit
c9269a7
·
1 Parent(s): 720a404
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from dotenv import load_dotenv
4
+ import google.generativeai as genai
5
+ import random
6
+ import time
7
+ load_dotenv()
8
+
9
+ genai.configure(api_key = os.environ["GOOGLE_API_KEY"])
10
+
11
+ model = genai.GenerativeModel('gemini-pro')
12
+ chat = model.start_chat(history=[])
13
+
14
+
15
+ with gr.Blocks() as demo:
16
+ chatbot = gr.Chatbot()
17
+ msg = gr.Textbox()
18
+ clear = gr.ClearButton([msg, chatbot])
19
+
20
+ def respond(msg, chat_history):
21
+ user_message = msg
22
+ bot_message = chat.send_message(user_message)
23
+ print(type(bot_message))
24
+ chat_history.append((user_message, bot_message.text))
25
+ time.sleep(2)
26
+ return "", chat_history
27
+
28
+
29
+ msg.submit(respond,[msg,chatbot],[msg,chatbot])
30
+
31
+
32
+ if __name__ == "__main__":
33
+ demo.launch(share=True)
34
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio