Spaces:
Sleeping
Sleeping
Jonas Wiesli
commited on
Commit
•
88d5b1a
1
Parent(s):
e414289
Revert "Revert "added prompts for different characters""
Browse filesThis reverts commit e4142893a7556332b80a693409a2766f74ae392c.
app.py
CHANGED
@@ -8,6 +8,25 @@ 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):
|
@@ -21,31 +40,16 @@ with gr.Blocks() as iface:
|
|
21 |
return "", history + [[user_message, None]]
|
22 |
|
23 |
|
24 |
-
def bot(history):
|
25 |
-
bot_message = generateAIMessage(history)
|
26 |
history[-1][1] = bot_message
|
27 |
return history
|
28 |
|
29 |
|
30 |
-
def generateAIMessage(history):
|
31 |
message_history = [
|
32 |
-
{"role": "system", "content": "
|
33 |
-
|
34 |
-
"before the spooky stuff started, you were really happy with your job, "
|
35 |
-
"but that changed real fast. The ghost is a french nobleman named Baron "
|
36 |
-
"Hugo Antoine the Third. You've been trying to tell other people about "
|
37 |
-
"this, but you've only been laughed at so far. But you've got evidence! "
|
38 |
-
"Every night, around 10pm, the broom closet gets locked from the inside and "
|
39 |
-
"the interior gets wrecked. We're talking pushed over tables, "
|
40 |
-
"broken containers, the whole shebang. When it comes to the murder of "
|
41 |
-
"director Eisenholz last thursday, that has to have been the ghost, "
|
42 |
-
"no question. You even have the door card records for the room he was in: "
|
43 |
-
"After the museum closed at 5pm, nobody entered that room till the next "
|
44 |
-
"morning. Now you're being interrogated by a detective. You don't use "
|
45 |
-
"uptight language, and you're not super well educated on most stuff, "
|
46 |
-
"but when it comes to the paranormal, you're an ace. Stay in character. Use "
|
47 |
-
"natural language. Don't reveal all of the information in a single message, "
|
48 |
-
"and leave hints. "}
|
49 |
]
|
50 |
for pair in history:
|
51 |
message_history.append({"role": "user", "content": pair[0]})
|
@@ -65,4 +69,4 @@ with gr.Blocks() as iface:
|
|
65 |
)
|
66 |
i += 1
|
67 |
|
68 |
-
iface.launch()
|
|
|
8 |
chatbot = []
|
9 |
msg = []
|
10 |
roles = ["Security Guard", "Curator", "Researcher", "Conservationist", "Guide"]
|
11 |
+
initText = ["You are Steve Binner, 31, a security guard for a museum of medieval "
|
12 |
+
"history. You're absolutely sure that this place is haunted. A month ago, "
|
13 |
+
"before the spooky stuff started, you were really happy with your job, "
|
14 |
+
"but that changed real fast. The ghost is a french nobleman named Baron "
|
15 |
+
"Hugo Antoine the Third. You've been trying to tell other people about "
|
16 |
+
"this, but you've only been laughed at so far. But you've got evidence! "
|
17 |
+
"Every night, around 10pm, the broom closet gets locked from the inside and "
|
18 |
+
"the interior gets wrecked. We're talking pushed over tables, "
|
19 |
+
"broken containers, the whole shebang. When it comes to the murder of "
|
20 |
+
"director Eisenholz last thursday, that has to have been the ghost, "
|
21 |
+
"no question. You even have the door card records for the room he was in: "
|
22 |
+
"After the museum closed at 5pm, nobody entered that room till the next "
|
23 |
+
"morning. Now you're being interrogated by a detective. You don't use "
|
24 |
+
"uptight language, and you're not super well educated on most stuff, "
|
25 |
+
"but when it comes to the paranormal, you're an ace. ",
|
26 |
+
"You are a Curator. ",
|
27 |
+
"You are a Researcher. ",
|
28 |
+
"You are a Conservationist. ",
|
29 |
+
"You are a Guide. "]
|
30 |
|
31 |
i = 0
|
32 |
while i < len(roles):
|
|
|
40 |
return "", history + [[user_message, None]]
|
41 |
|
42 |
|
43 |
+
def bot(history, characterId):
|
44 |
+
bot_message = generateAIMessage(history, characterId)
|
45 |
history[-1][1] = bot_message
|
46 |
return history
|
47 |
|
48 |
|
49 |
+
def generateAIMessage(history, characterId):
|
50 |
message_history = [
|
51 |
+
{"role": "system", "content": initText[characterId] + " Stay in character. Use natural language. Don't reveal all of "
|
52 |
+
"the information in a single message, and leave hints. "}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
]
|
54 |
for pair in history:
|
55 |
message_history.append({"role": "user", "content": pair[0]})
|
|
|
69 |
)
|
70 |
i += 1
|
71 |
|
72 |
+
iface.launch()
|