-
-
Notifications
You must be signed in to change notification settings - Fork 141
[Store] Do not allow to store state in Indexer type #997
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: main
Are you sure you want to change the base?
Conversation
e11d79f to
e2cdac7
Compare
| return (new PhpCsFixer\Config()) | ||
| // @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7777 | ||
| ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) | ||
| ->setUnsupportedPhpVersionAllowed(true) |
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'm using PHP8.5. This allow me to run php-cs-fixer.
Obviously, we must not use PHP8.5 features. The CI will catch us if we do :)
| $platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client()); | ||
| $vectorizer = new Vectorizer($platform, $embeddings = 'text-embedding-3-small'); | ||
| $indexer = new Indexer(new InMemoryLoader($documents), $vectorizer, $store, logger: logger()); | ||
| $indexer->index($documents); |
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.
$documents, are already set in the Loader. No need to repeat it here.
645485a to
2bf1345
Compare
Life is always easier without storing state in a service
2bf1345 to
e56e022
Compare
|
Yes, i agree on the issue with the statefulness, but the slim configuration is quite nice and methods names like what do you think about a concept of an abstract
the indexer could even know a set of loaders with: interface LoaderInterface
{
public function supports(SourceInterface $source): bool;
public function createSource(string|string[] $source): SourceInterface;
public function load(SourceInterface $source, array $options = []): EmbeddableDocumentInterface[];
}we could have
the would that solve our concerns here? @lyrixx @OskarStark |
At first glance, it seems okay, but I fail to see how to implement that. It's too specific. We would implement Then, to me, Moreover, I'm not a fan of the Strategy Design Pattern. You have to inject a bunch of Loaders, and call I understand
So I think the first, small step, is to break this class in two:
|
Life is always easier without storing state in a service