Update to gradio 4 and allow upload multiple files at once in UI (#1271)
This commit is contained in:
		
							parent
							
								
									adaa00ccc8
								
							
						
					
					
						commit
						224812f7f6
					
				|  | @ -1,10 +1,10 @@ | ||||||
| # 🔒 PrivateGPT 📑 | # 🔒 PrivateGPT 📑 | ||||||
| 
 | 
 | ||||||
|  | [](https://github.com/imartinez/privateGPT/actions/workflows/tests.yml?query=branch%3Amain) | ||||||
|  | [](https://docs.privategpt.dev/) | ||||||
| 
 | 
 | ||||||
|  | [](https://discord.gg/bK6mRVpErU) | ||||||
|  | [](https://twitter.com/PrivateGPT_AI) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| > Install & usage docs: https://docs.privategpt.dev/ | > Install & usage docs: https://docs.privategpt.dev/ | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -3,7 +3,7 @@ import itertools | ||||||
| import logging | import logging | ||||||
| from collections.abc import Iterable | from collections.abc import Iterable | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from typing import Any, TextIO | from typing import Any | ||||||
| 
 | 
 | ||||||
| import gradio as gr  # type: ignore | import gradio as gr  # type: ignore | ||||||
| from fastapi import FastAPI | from fastapi import FastAPI | ||||||
|  | @ -155,9 +155,12 @@ class PrivateGptUi: | ||||||
|             files.add(file_name) |             files.add(file_name) | ||||||
|         return [[row] for row in files] |         return [[row] for row in files] | ||||||
| 
 | 
 | ||||||
|     def _upload_file(self, file: TextIO) -> None: |     def _upload_file(self, files: list[str]) -> None: | ||||||
|         path = Path(file.name) |         logger.debug("Loading count=%s files", len(files)) | ||||||
|         self._ingest_service.ingest(file_name=path.name, file_data=path) |         for file in files: | ||||||
|  |             logger.info("Loading file=%s", file) | ||||||
|  |             path = Path(file) | ||||||
|  |             self._ingest_service.ingest(file_name=path.name, file_data=path) | ||||||
| 
 | 
 | ||||||
|     def _build_ui_blocks(self) -> gr.Blocks: |     def _build_ui_blocks(self) -> gr.Blocks: | ||||||
|         logger.debug("Creating the UI blocks") |         logger.debug("Creating the UI blocks") | ||||||
|  | @ -186,9 +189,9 @@ class PrivateGptUi: | ||||||
|                         value="Query Docs", |                         value="Query Docs", | ||||||
|                     ) |                     ) | ||||||
|                     upload_button = gr.components.UploadButton( |                     upload_button = gr.components.UploadButton( | ||||||
|                         "Upload a File", |                         "Upload File(s)", | ||||||
|                         type="file", |                         type="filepath", | ||||||
|                         file_count="single", |                         file_count="multiple", | ||||||
|                         size="sm", |                         size="sm", | ||||||
|                     ) |                     ) | ||||||
|                     ingested_dataset = gr.List( |                     ingested_dataset = gr.List( | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ types-pyyaml = "^6.0.12.12" | ||||||
| [tool.poetry.group.ui] | [tool.poetry.group.ui] | ||||||
| optional = true | optional = true | ||||||
| [tool.poetry.group.ui.dependencies] | [tool.poetry.group.ui.dependencies] | ||||||
| gradio = "^3.45.2" | gradio = "^4.4.1" | ||||||
| 
 | 
 | ||||||
| [tool.poetry.group.local] | [tool.poetry.group.local] | ||||||
| optional = true | optional = true | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue