Skip to content

Conversation

@jnnnthnn
Copy link
Contributor

@jnnnthnn jnnnthnn commented Oct 9, 2023

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/query and /indexes/{index_id}/records/query) and confirm their behavior is unchanged.

Copy link
Contributor Author

jnnnthnn commented Oct 9, 2023

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"))
Copy link
Contributor Author

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()
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 will raise if it fails. We can catch and rethrow a custom error to improve DX.

return {"Say": "Transformer deleted!"}


@router.post("/embed/string",
Copy link
Contributor Author

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(
Copy link
Contributor Author

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)!

@jnnnthnn jnnnthnn marked this pull request as ready for review October 9, 2023 20:01
@jnnnthnn jnnnthnn requested a review from shabani1 October 9, 2023 20:01
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.

2 participants