C API reference · Kjarni 0.2.8
indexer
kjarni_index_info_free
void kjarni_index_info_free(struct KjarniIndexInfo info);
Free memory allocated for index info strings
Safety
infomust be a value returned bykjarni_index_info, passed here exactly once. Its buffers are invalid to read afterwards.
kjarni_indexer_config_default
struct KjarniIndexerConfig kjarni_indexer_config_default(void);
Get default indexer configuration
kjarni_indexer_new
enum KjarniErrorCode kjarni_indexer_new(const struct KjarniIndexerConfig *config, struct KjarniIndexer **out);
Create a new Indexer
Safety
outmust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.
kjarni_indexer_free
void kjarni_indexer_free(struct KjarniIndexer *indexer);
Free an Indexer handle
Safety
indexermust be null, or a handle returned bykjarni_indexer_newthat has not already been passed to this function. It is invalid to use afterwards.
kjarni_indexer_create
enum KjarniErrorCode kjarni_indexer_create(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, int32_t force, struct KjarniIndexStats *out);
Create a new index from files/directories
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.inputsmust point tothe accompanying countreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.outmust be a valid, writable pointer to aKjarniIndexStats. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_indexer_create_with_callback
enum KjarniErrorCode kjarni_indexer_create_with_callback(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, int32_t force, KjarniProgressCallbackFn progress_callback, void *user_data, const struct KjarniCancelToken *cancel_token, struct KjarniIndexStats *out);
Create a new index with progress callback and cancellation support.
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.inputsmust point tothe accompanying countreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.user_datamust be a valid, writable pointer to ac_void. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.cancel_tokenmust be null, or a live handle returned bykjarni_cancel_token_newthat has not been freed.outmust be a valid, writable pointer to aKjarniIndexStats. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_indexer_add
enum KjarniErrorCode kjarni_indexer_add(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, uintptr_t *documents_added);
Add documents to an existing index
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.inputsmust point tothe accompanying countreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.documents_addedmust be a valid, writable pointer to ausize. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_indexer_add_with_callback
enum KjarniErrorCode kjarni_indexer_add_with_callback(struct KjarniIndexer *indexer, const char *index_path, const char *const *inputs, uintptr_t num_inputs, KjarniProgressCallbackFn progress_callback, void *user_data, const struct KjarniCancelToken *cancel_token, uintptr_t *documents_added);
Add documents to an existing index with progress callback and cancellation support.
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.index_pathmust be null, or a valid pointer to a nul-terminated C string.inputsmust point tothe accompanying countreadable pointers, each null or a valid nul-terminated C string that stays valid for the call.user_datamust be a valid, writable pointer to ac_void. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.cancel_tokenmust be null, or a live handle returned bykjarni_cancel_token_newthat has not been freed.documents_addedmust be a valid, writable pointer to ausize. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_index_info
enum KjarniErrorCode kjarni_index_info(const char *index_path, struct KjarniIndexInfo *out);
Get information about an existing index
Safety
index_pathmust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to aKjarniIndexInfo. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_index_delete
enum KjarniErrorCode kjarni_index_delete(const char *index_path);
Delete an index.
Safety
index_pathmust be null, or a valid pointer to a nul-terminated C string.
kjarni_indexer_model_name
uintptr_t kjarni_indexer_model_name(const struct KjarniIndexer *indexer, char *buf, uintptr_t buf_len);
Get the embedding model name used by the indexer.
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.bufmust be null, or point to at leastbuf_lenwritable bytes. When it is null the required size is returned and nothing is written.
kjarni_indexer_dimension
uintptr_t kjarni_indexer_dimension(const struct KjarniIndexer *indexer);
Get the embedding dimension used by the indexer.
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.
kjarni_indexer_chunk_size
uintptr_t kjarni_indexer_chunk_size(const struct KjarniIndexer *indexer);
Get the chunk size configured for the indexer.
Safety
indexermust be null, or a live handle returned bykjarni_indexer_newthat has not been freed.
Kjarni runs the same engine on every platform: