Spaces:
Build error
Build error
ffreemt
commited on
Commit
•
3294385
1
Parent(s):
874bd1c
ncc
Browse files
app.py
CHANGED
@@ -9,28 +9,25 @@ transformers
|
|
9 |
sentencepiece
|
10 |
torch
|
11 |
|
12 |
-
"""
|
13 |
-
# pylint: disable=line-too-long, missing-module-docstring, missing-function-docstring
|
14 |
-
# import torch
|
15 |
import gradio as gr
|
16 |
-
from examples_list import examples_list
|
17 |
-
from transformers import AutoModel, AutoTokenizer # AutoModelForCausalLM,
|
18 |
|
19 |
-
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
_ = """
|
27 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
28 |
-
"THUDM/chatglm2-6b-int4", trust_remote_code=True
|
29 |
-
)
|
30 |
-
chat_model = AutoModel.from_pretrained(
|
31 |
-
"THUDM/chatglm2-6b-int4", trust_remote_code=True # 3.92G
|
32 |
-
).float()
|
33 |
"""
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def stream_chat():
|
36 |
"""samples:
|
@@ -75,17 +72,16 @@ def update_chatbot():
|
|
75 |
message = yield
|
76 |
print(f"{message=}")
|
77 |
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
for response, _ in chat_model.stream_chat(
|
85 |
-
tokenizer, message, history, max_length=2048, top_p=0.7, temperature=0.95
|
86 |
-
):
|
87 |
-
yield response, _
|
88 |
|
|
|
89 |
with gr.Blocks(theme=gr.themes.Glass(text_size="sm", spacing_size="sm"),) as block:
|
90 |
chatbot = gr.Chatbot()
|
91 |
msg = gr.Textbox()
|
@@ -98,3 +94,6 @@ block(
|
|
98 |
# title="gradio-chatinterface-tryout",
|
99 |
# examples=examples_list,
|
100 |
).queue(max_size=2).launch()
|
|
|
|
|
|
|
|
9 |
sentencepiece
|
10 |
torch
|
11 |
|
|
|
|
|
|
|
12 |
import gradio as gr
|
|
|
|
|
13 |
|
14 |
+
def greet(name):
|
15 |
+
return "Hello " + name + "!"
|
16 |
|
17 |
+
with gr.Blocks() as demo:
|
18 |
+
name = gr.Textbox(label="Name")
|
19 |
+
output = gr.Textbox(label="Output Box")
|
20 |
+
greet_btn = gr.Button("Greet")
|
21 |
+
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
22 |
+
|
23 |
+
|
24 |
+
demo.launch()
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
"""
|
27 |
+
# pylint: disable=line-too-long, missing-module-docstring, missing-function-docstring
|
28 |
+
# import torch
|
29 |
+
import gradio as gr
|
30 |
+
|
31 |
|
32 |
def stream_chat():
|
33 |
"""samples:
|
|
|
72 |
message = yield
|
73 |
print(f"{message=}")
|
74 |
|
75 |
+
def greet(name):
|
76 |
+
return "Hello " + name + "!"
|
77 |
|
78 |
+
with gr.Blocks() as block:
|
79 |
+
name = gr.Textbox(label="Name")
|
80 |
+
output = gr.Textbox(label="Output Box")
|
81 |
+
greet_btn = gr.Button("Greet")
|
82 |
+
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
|
|
|
|
|
|
|
|
83 |
|
84 |
+
_ = """
|
85 |
with gr.Blocks(theme=gr.themes.Glass(text_size="sm", spacing_size="sm"),) as block:
|
86 |
chatbot = gr.Chatbot()
|
87 |
msg = gr.Textbox()
|
|
|
94 |
# title="gradio-chatinterface-tryout",
|
95 |
# examples=examples_list,
|
96 |
).queue(max_size=2).launch()
|
97 |
+
# """
|
98 |
+
|
99 |
+
block.queue(max_size=2).launch()
|