Skip to content

[Store] Add Meilisearch #105

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Guikingone
Copy link

@Guikingone Guikingone commented Jul 12, 2025

Q A
Bug fix? no
New feature? yes
Docs? yes
Issues Fix #93
License MIT

Hi 👋🏻

As explained in #93, this PR aim to add meilisearch as a vector store, the full integration is not finished (tests to be validated) but the main implementation is ready.

@Guikingone Guikingone changed the title feat(store): meilisearch store started [Store] Meilisearch store Jul 12, 2025
Copy link
Contributor

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Hey @Guikingone, thanks for jumping on that and providing the first commits :) 👍

In general it looks good already and i think going with the API directly is a good and lightweight idea 👍

I left a couple of comments and was wondering, if we can ease the usage of the example here. were you using the cloud or a docker container of meilisearch?

I think, if reasonable to you as well, it would be great to extend the docker compose setup of the example to bring in meilisearch there.

and please add docs and a test for the Store class

@chr-hertel chr-hertel added Status: Needs Work Store Issues & PRs about the AI Store component labels Jul 12, 2025
@OskarStark OskarStark changed the title [Store] Meilisearch store [Store] Add Meilisearch Jul 13, 2025
@Guikingone
Copy link
Author

Hi @chr-hertel 👋🏻

The PR is fixed, the CI fails due to a zip error (not on unit tests side), the store is improved and tested 🙂

@chr-hertel
Copy link
Contributor

Thanks for the update and especially the docker changes - now I can easily run it, but I get this error while executing the example:

php store/meilisearch-similarity-search.php
PHP Fatal error:  Uncaught Symfony\Component\HttpClient\Exception\InvalidArgumentException: Invalid URL: scheme is missing in "indexes". Did you forget to add "http(s)://"? in /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php:580
Stack trace:
#0 /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php(178): Symfony\Component\HttpClient\CurlHttpClient::resolveUrl()
#1 /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/CurlHttpClient.php(100): Symfony\Component\HttpClient\CurlHttpClient::prepareRequest()
#2 /home/christopher/Projects/SymfonyAI/repo/src/store/src/Bridge/Meilisearch/Store.php(72): Symfony\Component\HttpClient\CurlHttpClient->request()
#3 /home/christopher/Projects/SymfonyAI/repo/examples/store/meilisearch-similarity-search.php(64): Symfony\AI\Store\Bridge\Meilisearch\Store->initialize()
#4 {main}
  thrown in /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php on line 580

i'm just using the default values you provided with the .env file

@Guikingone
Copy link
Author

Ah yes, forgot to call request method during the index initialization, the clients wasn't fully configured and the error occurred when you've called initialize, it should be better now 🙂

@chr-hertel
Copy link
Contributor

Yes, that works better - now I'm getting this error:

Invalid value type at .hybrid.semanticRatio: expected a number, but found a string: "1.0"

which refers to this: https://github.com/symfony/ai/pull/105/files#diff-969e7ab9dcae7946fdb6f82fcc866bb86e4389e23e3d40b752e3976de997dd09R58

after fixing this, i get the next one:

Cannot find embedder with name default.

Looks like I'm doing something wrong while running the example or is it also failing for you?

@Guikingone
Copy link
Author

Ah yes, forgot about the initialization of an embedder in initialize, I added the dimensions as constructor argument (required as we don't know which model is used by the end user).

@chr-hertel
Copy link
Contributor

@Guikingone so the provided example runs locally for you and is functional?

@Guikingone
Copy link
Author

Guikingone commented Jul 13, 2025

Yes, works locally (I failed to see the indexes embeddings as my local indexes were already configured) 🙂

However, I can't run the script in examples, I need to create a new file 🤔

Thanks for the update and especially the docker changes - now I can easily run it, but I get this error while executing the example:

php store/meilisearch-similarity-search.php
PHP Fatal error:  Uncaught Symfony\Component\HttpClient\Exception\InvalidArgumentException: Invalid URL: scheme is missing in "indexes". Did you forget to add "http(s)://"? in /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php:580
Stack trace:
#0 /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php(178): Symfony\Component\HttpClient\CurlHttpClient::resolveUrl()
#1 /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/CurlHttpClient.php(100): Symfony\Component\HttpClient\CurlHttpClient::prepareRequest()
#2 /home/christopher/Projects/SymfonyAI/repo/src/store/src/Bridge/Meilisearch/Store.php(72): Symfony\Component\HttpClient\CurlHttpClient->request()
#3 /home/christopher/Projects/SymfonyAI/repo/examples/store/meilisearch-similarity-search.php(64): Symfony\AI\Store\Bridge\Meilisearch\Store->initialize()
#4 {main}
  thrown in /home/christopher/Projects/SymfonyAI/repo/examples/vendor/symfony/http-client/HttpClientTrait.php on line 580

i'm just using the default values you provided with the .env file

How are you running this file? Any error on the autoload? 🤔

@chr-hertel
Copy link
Contributor

like this:
image

And the underlying issue that OpenAI returns is

This model's maximum context length is 128000 tokens. However, your messages resulted in 281690 tokens (281645 in the messages, 45 in the functions). Please reduce the length of the messages or functions.

Due to the fact that the vectors are part of the payload. Might be rather a design flaw of the SimiliaritySearch feature than your implementation tho 🤔

Was just wondering if it's only me, or if the example works for you

@Guikingone
Copy link
Author

Strange, if I try to run the script from examples, here's my error:

Capture d’écran 2025-07-13 à 19 52 01

Regarding the issue with OpenAI, that seems strange, I'll take a look, maybe I missed something 🤔

@chr-hertel
Copy link
Contributor

Ah, I know that one, that should've been documented, sorry - see #112

The issue is that Composer is installing the dependencies from main currently and therefore your new class is not available. Meaning, after composer install you can run ../link to bring in your locally changed code

@chr-hertel
Copy link
Contributor

Oh, and that's blocked by #108 🙈 - a bit rough here still :D

#[CoversClass(Store::class)]
final class StoreTest extends TestCase
{
public function testStoreCannotInitializeOnInvalidResponse(): void
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove all void return types in tests please

Copy link
Contributor

@chr-hertel chr-hertel Jul 13, 2025

Choose a reason for hiding this comment

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

but why @OskarStark?

it looks like it's common in symfony/symfony but that also supports other versions of PHP and PHPUnit I guess

Copy link
Author

Choose a reason for hiding this comment

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

Yes, not to mention that PHPStan doesn't like when return types are not specified 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just, that it does not add any value in tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I get that there is no functional value, but same is true for the public keyword for test methods.

I get that in combination with supporting various versions and having merge conflicts for nothing but coding best practices is annoying for symfony/symfony - but we don't have that struggle here. so for me adding return type declarations is a best practice to opt-out for reasons, but i see no reason here.

i'd vote for keeping them in

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Work Store Issues & PRs about the AI Store component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Meilisearch, at least as a Vector Store
3 participants