Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,7 +67,7 @@ def upload_to_object_storage(user_name, text):
|
|
67 |
)
|
68 |
return filename
|
69 |
|
70 |
-
# === List
|
71 |
def list_object_store():
|
72 |
try:
|
73 |
objects = object_storage.list_objects(namespace, bucket_name)
|
@@ -75,9 +75,6 @@ def list_object_store():
|
|
75 |
except Exception as e:
|
76 |
return [f"Failed to list objects: {str(e)}"]
|
77 |
|
78 |
-
def filter_object_store(query):
|
79 |
-
return [name for name in list_object_store() if query.lower() in name.lower()]
|
80 |
-
|
81 |
# === View file contents ===
|
82 |
def view_transcription(file_name):
|
83 |
try:
|
@@ -184,11 +181,12 @@ with gr.Blocks() as app:
|
|
184 |
input_file.change(fn=transcribe_image, inputs=[input_file, user_dropdown], outputs=output_text)
|
185 |
|
186 |
gr.Markdown("### View Transcription")
|
187 |
-
|
188 |
-
filtered_dropdown = gr.Dropdown(label="Select transcription file")
|
189 |
view_output = gr.Textbox(label="File Content")
|
190 |
-
|
191 |
-
|
|
|
|
|
192 |
|
193 |
gr.Markdown("### Summarize or Recommend")
|
194 |
file_multiselect = gr.Dropdown(choices=list_object_store(), label="Select files to analyze", multiselect=True)
|
@@ -207,3 +205,4 @@ with gr.Blocks() as app:
|
|
207 |
# === Launch App ===
|
208 |
if __name__ == "__main__":
|
209 |
app.launch(share=True)
|
|
|
|
67 |
)
|
68 |
return filename
|
69 |
|
70 |
+
# === List object storage ===
|
71 |
def list_object_store():
|
72 |
try:
|
73 |
objects = object_storage.list_objects(namespace, bucket_name)
|
|
|
75 |
except Exception as e:
|
76 |
return [f"Failed to list objects: {str(e)}"]
|
77 |
|
|
|
|
|
|
|
78 |
# === View file contents ===
|
79 |
def view_transcription(file_name):
|
80 |
try:
|
|
|
181 |
input_file.change(fn=transcribe_image, inputs=[input_file, user_dropdown], outputs=output_text)
|
182 |
|
183 |
gr.Markdown("### View Transcription")
|
184 |
+
file_selector = gr.Dropdown(choices=list_object_store(), label="Select transcription file")
|
|
|
185 |
view_output = gr.Textbox(label="File Content")
|
186 |
+
file_selector.change(fn=view_transcription, inputs=file_selector, outputs=view_output)
|
187 |
+
|
188 |
+
gr.Markdown("### List Object Store Contents")
|
189 |
+
gr.Button("List Object Store").click(fn=lambda: "\n".join(list_object_store()), outputs=gr.Textbox(label="Object Store Contents"))
|
190 |
|
191 |
gr.Markdown("### Summarize or Recommend")
|
192 |
file_multiselect = gr.Dropdown(choices=list_object_store(), label="Select files to analyze", multiselect=True)
|
|
|
205 |
# === Launch App ===
|
206 |
if __name__ == "__main__":
|
207 |
app.launch(share=True)
|
208 |
+
|