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

Compatibility of DoctrineVectorStore with doctrine migration #48

Open
SebastienTouze opened this issue Oct 31, 2023 · 3 comments
Open

Comments

@SebastienTouze
Copy link
Contributor

Hi o/

As the VectorType type is added to Doctrine on DoctrineVectorStore constructor, it is not available in DoctrineMigration which is not aware of this type. So using bin/console make:migration or equivalent bin/console doctrine:migration:diff result in error: Unknown column type "vector" requested.

One option seems to move the type declaration to doctrine dbal config file, with consequence to make the VectorType always available to doctrine. This is mostly adding some config info on the readme and maybe remove the integration in DoctrineVectorStore class.

If this proposition is OK for you I can open a PR

@SebastienTouze
Copy link
Contributor Author

SebastienTouze commented Oct 31, 2023

Example of config that seems to work

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
        types:
            vector: LLPhant\Embeddings\VectorStores\Doctrine\VectorType
        mapping_types:
            enum: string
            vector: vector

But I get an error on length not being define though it is defined in default DoctrineEmbeddingEntityBase I extend.
Operation 'VECTORs must have a length.' is not supported by platform.

I am using LLPhant v0.2.12

@chr-hertel
Copy link
Collaborator

chr-hertel commented Oct 31, 2023

Currently using vector: array as mapping type currently, but also still having issues with migrations.
For me it is regenerating the same migrations all over again with this:

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE snippet ALTER embedding TYPE vector(1536)');
        $this->addSql('COMMENT ON COLUMN snippet.embedding IS NULL');
    }

@arnaudgoulpeau
Copy link

Hi !

I used this bundle (mainly to get access to DQL functions) : https://packagist.org/packages/partitech/doctrine-pgvector
If you follow their docs about configuring the new type, you shouldn't have problems.
It works great on with doctrine/dbal 3.8 and doctrine/orm 2.19

Hope this helps

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

No branches or pull requests

3 participants