Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,27 +3,16 @@ from huggingface_hub import InferenceClient
|
|
3 |
|
4 |
client = InferenceClient("Orenguteng/Llama-3-8B-Lexi-Uncensored")
|
5 |
|
6 |
-
|
7 |
-
def respond(
|
8 |
-
message,
|
9 |
-
history: list[tuple[str, str]],
|
10 |
-
system_message,
|
11 |
-
max_tokens,
|
12 |
-
temperature,
|
13 |
-
top_p,
|
14 |
-
):
|
15 |
messages = [{"role": "system", "content": system_message}]
|
16 |
-
|
17 |
for val in history:
|
18 |
if val[0]:
|
19 |
messages.append({"role": "user", "content": val[0]})
|
20 |
if val[1]:
|
21 |
messages.append({"role": "assistant", "content": val[1]})
|
22 |
-
|
23 |
messages.append({"role": "user", "content": message})
|
24 |
|
25 |
response = ""
|
26 |
-
|
27 |
for message in client.chat_completion(
|
28 |
messages,
|
29 |
max_tokens=max_tokens,
|
@@ -32,27 +21,17 @@ def respond(
|
|
32 |
top_p=top_p,
|
33 |
):
|
34 |
token = message.choices[0].delta.content
|
35 |
-
|
36 |
response += token
|
37 |
yield response
|
38 |
|
39 |
-
|
40 |
demo = gr.ChatInterface(
|
41 |
respond,
|
42 |
additional_inputs=[
|
43 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
44 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
45 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
46 |
-
gr.Slider(
|
47 |
-
minimum=0.1,
|
48 |
-
maximum=1.0,
|
49 |
-
value=0.95,
|
50 |
-
step=0.05,
|
51 |
-
label="Top-p (nucleus sampling)",
|
52 |
-
),
|
53 |
],
|
54 |
)
|
55 |
|
56 |
-
|
57 |
-
if __name__ == "__main__":
|
58 |
-
demo.launch()
|
|
|
3 |
|
4 |
client = InferenceClient("Orenguteng/Llama-3-8B-Lexi-Uncensored")
|
5 |
|
6 |
+
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
messages = [{"role": "system", "content": system_message}]
|
|
|
8 |
for val in history:
|
9 |
if val[0]:
|
10 |
messages.append({"role": "user", "content": val[0]})
|
11 |
if val[1]:
|
12 |
messages.append({"role": "assistant", "content": val[1]})
|
|
|
13 |
messages.append({"role": "user", "content": message})
|
14 |
|
15 |
response = ""
|
|
|
16 |
for message in client.chat_completion(
|
17 |
messages,
|
18 |
max_tokens=max_tokens,
|
|
|
21 |
top_p=top_p,
|
22 |
):
|
23 |
token = message.choices[0].delta.content
|
|
|
24 |
response += token
|
25 |
yield response
|
26 |
|
|
|
27 |
demo = gr.ChatInterface(
|
28 |
respond,
|
29 |
additional_inputs=[
|
30 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
31 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
32 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
33 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
],
|
35 |
)
|
36 |
|
37 |
+
demo.launch()
|
|
|
|