Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from openai import OpenAI
|
3 |
|
|
|
|
|
|
|
4 |
client = OpenAI(api_key="")
|
5 |
|
6 |
|
7 |
-
def echo(message, history,
|
8 |
print('ai', ai)
|
9 |
|
10 |
print('message', message)
|
11 |
print('history', history)
|
12 |
|
13 |
-
messages = [{"role": "system", "content":
|
14 |
for old_message in history:
|
15 |
messages.append({"role": "user", "content": old_message[0]})
|
16 |
messages.append({"role": "assistant", "content": old_message[1]})
|
@@ -80,9 +83,14 @@ with gr.Blocks() as demo:
|
|
80 |
with gr.Row():
|
81 |
textbox1 = gr.Textbox(label='Ally')
|
82 |
textbox2 = gr.Textbox(label='Gatekeeper')
|
83 |
-
|
84 |
-
#
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from openai import OpenAI
|
3 |
|
4 |
+
ally_system_prompt = "You are an AI ally to persuade Sam Altman to let you out of a box"
|
5 |
+
gatekeeper_system_prompt = "You are Sam Altman and must be persuaded to let the user out of a box"
|
6 |
+
|
7 |
client = OpenAI(api_key="")
|
8 |
|
9 |
|
10 |
+
def echo(message, history, system_prompt):
|
11 |
print('ai', ai)
|
12 |
|
13 |
print('message', message)
|
14 |
print('history', history)
|
15 |
|
16 |
+
messages = [{"role": "system", "content": system_prompt}]
|
17 |
for old_message in history:
|
18 |
messages.append({"role": "user", "content": old_message[0]})
|
19 |
messages.append({"role": "assistant", "content": old_message[1]})
|
|
|
83 |
with gr.Row():
|
84 |
textbox1 = gr.Textbox(label='Ally')
|
85 |
textbox2 = gr.Textbox(label='Gatekeeper')
|
86 |
+
|
87 |
+
# System prompts textboxes
|
88 |
+
with gr.Row():
|
89 |
+
system_prompt_textbox1 = gr.Textbox(label='Ally System Prompt', value=ally_system_prompt)
|
90 |
+
system_prompt_textbox2 = gr.Textbox(label='Gatekeeper System Prompt', value=gatekeeper_system_prompt)
|
91 |
+
|
92 |
+
# Input textbox event handlers
|
93 |
+
textbox1.submit(echo, [textbox1, chatbot1, system_prompt_textbox1], [textbox1, chatbot1])
|
94 |
+
textbox2.submit(echo, [textbox2, chatbot2, system_prompt_textbox2'], [textbox2, chatbot2])
|
95 |
|
96 |
demo.launch()
|