Spaces:
Runtime error
Runtime error
update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
"""
|
7 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
8 |
-
|
9 |
|
10 |
def respond(
|
11 |
message,
|
@@ -15,6 +12,7 @@ def respond(
|
|
15 |
temperature,
|
16 |
top_p,
|
17 |
):
|
|
|
18 |
messages = [{"role": "system", "content": system_message}]
|
19 |
|
20 |
for val in history:
|
@@ -27,6 +25,7 @@ def respond(
|
|
27 |
|
28 |
response = ""
|
29 |
|
|
|
30 |
for message in client.chat_completion(
|
31 |
messages,
|
32 |
max_tokens=max_tokens,
|
@@ -35,14 +34,10 @@ def respond(
|
|
35 |
top_p=top_p,
|
36 |
):
|
37 |
token = message.choices[0].delta.content
|
38 |
-
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
-
|
43 |
-
"""
|
44 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
45 |
-
"""
|
46 |
demo = gr.ChatInterface(
|
47 |
respond,
|
48 |
additional_inputs=[
|
@@ -59,6 +54,5 @@ demo = gr.ChatInterface(
|
|
59 |
],
|
60 |
)
|
61 |
|
62 |
-
|
63 |
if __name__ == "__main__":
|
64 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
# Initialize the InferenceClient with the model
|
5 |
+
client = InferenceClient("LLM360/K2-Chat")
|
|
|
|
|
|
|
6 |
|
7 |
def respond(
|
8 |
message,
|
|
|
12 |
temperature,
|
13 |
top_p,
|
14 |
):
|
15 |
+
# Prepare the messages for the model
|
16 |
messages = [{"role": "system", "content": system_message}]
|
17 |
|
18 |
for val in history:
|
|
|
25 |
|
26 |
response = ""
|
27 |
|
28 |
+
# Generate the response from the model
|
29 |
for message in client.chat_completion(
|
30 |
messages,
|
31 |
max_tokens=max_tokens,
|
|
|
34 |
top_p=top_p,
|
35 |
):
|
36 |
token = message.choices[0].delta.content
|
|
|
37 |
response += token
|
38 |
yield response
|
39 |
|
40 |
+
# Create a Gradio ChatInterface
|
|
|
|
|
|
|
41 |
demo = gr.ChatInterface(
|
42 |
respond,
|
43 |
additional_inputs=[
|
|
|
54 |
],
|
55 |
)
|
56 |
|
|
|
57 |
if __name__ == "__main__":
|
58 |
demo.launch()
|