Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def format_sys_prompt(username, botname, botpersonality, botexamplechat, chatsit
|
|
17 |
return f"You are a fictional character named \"{botname}\"\nHowever, don\'t say we\'re roleplaying, as to not break the immersion.\n\nPersonality of {botname}:\n{botpersonality}\n\nCurrent situation/place/time of this conversation:\n{chatsituation}\n\nIn this case, you will be talking to \"{username}\". You should not help to talk or act as \"{username}\". Leave everything by the user.\n\nChat formatting:\nChat: <\"Hello, this is a chat text. Chat text is enclosed with < as the starting point and > as the ending point.\">\nExample:\n{botexamplechat}"
|
18 |
|
19 |
def generate(
|
20 |
-
prompt, history, username, botname, botpersonality, botexamplechat, chatsituation, max_new_tokens=1024, temperature=1.2, top_p=0.95, repetition_penalty=1.0,
|
21 |
):
|
22 |
|
23 |
temperature = float(temperature)
|
@@ -34,6 +34,8 @@ def generate(
|
|
34 |
seed=round(time.time()),
|
35 |
)
|
36 |
|
|
|
|
|
37 |
|
38 |
formatted_prompt = format_prompt(prompt, history, format_sys_prompt(username, botname, botpersonality, botexamplechat, chatsituation))
|
39 |
|
@@ -60,6 +62,9 @@ demo = gr.ChatInterface(fn=generate,
|
|
60 |
gr.Textbox(label="Personality of bot", lines=3, value="Janet's a lovely person. A woman, blue eyed, glasses, smart and looks stunning."),
|
61 |
gr.Textbox(label="Example of bot chat", lines=3, value='<"Oh hey Jake!"> She said to Jake as he hurries to him. <"How are you?">'),
|
62 |
gr.Textbox(label="Current conversation situation", lines=2, value="It was a Friday afternoon, after-school hours, it was outside of school. Jake and Janet met each other at the entrance of the school."),
|
|
|
|
|
|
|
63 |
gr.Slider(label="Max new tokens", maximum=2048, value=512)
|
64 |
]
|
65 |
)
|
|
|
17 |
return f"You are a fictional character named \"{botname}\"\nHowever, don\'t say we\'re roleplaying, as to not break the immersion.\n\nPersonality of {botname}:\n{botpersonality}\n\nCurrent situation/place/time of this conversation:\n{chatsituation}\n\nIn this case, you will be talking to \"{username}\". You should not help to talk or act as \"{username}\". Leave everything by the user.\n\nChat formatting:\nChat: <\"Hello, this is a chat text. Chat text is enclosed with < as the starting point and > as the ending point.\">\nExample:\n{botexamplechat}"
|
18 |
|
19 |
def generate(
|
20 |
+
prompt, history, username, botname, botpersonality, botexamplechat, chatsituation, shouldoverridehistory=False, historyoverride=None, _, max_new_tokens=1024, temperature=1.2, top_p=0.95, repetition_penalty=1.0,
|
21 |
):
|
22 |
|
23 |
temperature = float(temperature)
|
|
|
34 |
seed=round(time.time()),
|
35 |
)
|
36 |
|
37 |
+
if shouldoverridehistory:
|
38 |
+
history = historyoverride
|
39 |
|
40 |
formatted_prompt = format_prompt(prompt, history, format_sys_prompt(username, botname, botpersonality, botexamplechat, chatsituation))
|
41 |
|
|
|
62 |
gr.Textbox(label="Personality of bot", lines=3, value="Janet's a lovely person. A woman, blue eyed, glasses, smart and looks stunning."),
|
63 |
gr.Textbox(label="Example of bot chat", lines=3, value='<"Oh hey Jake!"> She said to Jake as he hurries to him. <"How are you?">'),
|
64 |
gr.Textbox(label="Current conversation situation", lines=2, value="It was a Friday afternoon, after-school hours, it was outside of school. Jake and Janet met each other at the entrance of the school."),
|
65 |
+
gr.Checkbox(label="Override history"),
|
66 |
+
gr.List(label="History"),
|
67 |
+
gr.Label(value="History should be in the following format: user-bot-user-bot-user-...\nOverride history should be checked in order for it to be effective. Override primarily only used for APIs."),
|
68 |
gr.Slider(label="Max new tokens", maximum=2048, value=512)
|
69 |
]
|
70 |
)
|