Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import spaces
|
|
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 |
-
pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
|
9 |
|
10 |
@spaces.GPU(duration=120)
|
11 |
def respond(
|
@@ -28,14 +28,15 @@ def respond(
|
|
28 |
|
29 |
response = ""
|
30 |
|
31 |
-
for message in pipe
|
32 |
messages,
|
33 |
-
|
34 |
-
|
35 |
temperature=temperature,
|
36 |
top_p=top_p,
|
|
|
37 |
):
|
38 |
-
token = message
|
39 |
|
40 |
response += token
|
41 |
yield response
|
@@ -59,6 +60,5 @@ demo = gr.ChatInterface(
|
|
59 |
],
|
60 |
)
|
61 |
|
62 |
-
|
63 |
if __name__ == "__main__":
|
64 |
demo.launch()
|
|
|
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 |
+
pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", framework="pt", trust_remote_code=True)
|
9 |
|
10 |
@spaces.GPU(duration=120)
|
11 |
def respond(
|
|
|
28 |
|
29 |
response = ""
|
30 |
|
31 |
+
for message in pipe(
|
32 |
messages,
|
33 |
+
max_length=max_tokens,
|
34 |
+
do_sample=True,
|
35 |
temperature=temperature,
|
36 |
top_p=top_p,
|
37 |
+
return_dict_in_generate=True,
|
38 |
):
|
39 |
+
token = message["generated_text"]
|
40 |
|
41 |
response += token
|
42 |
yield response
|
|
|
60 |
],
|
61 |
)
|
62 |
|
|
|
63 |
if __name__ == "__main__":
|
64 |
demo.launch()
|