Skip to content
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

feat: add docs about potential python integration #208

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Askir
Copy link
Contributor

@Askir Askir commented Nov 8, 2024

WIP: My experiments on python tooling integrations.

Note a bunch of this is claude code and quite hacky still. Just iterating fast to see what's possible from the SQLAlchemy/Alembic side.

Comment on lines +42 to +50
def __get__(self, obj, objtype=None):
"""
When accessed on class (BlogPost.content_embeddings) -> return Embedding class
When accessed on instance (post.content_embeddings) -> return relationship data
"""
if obj is None: # Class access
return self._embedding_class
# Instance access - return relationship data through the relationship property
return getattr(obj, f"_{self.name}_relation")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a nasty hack.
I wanted to enable querying all Embeddings under the same key as you'd retrieve the subobjects if you already have a BlogPost.

This is not default sqlalchemy behaviour (because you'd usually have the embedding class defined separately). Alternatively I can just defined a property Embeddings on the parent model, that might end up working out better.

Or we disabled the relationship mapping by default then this attribute free to be used by the Embedding model I suppose?

Will think about it a bit more, happy about additional input.

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