Jonas Wiesli commited on
Commit
a0e8812
1 Parent(s): 2817c27

added multiple characters

Browse files
Files changed (1) hide show
  1. app.py +16 -10
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
- with gr.Tab("Security Guard"):
9
- chatbot = gr.Chatbot()
10
- msg = gr.Textbox()
11
- with gr.Tab("Curator"):
12
- chatbot = gr.Chatbot()
13
- msg = gr.Textbox()
 
 
 
 
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
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
59
- bot, chatbot, chatbot
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()