Spaces:
Sleeping
Sleeping
none type error fixed
Browse files
app.py
CHANGED
@@ -7,6 +7,39 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
7 |
client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
|
8 |
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
@@ -34,10 +67,11 @@ def respond(
|
|
34 |
temperature=temperature,
|
35 |
top_p=top_p,
|
36 |
):
|
37 |
-
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
yield response
|
41 |
|
42 |
"""
|
43 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
7 |
client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
|
8 |
|
9 |
|
10 |
+
# def respond(
|
11 |
+
# message,
|
12 |
+
# history: list[tuple[str, str]],
|
13 |
+
# system_message,
|
14 |
+
# max_tokens,
|
15 |
+
# temperature,
|
16 |
+
# top_p,
|
17 |
+
# ):
|
18 |
+
# messages = [{"role": "system", "content": system_message}]
|
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 |
+
# messages.append({"role": "user", "content": message})
|
27 |
+
|
28 |
+
# response = ""
|
29 |
+
|
30 |
+
# for message in client.chat_completion(
|
31 |
+
# messages,
|
32 |
+
# max_tokens=max_tokens,
|
33 |
+
# stream=True,
|
34 |
+
# temperature=temperature,
|
35 |
+
# top_p=top_p,
|
36 |
+
# ):
|
37 |
+
# token = message.choices[0].delta.content
|
38 |
+
|
39 |
+
# response += token
|
40 |
+
# yield response
|
41 |
+
|
42 |
+
##None type
|
43 |
def respond(
|
44 |
message,
|
45 |
history: list[tuple[str, str]],
|
|
|
67 |
temperature=temperature,
|
68 |
top_p=top_p,
|
69 |
):
|
70 |
+
if message.choices[0].delta.content is not None:
|
71 |
+
token = message.choices[0].delta.content
|
72 |
+
response += token
|
73 |
|
74 |
+
yield response
|
|
|
75 |
|
76 |
"""
|
77 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|