Commit
·
b60bfb0
1
Parent(s):
7a651fd
Update app.py
Browse files
app.py
CHANGED
@@ -41,6 +41,34 @@ class CustomInterface(gr.Interface):
|
|
41 |
flag_btns = [submit_btn]
|
42 |
return submit_btn, clear_btn, stop_btn, flag_btns, input_component_column
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Define the device
|
46 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -176,9 +204,8 @@ iface = CustomInterface(
|
|
176 |
fn=mistral_bot.predict,
|
177 |
title=title,
|
178 |
description=description,
|
179 |
-
|
180 |
-
|
181 |
-
] + additional_inputs,
|
182 |
outputs=[gr.Textbox(label="Réponse", type="text", lines=5)],
|
183 |
theme="carlosrosash/bellay_test"
|
184 |
)
|
|
|
41 |
flag_btns = [submit_btn]
|
42 |
return submit_btn, clear_btn, stop_btn, flag_btns, input_component_column
|
43 |
|
44 |
+
# CustomInterface class definition
|
45 |
+
class CustomInterface(gr.Interface):
|
46 |
+
def render_input_column(self):
|
47 |
+
submit_btn, clear_btn, stop_btn, flag_btns = None, None, None, None
|
48 |
+
|
49 |
+
with Column(variant="panel"):
|
50 |
+
input_component_column = Column()
|
51 |
+
with input_component_column:
|
52 |
+
for component in self.input_components:
|
53 |
+
component.render()
|
54 |
+
with Row():
|
55 |
+
if self.interface_type in [InterfaceTypes.STANDARD, InterfaceTypes.INPUT_ONLY]:
|
56 |
+
clear_btn = ClearButton(value = "XXXXXX")
|
57 |
+
if not self.live:
|
58 |
+
submit_btn = Button("Ciaoooooooo", variant="primary") # Custom label
|
59 |
+
if inspect.isgeneratorfunction(self.fn) or inspect.isasyncgenfunction(self.fn):
|
60 |
+
stop_btn = Button("Stop", variant="stop", visible=False)
|
61 |
+
elif self.interface_type == InterfaceTypes.UNIFIED:
|
62 |
+
clear_btn = ClearButton(value = "XXXXXX")
|
63 |
+
submit_btn = Button("Ciaoooooooo", variant="primary") # Custom label
|
64 |
+
if (inspect.isgeneratorfunction(self.fn) or inspect.isasyncgenfunction(self.fn)) and not self.live:
|
65 |
+
stop_btn = Button("Stop", variant="stop")
|
66 |
+
if self.allow_flagging == "manual":
|
67 |
+
flag_btns = self.render_flag_btns()
|
68 |
+
elif self.allow_flagging == "auto":
|
69 |
+
flag_btns = [submit_btn]
|
70 |
+
return submit_btn, clear_btn, stop_btn, flag_btns, input_component_column
|
71 |
+
|
72 |
|
73 |
# Define the device
|
74 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
204 |
fn=mistral_bot.predict,
|
205 |
title=title,
|
206 |
description=description,
|
207 |
+
examples=examples,
|
208 |
+
inputs=[gr.Textbox(label="Votre question ou votre instruction.", type="text", lines=5)] + additional_inputs,
|
|
|
209 |
outputs=[gr.Textbox(label="Réponse", type="text", lines=5)],
|
210 |
theme="carlosrosash/bellay_test"
|
211 |
)
|