Skip to main content

Files and skills

These functions call a provider's Files API or Skills API. The API field of each options struct takes a provider.FilesAPI (or provider.SkillsAPI) or a provider that exposes a Files() (or Skills()) method.

Functions​

FunctionDescription
ai.UploadFile(ctx, UploadFileOptions) (*types.UploadFileResult, error)Uploads a file and returns a provider reference.
ai.GetFileMetadata(ctx, GetFileMetadataOptions) (*provider.FileMetadataResult, error)Returns metadata for an uploaded file.
ai.DownloadFile(ctx, DownloadFileOptions) (*provider.DownloadFileResult, error)Downloads an uploaded file.
ai.DeleteFile(ctx, DeleteFileOptions) (*provider.DeleteFileResult, error)Deletes an uploaded file.
ai.UploadSkill(ctx, UploadSkillOptions) (*types.UploadSkillResult, error)Uploads a skill.

UploadFileOptions​

FieldTypeDescription
APIinterface{}
Datainterface{}
MediaTypestring
Filenamestring
ProviderOptionsmap[string]interface{}
Headersmap[string]stringHeaders are additional HTTP headers to send with the upload request. Only applicable for HTTP-based providers.

GetFileMetadataOptions​

FieldTypeDescription
APIinterface{}API is a provider.FilesAPI instance or a provider.FilesProvider (a Provider exposing a Files() method).
Filetypes.ProviderReferenceFile is the provider reference of the file, as returned by UploadFile.
Headersmap[string]string
ProviderOptionsmap[string]interface{}

DownloadFileOptions​

FieldTypeDescription
APIinterface{}API is a provider.FilesAPI instance or a provider.FilesProvider (a Provider exposing a Files() method).
Filetypes.ProviderReferenceFile is the provider reference of the file, as returned by UploadFile.
Headersmap[string]string
ProviderOptionsmap[string]interface{}

DeleteFileOptions​

FieldTypeDescription
APIinterface{}API is a provider.FilesAPI instance or a provider.FilesProvider (a Provider exposing a Files() method).
Filetypes.ProviderReferenceFile is the provider reference of the file, as returned by UploadFile.
Headersmap[string]string
ProviderOptionsmap[string]interface{}

UploadSkillOptions​

FieldTypeDescription
APIinterface{}
Files[]UploadSkillFile
DisplayTitlestring
ProviderOptionsmap[string]interface{}

Errors​

VariableReturned when
ai.ErrFilesAPINotSupportedThe provider does not expose a Files() method.
ai.ErrFileMetadataNotSupportedThe provider's Files API cannot return metadata.
ai.ErrFileDownloadNotSupportedThe provider's Files API cannot download files.
ai.ErrFileDeleteNotSupportedThe provider's Files API cannot delete files.
ai.ErrSkillsAPINotSupportedThe provider does not expose a Skills() method.