Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,11 +13,11 @@ def format_prompt(message, history, system_prompt):
|
|
13 |
prompt += f"[INST] {message} [/INST]"
|
14 |
return prompt
|
15 |
|
16 |
-
def format_sys_prompt(username, botname, botpersonality, botexamplechat):
|
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\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, max_new_tokens=1024, temperature=1.2, top_p=0.95, repetition_penalty=1.0,
|
21 |
):
|
22 |
|
23 |
temperature = float(temperature)
|
@@ -35,7 +35,7 @@ def generate(
|
|
35 |
)
|
36 |
|
37 |
|
38 |
-
formatted_prompt = format_prompt(prompt, history, format_sys_prompt(username, botname, botpersonality, botexamplechat))
|
39 |
|
40 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
41 |
output = ""
|
@@ -59,6 +59,7 @@ demo = gr.ChatInterface(fn=generate,
|
|
59 |
gr.Textbox(label="Name of bot", lines=1, value="Janet"),
|
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.Slider(label="Max new tokens", maximum=2048, value=512)
|
63 |
]
|
64 |
)
|
|
|
13 |
prompt += f"[INST] {message} [/INST]"
|
14 |
return prompt
|
15 |
|
16 |
+
def format_sys_prompt(username, botname, botpersonality, botexamplechat, chatsituation):
|
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)
|
|
|
35 |
)
|
36 |
|
37 |
|
38 |
+
formatted_prompt = format_prompt(prompt, history, format_sys_prompt(username, botname, botpersonality, botexamplechat, chatsituation))
|
39 |
|
40 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
41 |
output = ""
|
|
|
59 |
gr.Textbox(label="Name of bot", lines=1, value="Janet"),
|
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 |
)
|