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("BSC-LT/ALIA-40b")
|
8 |
|
9 |
-
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
@@ -15,31 +14,27 @@ def respond(
|
|
15 |
temperature,
|
16 |
top_p,
|
17 |
):
|
18 |
-
|
19 |
-
|
20 |
-
for val in history:
|
21 |
-
if val[0]:
|
22 |
-
messages.append({"role": "user", "content": val[0]})
|
23 |
-
if val[1]:
|
24 |
-
messages.append({"role": "assistant", "content": val[1]})
|
25 |
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
response = ""
|
29 |
|
30 |
-
for message in client.
|
31 |
-
|
32 |
-
|
33 |
-
stream=True,
|
34 |
temperature=temperature,
|
35 |
top_p=top_p,
|
|
|
36 |
):
|
37 |
-
|
38 |
-
|
39 |
-
response += token
|
40 |
yield response
|
41 |
|
42 |
|
|
|
43 |
"""
|
44 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
45 |
"""
|
|
|
6 |
"""
|
7 |
client = InferenceClient("BSC-LT/ALIA-40b")
|
8 |
|
|
|
9 |
def respond(
|
10 |
message,
|
11 |
history: list[tuple[str, str]],
|
|
|
14 |
temperature,
|
15 |
top_p,
|
16 |
):
|
17 |
+
prompt = f"{system_message}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
for user_input, bot_response in history:
|
20 |
+
prompt += f"User: {user_input}\nAssistant: {bot_response}\n"
|
21 |
+
|
22 |
+
prompt += f"User: {message}\nAssistant:"
|
23 |
|
24 |
response = ""
|
25 |
|
26 |
+
for message in client.text_generation(
|
27 |
+
prompt=prompt,
|
28 |
+
max_new_tokens=max_tokens,
|
|
|
29 |
temperature=temperature,
|
30 |
top_p=top_p,
|
31 |
+
stream=True
|
32 |
):
|
33 |
+
response += message
|
|
|
|
|
34 |
yield response
|
35 |
|
36 |
|
37 |
+
|
38 |
"""
|
39 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
40 |
"""
|