Requirements
This guide assumes a basic understanding of Python and LangChain. Beginners to LangChain will still find the tutorial accessible.- Python (LangChain requires >= 3.8.1 and < 4.0) and the pip CLI
- A Meilisearch >= 1.6 project
- An OpenAI API key
Creating the application
Create a folder for your application with an emptysetup.py file.
Before writing any code, install the necessary dependencies:
setup.py file with some boilerplate code:
Importing documents and embeddings
Now that the project is ready, import some documents in Meilisearch. First, download this small movies dataset:movies-lite.json
Download movies-lite.json
userProvided source which requires to specify the size of the vectors in a dimensions field. The default model used by OpenAIEmbeddings() is text-embedding-ada-002, which has 1,536 dimensions.
Performing similarity search
Your database is now populated with the data from the movies dataset. Create a newsearch.py file to make a semantic search query: searching for documents using similarity search.
search.py. If everything is working correctly, you should see an output like this: