View Source Qdrant Elixir Client
this-library-is-under-active-development-and-is-subject-to-change-please-use-the-latest-version-from-github
⚠️ This library is under active development and is subject to change. Please use the latest version from GitHub ⚠️
An Elixir client for the Qdrant vector similarity search engine. This library provides a convenient way to interact with the Qdrant API, offering functionality to create collections, insert vectors, search, delete data, and more.
installation
Installation
It's available in Hex, the package can be installed
by adding qdrant
to your list of dependencies in mix.exs
:
def deps do
[
{:qdrant, "~> 0.8.0"}
# Or use the latest version from GitHub | Recommended during development phase
{:qdrant, git: "git@github.com:marinac-dev/qdrant.git"},
]
end
config
Config
config :qdrant,
port: 6333,
interface: "rest", # gRPC not yet supported
database_url: System.get_env("QDRANT_DATABASE_URL"),
# If you are using cloud version of Qdrant, add API key
api_key: System.get_env("QDRANT_API_KEY")
usage
Usage
The Qdrant Elixir Client provides a simple interface for interacting with the Qdrant API. For example, you can create a new collection, insert vectors, search, and delete data using the provided functions.
collection_name = "my-collection"
# Create a new collection
# The vectors are 1536-dimensional (because of OpenAi embedding) and use the Cosine distance metric
Qdrant.create_collection(collection_name, %{vectors: %{size: 1536, distance: "Cosine"}})
# Create embeddings for some text
vector1 = OpenAi.embed_text("Hello world")
vector2 = OpenAi.embed_text("This is OpenAI")
# Now we can insert the vectors with batch
Qdrant.upsert_points(collection_name, %{batch: %{ids: [1,2], vectors: [vector1, vector2]}})
# Or one by one
Qdrant.upsert_point(collection_name, %{points: [%{id: 1, vector: vector1}, %{id: 2, vector: vector2}]})
# Search for similar vectors
vector3 = OpenAi.embed_text("Hello world!")
Qdrant.search(collection_name, %{vector: vector3, limit: 3})
contributing
Contributing
- Fork the repository
- Create a branch for your changes
- Make your changes
- Run
mix format
to format your code
change-log
Change Log
Generate change log with git-chglog -o CHANGELOG.md
license
License
This project is licensed under the MIT License - see the LICENSE file for details