Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,34 +3,27 @@ from huggingface_hub import InferenceClient
|
|
3 |
|
4 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
5 |
|
6 |
-
def
|
7 |
-
"""Formats input
|
8 |
-
|
9 |
-
|
10 |
-
### Instruction:
|
11 |
-
{user_input}
|
12 |
-
|
13 |
-
### Response:
|
14 |
-
"""
|
15 |
-
return prompt
|
16 |
|
17 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
18 |
-
formatted_prompt =
|
19 |
|
20 |
response = client.text_generation(
|
21 |
-
formatted_prompt,
|
22 |
-
max_new_tokens=max_tokens,
|
23 |
temperature=temperature,
|
24 |
top_p=top_p,
|
25 |
)
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
demo = gr.ChatInterface(
|
30 |
respond,
|
31 |
additional_inputs=[
|
32 |
-
gr.
|
33 |
-
gr.Slider(minimum=1, maximum=250, value=128, step=1, label="Max new tokens"), # ✅ Keep ≤250
|
34 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
35 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
36 |
],
|
|
|
3 |
|
4 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
5 |
|
6 |
+
def format_clean_prompt(user_input):
|
7 |
+
"""Formats input without extra labels"""
|
8 |
+
return f"{user_input}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
11 |
+
formatted_prompt = format_clean_prompt(message)
|
12 |
|
13 |
response = client.text_generation(
|
14 |
+
formatted_prompt,
|
15 |
+
max_new_tokens=max_tokens,
|
16 |
temperature=temperature,
|
17 |
top_p=top_p,
|
18 |
)
|
19 |
|
20 |
+
# ✅ Clean output by removing extra newlines
|
21 |
+
yield response.strip()
|
22 |
|
23 |
demo = gr.ChatInterface(
|
24 |
respond,
|
25 |
additional_inputs=[
|
26 |
+
gr.Slider(minimum=1, maximum=250, value=128, step=1, label="Max new tokens"),
|
|
|
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 (nucleus sampling)"),
|
29 |
],
|