Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,10 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
| 9 |
def respond(
|
| 10 |
message,
|
| 11 |
history: list[tuple[str, str]],
|
| 12 |
-
system_message
|
|
|
|
|
|
|
|
|
|
| 13 |
):
|
| 14 |
|
| 15 |
messages = [{"role": "system", "content": system_message}]
|
|
@@ -26,7 +29,10 @@ def respond(
|
|
| 26 |
|
| 27 |
for message in client.chat_completion(
|
| 28 |
messages,
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
):
|
| 31 |
token = message.choices[0].delta.content
|
| 32 |
|
|
@@ -39,7 +45,16 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 39 |
demo = gr.ChatInterface(
|
| 40 |
respond,
|
| 41 |
additional_inputs=[
|
| 42 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
],
|
| 44 |
)
|
| 45 |
|
|
|
|
| 9 |
def respond(
|
| 10 |
message,
|
| 11 |
history: list[tuple[str, str]],
|
| 12 |
+
system_message,
|
| 13 |
+
max_tokens,
|
| 14 |
+
temperature,
|
| 15 |
+
top_p,
|
| 16 |
):
|
| 17 |
|
| 18 |
messages = [{"role": "system", "content": system_message}]
|
|
|
|
| 29 |
|
| 30 |
for message in client.chat_completion(
|
| 31 |
messages,
|
| 32 |
+
max_tokens=max_tokens,
|
| 33 |
+
stream=True,
|
| 34 |
+
temperature=temperature,
|
| 35 |
+
top_p=top_p,
|
| 36 |
):
|
| 37 |
token = message.choices[0].delta.content
|
| 38 |
|
|
|
|
| 45 |
demo = gr.ChatInterface(
|
| 46 |
respond,
|
| 47 |
additional_inputs=[
|
| 48 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 49 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 50 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 51 |
+
gr.Slider(
|
| 52 |
+
minimum=0.1,
|
| 53 |
+
maximum=1.0,
|
| 54 |
+
value=0.95,
|
| 55 |
+
step=0.05,
|
| 56 |
+
label="Top-p (nucleus sampling)",
|
| 57 |
+
),
|
| 58 |
],
|
| 59 |
)
|
| 60 |
|