Spaces:
Sleeping
Sleeping
Jonas Wiesli
commited on
Commit
•
a0e8812
1
Parent(s):
2817c27
added multiple characters
Browse files
app.py
CHANGED
@@ -5,12 +5,16 @@ import openai
|
|
5 |
openai.api_key = "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"
|
6 |
|
7 |
with gr.Blocks() as iface:
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def user(user_message, history):
|
@@ -54,9 +58,11 @@ with gr.Blocks() as iface:
|
|
54 |
)
|
55 |
return completion.choices[0].message.content
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
|
62 |
iface.launch()
|
|
|
5 |
openai.api_key = "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"
|
6 |
|
7 |
with gr.Blocks() as iface:
|
8 |
+
chatbot = []
|
9 |
+
msg = []
|
10 |
+
roles = ["Security Guard", "Curator", "Researcher", "Conservationist", "Guide"]
|
11 |
+
|
12 |
+
i = 0
|
13 |
+
while i < len(roles):
|
14 |
+
with gr.Tab(roles[i]):
|
15 |
+
chatbot[i] = gr.Chatbot()
|
16 |
+
msg[i] = gr.Textbox()
|
17 |
+
i += 1
|
18 |
|
19 |
|
20 |
def user(user_message, history):
|
|
|
58 |
)
|
59 |
return completion.choices[0].message.content
|
60 |
|
61 |
+
i = 0
|
62 |
+
while i < len(msg):
|
63 |
+
msg[i].submit(user, [msg[i], chatbot[i]], [msg[i], chatbot[i]], queue=False).then(
|
64 |
+
bot, chatbot[i], chatbot[i]
|
65 |
+
)
|
66 |
+
i += 1
|
67 |
|
68 |
iface.launch()
|