Jonas Wiesli commited on
Commit
6455877
·
1 Parent(s): 6ec12b4

trying in different space

Browse files
.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
.idea/.name ADDED
@@ -0,0 +1 @@
 
 
1
+ app.py
.idea/Wiesli_Jonas.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/Wiesli_Jonas.iml" filepath="$PROJECT_DIR$/.idea/Wiesli_Jonas.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import openai
4
+
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
+ 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):
33
+ with gr.Tab(roles[i]):
34
+ chatbot.append(gr.Chatbot())
35
+ msg.append(gr.Textbox())
36
+ i += 1
37
+
38
+
39
+ def user(user_message, history):
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]})
56
+ print()
57
+ if pair[1] is not None:
58
+ message_history.append({"role": "assistant", "content": pair[1]})
59
+ completion = openai.ChatCompletion.create(
60
+ model="gpt-3.5-turbo",
61
+ messages=message_history
62
+ )
63
+ return completion.choices[0].message.content
64
+
65
+ i = 0
66
+ while i < len(msg):
67
+ msg[i].submit(user, [msg[i], chatbot[i]], [msg[i], chatbot[i]], queue=False).then(
68
+ bot, chatbot[i], chatbot[i]
69
+ )
70
+ i += 1
71
+
72
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai~=0.27.2