Skip to content

[WIP/AI-assisted] fix: embedding parameter naming consistency#2335

Draft
lxcxjxhx wants to merge 4 commits into
abetlen:mainfrom
lxcxjxhx:fix/embedding-parameter-consistency
Draft

[WIP/AI-assisted] fix: embedding parameter naming consistency#2335
lxcxjxhx wants to merge 4 commits into
abetlen:mainfrom
lxcxjxhx:fix/embedding-parameter-consistency

Conversation

@lxcxjxhx

@lxcxjxhx lxcxjxhx commented Jul 9, 2026

Copy link
Copy Markdown

Fix inconsistent embedding vs embeddings parameter naming in __getstate__ and error message.

Problem

The __init__ method accepts embeddings (plural), but two places still reference the old singular embedding:

  1. __getstate__ (line 2176) serializes with key embedding, but __setstate__ passes it back to __init__ which expects embeddings. This breaks pickle round-tripping:
# __getstate__ returns:
{"embedding": self.context_params.embeddings, ...}
# __setstate__ calls:
self.__init__(**state)  # TypeError: unexpected keyword argument 'embedding'
  1. The error message in embed() (line 1101) tells users embedding=True, but the actual parameter is embeddings=True.

Fix

  • Changed embedding= to embeddings= in __getstate__ return dict
  • Changed error message from embedding=True to embeddings=True

Note: The __init__ method already handles the deprecated embedding kwarg (lines 203-211) with a DeprecationWarning, so old pickled state dicts will still load correctly through that path.

Testing

  • Verified __getstate__ now produces {"embeddings": ...} key
  • Verified the existing deprecation handler in __init__ provides backward compatibility for old pickled states
  • Confirmed error message now matches actual parameter name

lxcxjxhx added 4 commits July 9, 2026 12:18
- Update __init__ parameter from 'embedding' to 'embeddings'
- Fix error message to reference 'embeddings=True'
- Update __getstate__ to use 'embeddings' key
- Add backward compatibility handling in __setstate__

The parameter naming was inconsistent between Python API and C++ bindings,
causing confusion and potential serialization/deserialization issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant