Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,9 @@ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
8 |
def format_prompt(message, history):
|
9 |
prompt = "<s>"
|
10 |
for user_prompt, bot_response in history:
|
11 |
-
prompt += f"
|
12 |
prompt += f" {bot_response}</s> "
|
13 |
-
prompt += f"
|
14 |
return prompt
|
15 |
|
16 |
def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
|
@@ -24,18 +24,15 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=904
|
|
24 |
do_sample=True,
|
25 |
seed=42,
|
26 |
)
|
27 |
-
|
28 |
now = datetime.datetime.now()
|
29 |
formatted_time = now.strftime("%H:%M:%S, %B %d, %Y")
|
30 |
system_prompt = f"System time: {formatted_time}"
|
31 |
-
|
32 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
33 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
34 |
-
|
35 |
output = ""
|
36 |
for response in stream:
|
37 |
output += response.token.text
|
38 |
-
|
39 |
|
40 |
additional_inputs = [
|
41 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
@@ -47,7 +44,7 @@ additional_inputs = [
|
|
47 |
|
48 |
gr.ChatInterface(
|
49 |
fn=generate,
|
50 |
-
chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height="auto"
|
51 |
additional_inputs=additional_inputs,
|
52 |
title="ConvoLite",
|
53 |
submit_btn="➢",
|
|
|
8 |
def format_prompt(message, history):
|
9 |
prompt = "<s>"
|
10 |
for user_prompt, bot_response in history:
|
11 |
+
prompt += f"[INST] {user_prompt} [/INST]"
|
12 |
prompt += f" {bot_response}</s> "
|
13 |
+
prompt += f"[INST] {message} [/INST]"
|
14 |
return prompt
|
15 |
|
16 |
def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
|
|
|
24 |
do_sample=True,
|
25 |
seed=42,
|
26 |
)
|
|
|
27 |
now = datetime.datetime.now()
|
28 |
formatted_time = now.strftime("%H:%M:%S, %B %d, %Y")
|
29 |
system_prompt = f"System time: {formatted_time}"
|
|
|
30 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
31 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
|
|
32 |
output = ""
|
33 |
for response in stream:
|
34 |
output += response.token.text
|
35 |
+
yield output
|
36 |
|
37 |
additional_inputs = [
|
38 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
|
|
44 |
|
45 |
gr.ChatInterface(
|
46 |
fn=generate,
|
47 |
+
chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height="auto"),
|
48 |
additional_inputs=additional_inputs,
|
49 |
title="ConvoLite",
|
50 |
submit_btn="➢",
|