Spaces:
Running
Running
Update gradio_helper.py
Browse files- gradio_helper.py +13 -29
gradio_helper.py
CHANGED
@@ -14,13 +14,16 @@ chinese_examples = [
|
|
14 |
]
|
15 |
|
16 |
english_examples = [
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
]
|
25 |
|
26 |
japanese_examples = [
|
@@ -36,28 +39,19 @@ japanese_examples = [
|
|
36 |
|
37 |
def get_uuid():
|
38 |
"""
|
39 |
-
|
40 |
"""
|
41 |
return str(uuid4())
|
42 |
|
43 |
-
|
44 |
def handle_user_message(message, history):
|
45 |
"""
|
46 |
-
|
47 |
-
|
48 |
-
Params:
|
49 |
-
message: current message
|
50 |
-
history: conversation history
|
51 |
-
Returns:
|
52 |
-
None
|
53 |
"""
|
54 |
# Append the user's message to the conversation history
|
55 |
return "", history + [[message, ""]]
|
56 |
|
57 |
-
|
58 |
def make_demo(
|
59 |
run_fn: Callable,
|
60 |
-
stop_fn: Callable,
|
61 |
title: str = "OpenVINO Chatbot",
|
62 |
language: Literal["English", "Chinese", "Japanese"] = "English"
|
63 |
):
|
@@ -87,7 +81,6 @@ def make_demo(
|
|
87 |
)
|
88 |
with gr.Column():
|
89 |
submit = gr.Button("Submit")
|
90 |
-
stop = gr.Button("Stop")
|
91 |
clear = gr.Button("Clear")
|
92 |
|
93 |
# Advanced options for the chat
|
@@ -160,16 +153,7 @@ def make_demo(
|
|
160 |
queue=True,
|
161 |
)
|
162 |
|
163 |
-
# Stop button functionality
|
164 |
-
stop.click(
|
165 |
-
fn=stop_fn,
|
166 |
-
inputs=None,
|
167 |
-
outputs=None,
|
168 |
-
cancels=[submit_event], # Cancels the submission event
|
169 |
-
queue=False,
|
170 |
-
)
|
171 |
-
|
172 |
# Clear chat button functionality
|
173 |
clear.click(lambda: None, None, chatbot, queue=False)
|
174 |
|
175 |
-
return demo
|
|
|
14 |
]
|
15 |
|
16 |
english_examples = [
|
17 |
+
"What are the key findings of the latest climate summit, and how do they impact global policies?",
|
18 |
+
"Who are some of the most recent Nobel Prize winners, and what breakthroughs did they contribute to their fields?",
|
19 |
+
"What are the recent developments in the electric vehicle industry, and how are governments incentivizing their adoption?",
|
20 |
+
"Which tech companies recently announced breakthroughs in AI, and how could these innovations shape future industries?",
|
21 |
+
"What are the most recent discoveries in the search for habitable exoplanets, and how close are we to confirming one?",
|
22 |
+
"How are inflation and recent economic policies affecting global financial markets?",
|
23 |
+
"What are the latest advancements in cancer research, and how close are we to new treatments?",
|
24 |
+
"What steps are major companies taking to address recent cybersecurity threats and breaches?",
|
25 |
+
"How are recent regulatory changes in cryptocurrency markets affecting investors and innovation?",
|
26 |
+
"What are the latest scientific findings related to deep-sea exploration, and what have researchers uncovered about ocean ecosystems?"
|
27 |
]
|
28 |
|
29 |
japanese_examples = [
|
|
|
39 |
|
40 |
def get_uuid():
|
41 |
"""
|
42 |
+
Universal unique identifier for thread
|
43 |
"""
|
44 |
return str(uuid4())
|
45 |
|
|
|
46 |
def handle_user_message(message, history):
|
47 |
"""
|
48 |
+
Callback function for updating user messages in interface on submit button click
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
"""
|
50 |
# Append the user's message to the conversation history
|
51 |
return "", history + [[message, ""]]
|
52 |
|
|
|
53 |
def make_demo(
|
54 |
run_fn: Callable,
|
|
|
55 |
title: str = "OpenVINO Chatbot",
|
56 |
language: Literal["English", "Chinese", "Japanese"] = "English"
|
57 |
):
|
|
|
81 |
)
|
82 |
with gr.Column():
|
83 |
submit = gr.Button("Submit")
|
|
|
84 |
clear = gr.Button("Clear")
|
85 |
|
86 |
# Advanced options for the chat
|
|
|
153 |
queue=True,
|
154 |
)
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
# Clear chat button functionality
|
157 |
clear.click(lambda: None, None, chatbot, queue=False)
|
158 |
|
159 |
+
return demo
|