Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ from datasets import load_dataset
|
|
31 |
#dataset = load_dataset("csv", data_files="./data.csv")
|
32 |
|
33 |
|
34 |
-
DB_FILE = "./
|
35 |
|
36 |
TOKEN = os.environ.get('HF_KEY')
|
37 |
|
@@ -157,12 +157,52 @@ def load_data2():
|
|
157 |
reviews2, total_reviews2 = get_latest_reviews2(db)
|
158 |
db.close()
|
159 |
return reviews2, total_reviews2
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
css="footer {visibility: hidden}"
|
162 |
# Applying style to highlight the maximum value in each row
|
163 |
#styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
|
164 |
with gr.Blocks(css=css) as demo:
|
165 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
with gr.Column():
|
167 |
data = gr.Dataframe() #styler)
|
168 |
count = gr.Number(label="Rates!")
|
|
|
31 |
#dataset = load_dataset("csv", data_files="./data.csv")
|
32 |
|
33 |
|
34 |
+
DB_FILE = "./reviewsosa.db"
|
35 |
|
36 |
TOKEN = os.environ.get('HF_KEY')
|
37 |
|
|
|
157 |
reviews2, total_reviews2 = get_latest_reviews2(db)
|
158 |
db.close()
|
159 |
return reviews2, total_reviews2
|
160 |
+
def add_text(history, text):
|
161 |
+
history = history + [(text, None)]
|
162 |
+
return history, gr.Textbox(value="", interactive=False)
|
163 |
+
|
164 |
+
|
165 |
+
def add_file(history, file):
|
166 |
+
history = history + [((file.name,), None)]
|
167 |
+
return history
|
168 |
+
|
169 |
+
|
170 |
+
def bot(history):
|
171 |
+
response = "**That's cool!**"
|
172 |
+
history[-1][1] = ""
|
173 |
+
for character in response:
|
174 |
+
history[-1][1] += character
|
175 |
+
time.sleep(0.05)
|
176 |
+
yield history
|
177 |
css="footer {visibility: hidden}"
|
178 |
# Applying style to highlight the maximum value in each row
|
179 |
#styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
|
180 |
with gr.Blocks(css=css) as demo:
|
181 |
with gr.Row():
|
182 |
+
with gr.Column():
|
183 |
+
chatbot = gr.Chatbot(
|
184 |
+
[],
|
185 |
+
elem_id="chatbot",
|
186 |
+
bubble_full_width=False,
|
187 |
+
avatar_images=(None, (os.path.join(os.path.dirname(__file__), "avatar.png"))),
|
188 |
+
)
|
189 |
+
|
190 |
+
with gr.Row():
|
191 |
+
txt = gr.Textbox(
|
192 |
+
scale=4,
|
193 |
+
show_label=False,
|
194 |
+
placeholder="Enter text and press enter, or upload an image",
|
195 |
+
container=False,
|
196 |
+
)
|
197 |
+
btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
|
198 |
+
|
199 |
+
txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
|
200 |
+
bot, chatbot, chatbot, api_name="bot_response"
|
201 |
+
)
|
202 |
+
txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
|
203 |
+
file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(
|
204 |
+
bot, chatbot, chatbot
|
205 |
+
)
|
206 |
with gr.Column():
|
207 |
data = gr.Dataframe() #styler)
|
208 |
count = gr.Number(label="Rates!")
|