models method

  1. @override
Future<List<AIModel>> models()
override

Get available models from the provider

Returns a list of available models or throws an LLMError

Implementation

@override
Future<List<AIModel>> models() async {
  if (config.baseUrl.isEmpty) {
    throw const InvalidRequestError('Missing Ollama base URL');
  }

  try {
    final responseData = await client.getJson(modelsEndpoint);
    return _parseResponse(responseData);
  } on DioException catch (e) {
    throw DioErrorHandler.handleDioError(e, 'Ollama');
  } catch (e) {
    throw GenericError('Unexpected error: $e');
  }
}