carlosrosash
commited on
Commit
•
8f9cd66
1
Parent(s):
206b513
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,40 @@ import json
|
|
7 |
import os
|
8 |
import shutil
|
9 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Define the device
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -138,7 +172,7 @@ additional_inputs=[
|
|
138 |
),
|
139 |
]
|
140 |
|
141 |
-
iface =
|
142 |
fn=mistral_bot.predict,
|
143 |
title=title,
|
144 |
description=description,
|
@@ -148,12 +182,7 @@ iface = gr.Interface(
|
|
148 |
] + additional_inputs,
|
149 |
outputs=[
|
150 |
gr.Textbox(label="Output will happear here", type="text", lines=5)],
|
151 |
-
clear_buttom = 'Clear click here',
|
152 |
-
submit_button = 'Clear click here',
|
153 |
theme="carlosrosash/bellay_test",
|
154 |
-
css= """
|
155 |
-
p {align : center}
|
156 |
-
"""
|
157 |
)
|
158 |
|
159 |
# Launch the Gradio interface for the Mistral model
|
|
|
7 |
import os
|
8 |
import shutil
|
9 |
import requests
|
10 |
+
import gradio as gr
|
11 |
+
from gradio.components import Button, ClearButton
|
12 |
+
from gradio.layouts import Column, Row
|
13 |
+
from gradio.data_classes import InterfaceTypes
|
14 |
+
import inspect
|
15 |
+
|
16 |
+
# CustomInterface class definition
|
17 |
+
class CustomInterface(gr.Interface):
|
18 |
+
def render_input_column(self):
|
19 |
+
submit_btn, clear_btn, stop_btn, flag_btns = None, None, None, None
|
20 |
+
|
21 |
+
with Column(variant="panel"):
|
22 |
+
input_component_column = Column()
|
23 |
+
with input_component_column:
|
24 |
+
for component in self.input_components:
|
25 |
+
component.render()
|
26 |
+
with Row():
|
27 |
+
if self.interface_type in [InterfaceTypes.STANDARD, InterfaceTypes.INPUT_ONLY]:
|
28 |
+
clear_btn = ClearButton(value = "XXXXXX")
|
29 |
+
if not self.live:
|
30 |
+
submit_btn = Button("Ciaoooooooo", variant="primary") # Custom label
|
31 |
+
if inspect.isgeneratorfunction(self.fn) or inspect.isasyncgenfunction(self.fn):
|
32 |
+
stop_btn = Button("Stop", variant="stop", visible=False)
|
33 |
+
elif self.interface_type == InterfaceTypes.UNIFIED:
|
34 |
+
clear_btn = ClearButton(value = "XXXXXX")
|
35 |
+
submit_btn = Button("Ciaoooooooo", variant="primary") # Custom label
|
36 |
+
if (inspect.isgeneratorfunction(self.fn) or inspect.isasyncgenfunction(self.fn)) and not self.live:
|
37 |
+
stop_btn = Button("Stop", variant="stop")
|
38 |
+
if self.allow_flagging == "manual":
|
39 |
+
flag_btns = self.render_flag_btns()
|
40 |
+
elif self.allow_flagging == "auto":
|
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"
|
|
|
172 |
),
|
173 |
]
|
174 |
|
175 |
+
iface = CustomInterface(
|
176 |
fn=mistral_bot.predict,
|
177 |
title=title,
|
178 |
description=description,
|
|
|
182 |
] + additional_inputs,
|
183 |
outputs=[
|
184 |
gr.Textbox(label="Output will happear here", type="text", lines=5)],
|
|
|
|
|
185 |
theme="carlosrosash/bellay_test",
|
|
|
|
|
|
|
186 |
)
|
187 |
|
188 |
# Launch the Gradio interface for the Mistral model
|