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