-
Notifications
You must be signed in to change notification settings - Fork 0
Generalize custom transformer code by loading from DB #5
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: @jnnnthnn/Prototype_using_exec_to_run_transformer_code
Are you sure you want to change the base?
Conversation
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
| name="query_embeddings", | ||
| description="Query for similar documents") | ||
| async def query_embeddings(query_string: str, k: int = 5, session: AsyncSession = Depends(get_session)) -> dict: | ||
| transformer_result = await session.execute(select(Transformer).where(Transformer.transformer_id == "text.embeddings.minilm")) |
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.
Note I'm hard-coding text.embeddings.minilm for now. That is changed upstack.
| description="Query for similar documents") | ||
| async def query_embeddings(query_string: str, k: int = 5, session: AsyncSession = Depends(get_session)) -> dict: | ||
| transformer_result = await session.execute(select(Transformer).where(Transformer.transformer_id == "text.embeddings.minilm")) | ||
| transformer = transformer_result.scalar_one() |
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.
This will raise if it fails. We can catch and rethrow a custom error to improve DX.
| return {"Say": "Transformer deleted!"} | ||
|
|
||
|
|
||
| @router.post("/embed/string", |
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.
I don't think it's worth maintaining this?
| regex=r"^[a-zA-Z][a-zA-Z0-9_.]+$" | ||
| ) | ||
| path: Optional[str] = Field( | ||
| code: str = Field( |
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.
You will need to reset your DB state as a result of this (at least by deleting the bindings and transformers models)!

What changed
Generalizes custom transformer code by loading from DB.
Why
We want users to be able to provide arbitrary code to be run as transformers. To that end, we need the ability to run said arbitrary code. This PR scaffolds a minimal viable way to load said code.
Test plan
Call each of the affected endpoints (
/embeddings/queryand/indexes/{index_id}/records/query) and confirm their behavior is unchanged.