Spaces:
Sleeping
Sleeping
Commit
•
9819c30
1
Parent(s):
d193765
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
4 |
|
5 |
-
#client = InferenceClient("openai-community/gpt2")
|
6 |
-
gr.load("models/openai-community/gpt2")
|
7 |
|
8 |
def respond(
|
9 |
message,
|
10 |
-
history: list[tuple[str, str]],
|
11 |
system_message,
|
12 |
max_tokens,
|
13 |
temperature,
|
14 |
top_p,
|
15 |
):
|
16 |
messages = [{"role": "system", "content": system_message}]
|
17 |
-
|
18 |
for val in history:
|
19 |
if val[0]:
|
20 |
messages.append({"role": "user", "content": val[0]})
|
@@ -22,13 +22,13 @@ def respond(
|
|
22 |
messages.append({"role": "assistant", "content": val[1]})
|
23 |
|
24 |
messages.append({"role": "user", "content": message})
|
25 |
-
|
26 |
response = ""
|
27 |
|
28 |
for message in client.chat_completion(
|
29 |
messages,
|
30 |
max_tokens=max_tokens,
|
31 |
-
stream=True,
|
32 |
temperature=temperature,
|
33 |
top_p=top_p,
|
34 |
):
|
@@ -40,7 +40,7 @@ def respond(
|
|
40 |
"""
|
41 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
42 |
"""
|
43 |
-
demo = gr.
|
44 |
respond,
|
45 |
additional_inputs=[
|
46 |
gr.Textbox(value="You are Valkira Gearbyte, a hot android.", label="System message"),
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from huggingface_hub import InferenceClient
|
4 |
+
|
5 |
+
client = InferenceClient("models/openai-community/gpt2")
|
6 |
|
|
|
|
|
7 |
|
8 |
def respond(
|
9 |
message,
|
10 |
+
#history: list[tuple[str, str]],
|
11 |
system_message,
|
12 |
max_tokens,
|
13 |
temperature,
|
14 |
top_p,
|
15 |
):
|
16 |
messages = [{"role": "system", "content": system_message}]
|
17 |
+
"""
|
18 |
for val in history:
|
19 |
if val[0]:
|
20 |
messages.append({"role": "user", "content": val[0]})
|
|
|
22 |
messages.append({"role": "assistant", "content": val[1]})
|
23 |
|
24 |
messages.append({"role": "user", "content": message})
|
25 |
+
"""
|
26 |
response = ""
|
27 |
|
28 |
for message in client.chat_completion(
|
29 |
messages,
|
30 |
max_tokens=max_tokens,
|
31 |
+
#stream=True,
|
32 |
temperature=temperature,
|
33 |
top_p=top_p,
|
34 |
):
|
|
|
40 |
"""
|
41 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
42 |
"""
|
43 |
+
demo = gr.ChatInterface(
|
44 |
respond,
|
45 |
additional_inputs=[
|
46 |
gr.Textbox(value="You are Valkira Gearbyte, a hot android.", label="System message"),
|