seawolf2357
commited on
Commit
โข
8ce49a6
1
Parent(s):
e8bc679
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from huggingface_hub import InferenceClient
|
|
3 |
import os
|
4 |
import requests
|
5 |
|
6 |
-
#
|
7 |
hf_client = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407", token=os.getenv("HF_TOKEN"))
|
8 |
|
9 |
def respond(
|
@@ -16,10 +16,10 @@ def respond(
|
|
16 |
):
|
17 |
|
18 |
system_prefix = """
|
19 |
-
|
20 |
"""
|
21 |
|
22 |
-
messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}] # prefix
|
23 |
|
24 |
for val in history:
|
25 |
if val[0]:
|
@@ -40,7 +40,7 @@ def respond(
|
|
40 |
):
|
41 |
token = message.choices[0].delta.content
|
42 |
if token is not None:
|
43 |
-
response += token.strip("") #
|
44 |
yield response
|
45 |
|
46 |
|
@@ -56,8 +56,8 @@ demo = gr.ChatInterface(
|
|
56 |
respond,
|
57 |
additional_inputs=[
|
58 |
gr.Textbox(value="""
|
59 |
-
|
60 |
-
""", label="
|
61 |
gr.Slider(minimum=1, maximum=2000, value=512, step=1, label="Max new tokens"),
|
62 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
63 |
gr.Slider(
|
@@ -68,11 +68,9 @@ demo = gr.ChatInterface(
|
|
68 |
label="Top-p (nucleus sampling)",
|
69 |
),
|
70 |
],
|
71 |
-
theme=theme, #
|
72 |
-
css=css # CSS
|
73 |
)
|
74 |
|
75 |
-
|
76 |
-
|
77 |
if __name__ == "__main__":
|
78 |
demo.launch()
|
|
|
3 |
import os
|
4 |
import requests
|
5 |
|
6 |
+
# Set up the inference API client
|
7 |
hf_client = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407", token=os.getenv("HF_TOKEN"))
|
8 |
|
9 |
def respond(
|
|
|
16 |
):
|
17 |
|
18 |
system_prefix = """
|
19 |
+
If the input language is Korean, respond in Korean. If it's English, respond in English.
|
20 |
"""
|
21 |
|
22 |
+
messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}] # Add prefix
|
23 |
|
24 |
for val in history:
|
25 |
if val[0]:
|
|
|
40 |
):
|
41 |
token = message.choices[0].delta.content
|
42 |
if token is not None:
|
43 |
+
response += token.strip("") # Remove tokens
|
44 |
yield response
|
45 |
|
46 |
|
|
|
56 |
respond,
|
57 |
additional_inputs=[
|
58 |
gr.Textbox(value="""
|
59 |
+
You are an AI assistant.
|
60 |
+
""", label="System Prompt"),
|
61 |
gr.Slider(minimum=1, maximum=2000, value=512, step=1, label="Max new tokens"),
|
62 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
63 |
gr.Slider(
|
|
|
68 |
label="Top-p (nucleus sampling)",
|
69 |
),
|
70 |
],
|
71 |
+
theme=theme, # Apply theme
|
72 |
+
css=css # Apply CSS
|
73 |
)
|
74 |
|
|
|
|
|
75 |
if __name__ == "__main__":
|
76 |
demo.launch()
|