Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,27 +15,27 @@ def respond(
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
-
for
|
| 31 |
-
|
| 32 |
-
|
| 33 |
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
|
|
|
| 36 |
):
|
| 37 |
-
token = message.choices[0].delta.content
|
| 38 |
-
|
| 39 |
response += token
|
| 40 |
yield response
|
| 41 |
|
|
@@ -46,7 +46,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 46 |
demo = gr.ChatInterface(
|
| 47 |
respond,
|
| 48 |
additional_inputs=[
|
| 49 |
-
gr.Textbox(value="You are a
|
| 50 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 51 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 52 |
gr.Slider(
|
|
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
+
# Format the conversation in Mistral's instruction format
|
| 19 |
+
prompt = f"<s>[INST] {system_message} [/INST]\n\n"
|
| 20 |
+
|
| 21 |
+
for user_msg, assistant_msg in history:
|
| 22 |
+
if user_msg:
|
| 23 |
+
prompt += f"[INST] {user_msg} [/INST]\n"
|
| 24 |
+
if assistant_msg:
|
| 25 |
+
prompt += f"{assistant_msg}\n\n"
|
| 26 |
+
|
| 27 |
+
prompt += f"[INST] {message} [/INST]\n"
|
| 28 |
|
| 29 |
response = ""
|
| 30 |
|
| 31 |
+
for token in client.text_generation(
|
| 32 |
+
prompt,
|
| 33 |
+
max_new_tokens=max_tokens,
|
| 34 |
stream=True,
|
| 35 |
temperature=temperature,
|
| 36 |
top_p=top_p,
|
| 37 |
+
do_sample=True,
|
| 38 |
):
|
|
|
|
|
|
|
| 39 |
response += token
|
| 40 |
yield response
|
| 41 |
|
|
|
|
| 46 |
demo = gr.ChatInterface(
|
| 47 |
respond,
|
| 48 |
additional_inputs=[
|
| 49 |
+
gr.Textbox(value="You are a Microsoft 365 data management assistant.", label="System message"),
|
| 50 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 51 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 52 |
gr.Slider(
|