Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.1")
|
| 5 |
|
|
|
|
| 6 |
def format_prompt(message, history):
|
| 7 |
prompt = "<s>"
|
| 8 |
for user_prompt, bot_response in history:
|
|
@@ -11,6 +12,7 @@ def format_prompt(message, history):
|
|
| 11 |
prompt += f"[INST] {message} [/INST]"
|
| 12 |
return prompt
|
| 13 |
|
|
|
|
| 14 |
def generate(
|
| 15 |
prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
| 16 |
):
|
|
@@ -31,7 +33,11 @@ def generate(
|
|
| 31 |
formatted_prompt = format_prompt(prompt, history)
|
| 32 |
|
| 33 |
stream = client.text_generation(
|
| 34 |
-
formatted_prompt,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
output = ""
|
| 37 |
|
|
@@ -40,6 +46,7 @@ def generate(
|
|
| 40 |
yield output
|
| 41 |
return output
|
| 42 |
|
|
|
|
| 43 |
additional_inputs = [
|
| 44 |
gr.Slider(
|
| 45 |
label="Temperature",
|
|
@@ -83,8 +90,14 @@ initial_prompt = "Hello John! Welcome to our simulation interview for the Soluti
|
|
| 83 |
|
| 84 |
gr.ChatInterface(
|
| 85 |
generate,
|
| 86 |
-
gr.Textbox(label="Initial Prompt", type="text", default=initial_prompt),
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
).launch(show_api=False)
|
|
|
|
| 3 |
|
| 4 |
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.1")
|
| 5 |
|
| 6 |
+
|
| 7 |
def format_prompt(message, history):
|
| 8 |
prompt = "<s>"
|
| 9 |
for user_prompt, bot_response in history:
|
|
|
|
| 12 |
prompt += f"[INST] {message} [/INST]"
|
| 13 |
return prompt
|
| 14 |
|
| 15 |
+
|
| 16 |
def generate(
|
| 17 |
prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
| 18 |
):
|
|
|
|
| 33 |
formatted_prompt = format_prompt(prompt, history)
|
| 34 |
|
| 35 |
stream = client.text_generation(
|
| 36 |
+
formatted_prompt,
|
| 37 |
+
**generate_kwargs,
|
| 38 |
+
stream=True,
|
| 39 |
+
details=True,
|
| 40 |
+
return_full_text=False,
|
| 41 |
)
|
| 42 |
output = ""
|
| 43 |
|
|
|
|
| 46 |
yield output
|
| 47 |
return output
|
| 48 |
|
| 49 |
+
|
| 50 |
additional_inputs = [
|
| 51 |
gr.Slider(
|
| 52 |
label="Temperature",
|
|
|
|
| 90 |
|
| 91 |
gr.ChatInterface(
|
| 92 |
generate,
|
| 93 |
+
inputs=[gr.Textbox(label="Initial Prompt", type="text", default=initial_prompt)],
|
| 94 |
+
outputs=gr.Chatbot(
|
| 95 |
+
show_label=False,
|
| 96 |
+
show_share_button=False,
|
| 97 |
+
show_copy_button=True,
|
| 98 |
+
likeable=True,
|
| 99 |
+
layout="panel",
|
| 100 |
+
),
|
| 101 |
+
additional_inputs=additional_inputs,
|
| 102 |
+
title="Mistral 7B",
|
| 103 |
).launch(show_api=False)
|