upsertVectors method
Implementation
Future<Either<String, UpsertResponse>> upsertVectors(
{required String collectionId,
required Map<String, String>? segments}) async {
const method = 'upsertVectors';
try {
debugPrint('$tag $method started');
var body = {'segments': segments};
final response = await post(
Uri.parse('$baseUrl/relevantMemory/$collectionId/upsert'),
headers: {
'Content-Type': 'application/json',
'apikey': apiKey,
},
body: json.encode(body),
);
debugPrint('$tag $method success');
final upsertResponse =
UpsertResponse.fromJson(json.decode(response.body));
if (upsertResponse.warning != null) {
return Left(upsertResponse.warning ?? "Something went wrong");
}
return Right(upsertResponse);
} catch (e) {
debugPrint('$tag $method exception: $e');
return Left('$e');
}
}