Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
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 |
|
10 |
modelpath = "distilgpt2"
|
11 |
|
@@ -42,19 +42,26 @@ def respond(
|
|
42 |
|
43 |
messages.append({"role": "user", "content": message})
|
44 |
|
45 |
-
response =
|
46 |
-
|
47 |
-
for message in client.chat_completion(
|
48 |
messages,
|
49 |
-
|
50 |
-
stream=True,
|
51 |
temperature=temperature,
|
52 |
top_p=top_p,
|
53 |
-
)
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
|
60 |
"""
|
|
|
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 |
|
10 |
modelpath = "distilgpt2"
|
11 |
|
|
|
42 |
|
43 |
messages.append({"role": "user", "content": message})
|
44 |
|
45 |
+
response = pipe(
|
|
|
|
|
46 |
messages,
|
47 |
+
max_new_tokens=max_tokens,
|
|
|
48 |
temperature=temperature,
|
49 |
top_p=top_p,
|
50 |
+
)[0]["generated_text"]
|
51 |
+
yield response
|
52 |
+
#response = ""
|
53 |
+
|
54 |
+
#for message in client.chat_completion(
|
55 |
+
# messages,
|
56 |
+
# max_tokens=max_tokens,
|
57 |
+
# stream=True,
|
58 |
+
# temperature=temperature,
|
59 |
+
# top_p=top_p,
|
60 |
+
#):
|
61 |
+
# token = message.choices[0].delta.content
|
62 |
|
63 |
+
# response += token
|
64 |
+
# yield response
|
65 |
|
66 |
|
67 |
"""
|