embed method
Generate embeddings for valuesJson (a JSON array of strings).
optsJson — optional serialized EmbeddingCallOptions.
Returns the JSON-serialized EmbeddingResult, or throws AimuxException.
Implementation
String embed(String valuesJson, [String? optsJson]) {
_checkOpen();
return withAimuxCError((err) {
return withUtf8(valuesJson, (valuesPtr) {
final optsPtr = optsJson != null ? optsJson.toNativeUtf8() : nullptr;
try {
final resultPtr = _ffi.embed(_handle, valuesPtr, optsPtr, err);
return takeString(resultPtr, err);
} finally {
if (optsPtr != nullptr) calloc.free(optsPtr);
}
});
});
}