ehristoforu commited on
Commit
d005d10
·
1 Parent(s): 0e5986d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ import gradio as gr
3
+
4
+ genai.configure(api_key=os.getenv("GOOGLE_PALM_KEY"))
5
+
6
+
7
+ def generate(prompt, history, system):
8
+ sub_arrays_as_strings = [' '.join(sub_array) for sub_array in history]
9
+ result_string = ' '.join(sub_arrays_as_strings)
10
+ response = genai.chat(
11
+ context=result_string+", "+system,
12
+ messages=prompt)
13
+
14
+ return response.last
15
+
16
+ additional = [
17
+ gr.Textbox(label="System Prompt", max_lines=1, info="English only", value="You are PaLM-2 (AI-assistant from Google)"),
18
+ ]
19
+
20
+ gr.ChatInterface(
21
+ fn=generate,
22
+ chatbot=gr.Chatbot(show_label=False, avatar_images=(None, 'https://raw.githubusercontent.com/googlefonts/noto-emoji/main/svg/emoji_u1f334.svg'), show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
23
+ additional_inputs=additional,
24
+ title="PaLM-2",
25
+ concurrency_limit=20,
26
+ ).launch(show_api=False)