-
Notifications
You must be signed in to change notification settings - Fork 3
fix: handle missing output_dimension in embedding computation #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -506,6 +506,11 @@ int dbmem_remote_compute_embedding (dbmem_remote_engine_t *engine, const char *t | |
| } | ||
| } | ||
|
|
||
| // Some providers do not return output_dimension; fallback to embedding array length. | ||
| if (n_embd == 0 && emb_count > 0) { | ||
| n_embd = (int)emb_count; | ||
| } | ||
|
|
||
| if (emb_start < 0 || emb_count == 0 || n_embd == 0) { | ||
| dbmem_context_set_error(engine->context, "Missing embedding data in API response"); | ||
| return -1; | ||
|
Comment on lines
514
to
516
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new fallback triggers whenever
n_embd == 0, which also happens ifoutput_dimensionis present but non-numeric/invalid (sinceatoi()returns 0). That changes behavior from “reject invalidoutput_dimension” to “silently ignore it”. Consider tracking whether theoutput_dimensionkey was actually present (e.g.,bool saw_output_dimension) and only falling back when it’s absent, and/or validating token type + parsing withstrtolto detect invalid values explicitly.