buildFileManagement method

Future<FileManagementCapability> buildFileManagement()

Builds a provider with FileManagementCapability

Returns a provider that implements FileManagementCapability for uploading, managing, and processing files.

Throws UnsupportedCapabilityError if the provider doesn't support file management.

Example:

final fileProvider = await ai()
    .openai()
    .apiKey(apiKey)
    .buildFileManagement();

// Direct usage without type casting
final file = await fileProvider.uploadFile('document.pdf');

Implementation

Future<FileManagementCapability> buildFileManagement() async {
  final provider = await build();
  if (provider is! FileManagementCapability) {
    throw UnsupportedCapabilityError(
      'Provider "$_providerId" does not support file management capabilities. '
      'Supported providers: OpenAI, Anthropic',
    );
  }
  return provider as FileManagementCapability;
}