Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
|
9 |
-
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
@@ -23,7 +22,13 @@ def respond(
|
|
23 |
if val[1]:
|
24 |
messages.append({"role": "assistant", "content": val[1]})
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
response = ""
|
29 |
|
@@ -45,7 +50,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
|
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(
|
@@ -58,6 +63,5 @@ demo = gr.ChatInterface(
|
|
58 |
],
|
59 |
)
|
60 |
|
61 |
-
|
62 |
if __name__ == "__main__":
|
63 |
-
demo.launch()
|
|
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
|
|
|
9 |
def respond(
|
10 |
message,
|
11 |
history: list[tuple[str, str]],
|
|
|
22 |
if val[1]:
|
23 |
messages.append({"role": "assistant", "content": val[1]})
|
24 |
|
25 |
+
# Modify the prompt based on whether JSON output is requested
|
26 |
+
if "json" in message.lower():
|
27 |
+
modified_message = f"You are the best generator of gamification content. Your content is always engaging and awesome. Generate the following in JSON format: {message}"
|
28 |
+
else:
|
29 |
+
modified_message = f"You are a friendly and helpful assistant. {message}"
|
30 |
+
|
31 |
+
messages.append({"role": "user", "content": modified_message})
|
32 |
|
33 |
response = ""
|
34 |
|
|
|
50 |
demo = gr.ChatInterface(
|
51 |
respond,
|
52 |
additional_inputs=[
|
53 |
+
gr.Textbox(value="You are the best generator of gamification content. Your content is always engaging and awesome. You generate JSON data when asked.", label="System message"),
|
54 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
55 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
56 |
gr.Slider(
|
|
|
63 |
],
|
64 |
)
|
65 |
|
|
|
66 |
if __name__ == "__main__":
|
67 |
+
demo.launch()
|