Spaces:
Sleeping
Sleeping
Commit
·
e212319
1
Parent(s):
aacc5bf
fixed app
Browse files
app.py
CHANGED
@@ -21,16 +21,12 @@ env = Environment(loader=FileSystemLoader(proj_dir / 'templates'))
|
|
21 |
template_html = env.get_template('template_html.j2')
|
22 |
|
23 |
|
24 |
-
def add_text(
|
25 |
history = [] if history is None else history
|
26 |
history = history + [(text, None)]
|
27 |
return history, gr.Textbox(value="", interactive=False)
|
28 |
|
29 |
|
30 |
-
def turn_on_activity():
|
31 |
-
return gr.Textbox(interactive=True), gr.Textbox(interactive=True), gr.Textbox(interactive=True)
|
32 |
-
|
33 |
-
|
34 |
def bot(history):
|
35 |
user_query = history[-1][0]
|
36 |
|
@@ -52,43 +48,36 @@ def bot(history):
|
|
52 |
yield history, prompt_html
|
53 |
|
54 |
|
55 |
-
with
|
56 |
chatbot = gr.Chatbot(
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
with gr.Row():
|
67 |
txt = gr.Textbox(
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
txt_btn = gr.Button(value="Submit text", scale=1)
|
74 |
|
75 |
prompt_html = gr.HTML()
|
76 |
-
|
77 |
-
|
78 |
-
add_text, [txt, chatbot], [txt, chatbot], queue=False
|
79 |
-
).then(
|
80 |
-
bot, [chatbot], [chatbot, prompt_html]
|
81 |
-
)
|
82 |
|
83 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
84 |
|
85 |
-
txt_msg = txt.submit(
|
86 |
-
|
87 |
-
).then(
|
88 |
-
bot, [chatbot], [chatbot, prompt_html]
|
89 |
-
)
|
90 |
|
91 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
92 |
|
93 |
demo.queue()
|
94 |
-
demo.launch(debug=True)
|
|
|
21 |
template_html = env.get_template('template_html.j2')
|
22 |
|
23 |
|
24 |
+
def add_text(history, text):
|
25 |
history = [] if history is None else history
|
26 |
history = history + [(text, None)]
|
27 |
return history, gr.Textbox(value="", interactive=False)
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
30 |
def bot(history):
|
31 |
user_query = history[-1][0]
|
32 |
|
|
|
48 |
yield history, prompt_html
|
49 |
|
50 |
|
51 |
+
with gr.Blocks() as demo:
|
52 |
chatbot = gr.Chatbot(
|
53 |
+
[],
|
54 |
+
elem_id="chatbot",
|
55 |
+
avatar_images=('https://aui.atlassian.com/aui/8.8/docs/images/avatar-person.svg',
|
56 |
+
'https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg'),
|
57 |
+
bubble_full_width=False,
|
58 |
+
show_copy_button=True,
|
59 |
+
show_share_button=True,
|
60 |
+
)
|
61 |
|
62 |
with gr.Row():
|
63 |
txt = gr.Textbox(
|
64 |
+
scale=3,
|
65 |
+
show_label=False,
|
66 |
+
placeholder="Enter text and press enter",
|
67 |
+
container=False,
|
68 |
+
)
|
69 |
txt_btn = gr.Button(value="Submit text", scale=1)
|
70 |
|
71 |
prompt_html = gr.HTML()
|
72 |
+
txt_msg = txt_btn.click(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
73 |
+
bot, [chatbot], [chatbot, prompt_html])
|
|
|
|
|
|
|
|
|
74 |
|
75 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
76 |
|
77 |
+
txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
78 |
+
bot, [chatbot], [chatbot, prompt_html])
|
|
|
|
|
|
|
79 |
|
80 |
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
81 |
|
82 |
demo.queue()
|
83 |
+
demo.launch(debug=True)
|