Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,10 @@ from huggingface_hub import InferenceClient
|
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
| 7 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def respond(
|
|
@@ -27,17 +30,17 @@ def respond(
|
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
messages,
|
| 32 |
max_tokens=max_tokens,
|
| 33 |
-
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
| 36 |
-
)
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
response += token
|
| 40 |
-
yield response
|
| 41 |
|
| 42 |
"""
|
| 43 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
@@ -45,7 +48,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 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(
|
|
|
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
| 7 |
+
#client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 8 |
+
#client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
|
| 9 |
+
#client = InferenceClient("microsoft/Phi-3.5-mini-instruct")
|
| 10 |
+
client = InferenceClient("unsloth/Llama-3.2-1B-Instruct")
|
| 11 |
|
| 12 |
|
| 13 |
def respond(
|
|
|
|
| 30 |
|
| 31 |
response = ""
|
| 32 |
|
| 33 |
+
|
| 34 |
+
mensagens = client.chat_completion(
|
| 35 |
messages,
|
| 36 |
max_tokens=max_tokens,
|
|
|
|
| 37 |
temperature=temperature,
|
| 38 |
top_p=top_p,
|
| 39 |
+
)
|
| 40 |
+
response = mensagens.choices[0].message.content
|
| 41 |
+
|
| 42 |
+
return response
|
| 43 |
|
|
|
|
|
|
|
| 44 |
|
| 45 |
"""
|
| 46 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
|
| 48 |
demo = gr.ChatInterface(
|
| 49 |
respond,
|
| 50 |
additional_inputs=[
|
| 51 |
+
gr.Textbox(value="You are a friendly Chatbot. Your name is Juninho.", label="System message"),
|
| 52 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 53 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 54 |
gr.Slider(
|