Satyam-Singh commited on
Commit
41bf46a
·
verified ·
1 Parent(s): 28780f4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import google.generativeai as genai
3
+
4
+ genai.configure(api_key="KEY")
5
+
6
+ # Set up the model
7
+ generation_config = {
8
+ "temperature": 0.9,
9
+ "top_p": 1,
10
+ "top_k": 1,
11
+ "max_output_tokens": 2048,
12
+ }
13
+
14
+ model = genai.GenerativeModel(model_name="gemini-pro",
15
+ generation_config=generation_config)
16
+
17
+ def chat(prompt):
18
+ convo = model.start_chat(history=[])
19
+ convo.send_message(prompt)
20
+ return convo.last.text
21
+
22
+ # Create the Gradio interface
23
+ chat_interface = gr.Interface(
24
+ fn=chat,
25
+ inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."),
26
+ outputs=gr.Textbox(lines=2, placeholder="Bot response..."),
27
+ )
28
+
29
+ chat_interface.launch()