Spaces:
Runtime error
Runtime error
Huy
commited on
Commit
·
7c8ec43
1
Parent(s):
3322f3c
Fix download file name, Add Delete Collection Button
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ async def initialize_model() -> Dict:
|
|
| 32 |
os.makedirs("./pretrained/colpaligemma-3b-mix-448-base", exist_ok=True)
|
| 33 |
files_to_download = ["adapter_model.safetensors",
|
| 34 |
"config.json",
|
| 35 |
-
"model-
|
| 36 |
"model-00002-of-00002.safetensors",
|
| 37 |
"preprocessor_config.json",
|
| 38 |
"tokenizer.json",
|
|
@@ -177,6 +177,16 @@ async def search_with_llm(query: str,
|
|
| 177 |
|
| 178 |
return response.response, [Image.open(BytesIO(base64.b64decode(image))) for image in response.source_images]
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
def build_gui():
|
| 182 |
with gr.Blocks() as demo:
|
|
@@ -199,10 +209,15 @@ def build_gui():
|
|
| 199 |
message_box = gr.Textbox(value="File not yet uploaded",
|
| 200 |
show_label=False,
|
| 201 |
interactive=False)
|
| 202 |
-
|
|
|
|
|
|
|
| 203 |
|
| 204 |
# Define the actions for conversion
|
| 205 |
convert_button.click(index, inputs=[files, target_collection], outputs=[message_box, target_collection, choices])
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
with gr.Column():
|
| 208 |
gr.Markdown("## 3️. Enter your question")
|
|
|
|
| 32 |
os.makedirs("./pretrained/colpaligemma-3b-mix-448-base", exist_ok=True)
|
| 33 |
files_to_download = ["adapter_model.safetensors",
|
| 34 |
"config.json",
|
| 35 |
+
"model-00001-of-00002.safetensors",
|
| 36 |
"model-00002-of-00002.safetensors",
|
| 37 |
"preprocessor_config.json",
|
| 38 |
"tokenizer.json",
|
|
|
|
| 177 |
|
| 178 |
return response.response, [Image.open(BytesIO(base64.b64decode(image))) for image in response.source_images]
|
| 179 |
|
| 180 |
+
async def delete_collection(target_collection):
|
| 181 |
+
if await model_dict["vector_store_client"].collection_exists(collection_name=target_collection):
|
| 182 |
+
await model_dict["vector_store_client"].delete_collection(collection_name=target_collection, timeout=100)
|
| 183 |
+
choices = await get_collection_names(model_dict["vector_store_client"])
|
| 184 |
+
return (f"Deleted collection {target_collection}", gr.Dropdown(choices=choices), choices)
|
| 185 |
+
else:
|
| 186 |
+
choices = await get_collection_names(model_dict["vector_store_client"])
|
| 187 |
+
return (f"Collection {target_collection} is not found.", gr.Dropdown(choices=choices), choices)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
|
| 191 |
def build_gui():
|
| 192 |
with gr.Blocks() as demo:
|
|
|
|
| 209 |
message_box = gr.Textbox(value="File not yet uploaded",
|
| 210 |
show_label=False,
|
| 211 |
interactive=False)
|
| 212 |
+
with gr.Row(equal_height=True):
|
| 213 |
+
delete_button = gr.Button("🗑️ Delete collection")
|
| 214 |
+
convert_button = gr.Button("🔄 Convert and upload")
|
| 215 |
|
| 216 |
# Define the actions for conversion
|
| 217 |
convert_button.click(index, inputs=[files, target_collection], outputs=[message_box, target_collection, choices])
|
| 218 |
+
|
| 219 |
+
# Define the actions for delete collection
|
| 220 |
+
delete_button.click(delete_collection, inputs=[target_collection], outputs=[message_box, target_collection, choices])
|
| 221 |
|
| 222 |
with gr.Column():
|
| 223 |
gr.Markdown("## 3️. Enter your question")
|