Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,29 +3,24 @@ from huggingface_hub import InferenceClient
|
|
| 3 |
|
| 4 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
"""
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
| 11 |
-
formatted_prompt = format_alpaca_prompt(message, system_message)
|
| 12 |
-
|
| 13 |
response = client.text_generation(
|
| 14 |
-
|
| 15 |
-
max_new_tokens=max_tokens,
|
| 16 |
temperature=temperature,
|
| 17 |
top_p=top_p,
|
| 18 |
)
|
| 19 |
|
| 20 |
-
yield response # β
|
| 21 |
|
| 22 |
demo = gr.ChatInterface(
|
| 23 |
respond,
|
| 24 |
additional_inputs=[
|
| 25 |
-
gr.
|
| 26 |
-
gr.Slider(minimum=1, maximum=250, value=128, step=1, label="Max new tokens"), # β
Keep β€250
|
| 27 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 28 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p
|
| 29 |
],
|
| 30 |
)
|
| 31 |
|
|
|
|
| 3 |
|
| 4 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
| 5 |
|
| 6 |
+
def respond(message, history, max_tokens, temperature, top_p):
|
| 7 |
+
"""Sends only the user input as the prompt, ensuring a clean response."""
|
| 8 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
response = client.text_generation(
|
| 10 |
+
message, # β
Directly send user input
|
| 11 |
+
max_new_tokens=max_tokens,
|
| 12 |
temperature=temperature,
|
| 13 |
top_p=top_p,
|
| 14 |
)
|
| 15 |
|
| 16 |
+
yield response.strip() # β
Removes extra spaces/newlines
|
| 17 |
|
| 18 |
demo = gr.ChatInterface(
|
| 19 |
respond,
|
| 20 |
additional_inputs=[
|
| 21 |
+
gr.Slider(minimum=1, maximum=250, value=128, step=1, label="Max new tokens"),
|
|
|
|
| 22 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 23 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
|
| 24 |
],
|
| 25 |
)
|
| 26 |
|