Solarmonk commited on
Commit
84af721
·
1 Parent(s): 73ab916

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -72
app.py DELETED
@@ -1,72 +0,0 @@
1
- import gradio as gr
2
- import os
3
- import openai
4
-
5
- openai.api_key = ""
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):
44
- bot_message = generateAIMessage(history, 0)
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()