Files
The files SDK allows you to manage files uploaded to the PromptIDE. Its main purposes is to grant file access when executing prompts created in the IDE locally.
API reference
xai_sdk.files.AsyncFiles
Contains API for interacting with files.
Source code in xai_sdk/files.py
xai_sdk.files.AsyncFiles.__init__(stub)
Initializes a new instance of the AsyncFiles
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stub |
FileStub
|
Stub used to communicate with the gRPC API. |
required |
xai_sdk.files.AsyncFiles.delete(file_name)
async
Deletes a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str
|
Name of the file to delete. |
required |
xai_sdk.files.AsyncFiles.download(file_name)
async
Reads a file store in the IDE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str
|
Name of the file. This is case-sensitive. |
required |
Returns:
Type | Description |
---|---|
bytes
|
The file contents in bytes. |
Source code in xai_sdk/files.py
xai_sdk.files.AsyncFiles.list()
async
Returns the metadata of all files stored in the IDE.
Returns:
Type | Description |
---|---|
list[FileMetadata]
|
Metadata of all uploaded files. |
Source code in xai_sdk/files.py
xai_sdk.files.AsyncFiles.upload(file_name, content, mime_type='', overwrite=True)
async
Creates a new file in the IDE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str
|
Name of the file in the IDE. |
required |
content |
bytes
|
File contents. |
required |
mime_type |
str
|
Mime type of the file. |
''
|
overwrite |
bool
|
True if the file shall be overwritten when it's re-uploaded. |
True
|
Source code in xai_sdk/files.py
xai_sdk.files.AsyncFiles.upload_file(local_file_name, remote_file_name)
async
Uploads a locally stored file to the IDE's storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_file_name |
str
|
Local filename. |
required |
remote_file_name |
str
|
Name of the file in the IDE. |
required |