embed method
Generate embeddings for the given input texts
input
- List of strings to generate embeddings for
Returns a list of embedding vectors or throws an LLMError
Implementation
@override
Future<List<List<double>>> embed(List<String> input) async {
if (config.baseUrl.isEmpty) {
throw const InvalidRequestError('Missing Ollama base URL');
}
try {
final requestBody = _buildRequestBody(input);
final responseData =
await client.postJson(embeddingEndpoint, requestBody);
return _parseResponse(responseData);
} on DioException catch (e) {
throw DioErrorHandler.handleDioError(e, 'Ollama');
} catch (e) {
throw GenericError('Unexpected error: $e');
}
}