Skip to content

Commit 6fa8df4

Browse files
committed
docs: update custom provider result metadata
Align the public C API reference with the current dbmem_embedding_result_t shape by documenting the truncated boolean flag instead of n_tokens_truncated. This avoids publishing stale custom-provider docs after the shared embedding result metadata was simplified across local, remote, and custom engines.
1 parent c6f4071 commit 6fa8df4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

API.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ typedef struct {
564564
**`dbmem_embedding_result_t` struct:**
565565
```c
566566
typedef struct {
567-
int n_tokens; // Number of tokens processed
568-
int n_tokens_truncated; // Tokens that were truncated (0 if none)
567+
int n_tokens; // Number of processed tokens (0 if unknown)
568+
bool truncated; // True when the input was truncated before embedding
569569
int n_embd; // Embedding dimension
570570
float *embedding; // Embedding vector (engine-owned, valid until next call or free)
571571
} dbmem_embedding_result_t;
@@ -574,6 +574,7 @@ typedef struct {
574574
**Notes:**
575575
- Works regardless of `DBMEM_OMIT_LOCAL_ENGINE` / `DBMEM_OMIT_REMOTE_ENGINE` compile flags
576576
- The `embedding` buffer in `dbmem_embedding_result_t` must remain valid until the next `compute` call or `free` — it is engine-owned, not copied by the caller
577+
- `n_tokens` is metadata about the processed input when the engine can provide it; `truncated` is a boolean flag, not a truncated-token count
577578
- Only one custom provider can be registered per connection at a time; registering again replaces the previous one
578579
- The provider struct is copied by value; the caller does not need to keep it alive after registration
579580

@@ -596,7 +597,7 @@ static int my_compute(void *engine, const char *text, int text_len, void *xdata,
596597
// ... fill vec with your embedding ...
597598
result->n_embd = e->dimension;
598599
result->n_tokens = text_len / 4;
599-
result->n_tokens_truncated = 0;
600+
result->truncated = false;
600601
result->embedding = vec;
601602
return 0;
602603
}

0 commit comments

Comments
 (0)