getVector method
Read this record's stored vector on the named field.
Returns the full KoolbaseVector including the float values plus timestamps. Throws KoolbaseNotFoundException if either the field is not declared, or no vector has been set for this record on this field. Throws KoolbasePermissionException if the caller cannot read this record per the collection's read rule.
Online-only.
final v = await Koolbase.db.doc(articleId).getVector('embedding');
print('${v.vector.length}-dim vector, updated ${v.updatedAt}');
Implementation
Future<KoolbaseVector> getVector(String field) async {
final res = await _client
.post(
Uri.parse('$baseUrl/v1/sdk/db/get-vector'),
headers: await _headers(),
body: jsonEncode({
'record_id': recordId,
'field': field,
}),
)
.timeout(const Duration(seconds: 10));
if (res.statusCode != 200) {
throw await koolbaseDataErrorNotifying(res,
onSessionExpired: _onSessionExpired,
fallbackMessage: 'Get vector failed');
}
return KoolbaseVector.fromJson(
jsonDecode(res.body) as Map<String, dynamic>);
}