Module files
Sync client for files workflow.
upload_file_paths
def upload_file_paths(file_paths: List[Path],
api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME,
write_mode: WriteMode = WriteMode.KEEP,
blocking: bool = True,
timeout_s: int = 300,
show_progress: bool = True) -> None
Upload files to deepset Cloud.
Arguments:
file_paths
: List of file paths to upload.api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace to upload the files to. It uses the workspace from the .ENV file by default.write_mode
: The write mode determines how to handle uploading a file if it's already in the workspace. Your options are: keep the file with the same name, make the request fail if a file with the same name already exists, or overwrite the file. If you choose to overwrite, all files with the same name are overwritten.blocking
: Whether to wait for the files to be uploaded and listed in deepset Cloud.timeout_s
: Timeout in seconds for theblocking
parameter`.show_progress
: Shows the upload progress.
upload
def upload(paths: List[Path],
api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME,
write_mode: WriteMode = WriteMode.KEEP,
blocking: bool = True,
timeout_s: int = 300,
show_progress: bool = True,
recursive: bool = False) -> None
Upload a folder to deepset Cloud.
Arguments:
paths
: Path to the folder to upload. If the folder contains unsupported file types, they're skipped. deepset Cloud supports TXT and PDF files.api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace to upload the files to. It uses the workspace from the .ENV file by default.write_mode
: The write mode determines how to handle uploading a file if it's already in the workspace. Your options are: keep the file with the same name, make the request fail if a file with the same name already exists, or overwrite the file. If you choose to overwrite, all files with the same name are overwritten.blocking
: Whether to wait for the files to be uploaded and displayed in deepset Cloud.timeout_s
: Timeout in seconds for theblocking
parameter.show_progress
: Shows the upload progress.recursive
: Uploads files from subfolders as well.
upload_texts
def upload_texts(files: List[DeepsetCloudFile],
api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME,
write_mode: WriteMode = WriteMode.KEEP,
blocking: bool = True,
timeout_s: int = 300,
show_progress: bool = True) -> None
Upload texts to deepset Cloud.
Arguments:
files
: List of DeepsetCloudFiles to upload.api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace to upload the files to. It uses the workspace from the .ENV file by default.write_mode
: Specifies what to do when a file with the same name already exists in the workspace. Possible options are: KEEP - uploads the file with the same name and keeps both files in the workspace. OVERWRITE - overwrites the file that is in the workspace. FAIL - fails to upload the file with the same name.blocking
: Whether to wait for the files to be uploaded and listed in deepset Cloud.timeout_s
: Timeout in seconds for theblocking
parameter.show_progress
: Shows the upload progress.
get_upload_session
def get_upload_session(
session_id: UUID,
api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME) -> UploadSessionStatus
Get the status of an upload session.
Arguments:
session_id
: ID of the upload session to get the status for.api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace to upload the files to.
list_files
def list_files(api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME,
name: Optional[str] = None,
content: Optional[str] = None,
odata_filter: Optional[str] = None,
batch_size: int = 100,
timeout_s: int = 300) -> Generator[List[File], None, None]
List files in a deepset Cloud workspace.
Arguments:
api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace to list the files from. It uses the workspace from the .ENV file by default.name
: Name of the file to odata_filter for.content
: Content of the file to odata_filter for.odata_filter
: odata_filter to apply to the file list. For example,odata_filter="category eq 'news'" lists files with metadata
{"meta": {"category": "news"}}.batch_size
: Batch size to use for the file list.timeout_s
: Timeout in seconds for the API requests.
list_upload_sessions
def list_upload_sessions(
api_key: Optional[str] = None,
api_url: Optional[str] = None,
workspace_name: str = DEFAULT_WORKSPACE_NAME,
is_expired: Optional[bool] = False,
batch_size: int = 100,
timeout_s: int = 300
) -> Generator[List[UploadSessionDetail], None, None]
List the details of all upload sessions, including the closed ones.
Arguments:
api_key
: deepset Cloud API key to use for authentication.api_url
: API URL to use for authentication.workspace_name
: Name of the workspace whose sessions you want to list. It uses the workspace from the .ENV file by default.is_expired
: Lists expired sessions.batch_size
: Batch size to use for the session list.timeout_s
: Timeout in seconds for the API request.