Spaces:
Runtime error
Runtime error
Commit
Β·
aa79c62
1
Parent(s):
fc4acd6
Latxa
Browse files- app.py +23 -19
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
3 |
|
4 |
"""
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
"""
|
7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
-
|
9 |
|
10 |
def respond(
|
11 |
message,
|
@@ -15,29 +16,32 @@ def respond(
|
|
15 |
temperature,
|
16 |
top_p,
|
17 |
):
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
for val in history:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
messages.append({"role": "user", "content": message})
|
27 |
|
28 |
-
response = ""
|
29 |
|
30 |
-
for message in client.chat_completion(
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
):
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
|
|
41 |
|
42 |
"""
|
43 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
"""
|
6 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
7 |
"""
|
8 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
9 |
+
pipe = pipeline("text-generation", model="HiTZ/latxa-7b-v1")
|
10 |
|
11 |
def respond(
|
12 |
message,
|
|
|
16 |
temperature,
|
17 |
top_p,
|
18 |
):
|
19 |
+
|
20 |
+
message = pipe(system_message, max_new_tokens=50, num_beams=5)
|
21 |
+
# messages = [{"role": "system", "content": system_message}]
|
22 |
|
23 |
+
# for val in history:
|
24 |
+
# if val[0]:
|
25 |
+
# messages.append({"role": "user", "content": val[0]})
|
26 |
+
# if val[1]:
|
27 |
+
# messages.append({"role": "assistant", "content": val[1]})
|
28 |
|
29 |
+
# messages.append({"role": "user", "content": message})
|
30 |
|
31 |
+
# response = ""
|
32 |
|
33 |
+
# for message in client.chat_completion(
|
34 |
+
# messages,
|
35 |
+
# max_tokens=max_tokens,
|
36 |
+
# stream=True,
|
37 |
+
# temperature=temperature,
|
38 |
+
# top_p=top_p,
|
39 |
+
# ):
|
40 |
+
# token = message.choices[0].delta.content
|
41 |
|
42 |
+
# response += token
|
43 |
+
# yield response
|
44 |
+
return message
|
45 |
|
46 |
"""
|
47 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
huggingface_hub==0.22.2
|
|
|
|
1 |
+
huggingface_hub==0.22.2
|
2 |
+
transformers
|