Spaces:
Sleeping
Sleeping
Pavithiran
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
-
from typing import List, Tuple
|
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
|
@@ -9,9 +8,9 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
9 |
|
10 |
|
11 |
def respond(
|
12 |
-
message
|
13 |
-
history:
|
14 |
-
system_message
|
15 |
max_tokens=1024,
|
16 |
temperature=0.7,
|
17 |
top_p=0.95,
|
@@ -36,13 +35,12 @@ def respond(
|
|
36 |
temperature=temperature,
|
37 |
top_p=top_p,
|
38 |
):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
except
|
44 |
-
|
45 |
-
yield "An error occurred while processing the request."
|
46 |
|
47 |
"""
|
48 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
@@ -65,4 +63,4 @@ demo = gr.ChatInterface(
|
|
65 |
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
-
demo.launch()
|
|
|
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
|
|
|
8 |
|
9 |
|
10 |
def respond(
|
11 |
+
message,
|
12 |
+
history: list[tuple[str, str]],
|
13 |
+
system_message,
|
14 |
max_tokens=1024,
|
15 |
temperature=0.7,
|
16 |
top_p=0.95,
|
|
|
35 |
temperature=temperature,
|
36 |
top_p=top_p,
|
37 |
):
|
38 |
+
token = message.choices[0].delta.content
|
39 |
+
|
40 |
+
response += token
|
41 |
+
yield response
|
42 |
+
except json.JSONDecodeError as e:
|
43 |
+
yield f"Error: {e}"
|
|
|
44 |
|
45 |
"""
|
46 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
63 |
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
+
demo.launch()
|