22
33** A PHP library for interacting with ChromaDB vector database seamlessly.**
44
5- [ ![ Build Status] ( https://travis-ci.org/ChromaDatabase/ChromaDB-PHP.svg?branch=master )] ( https://travis-ci.org/ChromaDatabase/ChromaDB-PHP )
6- [ ![ Coverage Status] ( https://coveralls.io/repos/github/ChromaDatabase/ChromaDB-PHP/badge.svg?branch=master )] ( https://coveralls.io/github/ChromaDatabase/ChromaDB-PHP?branch=master )
7- [ ![ Latest Stable Version] ( https://poser.pugx.org/chromadb/chromadb-php/v/stable )] ( https://packagist.org/packages/chromadb/chromadb-php )
8- [ ![ Total Downloads] ( https://poser.pugx.org/chromadb/chromadb-php/downloads )] ( https://packagist.org/packages/chromadb/chromadb-php )
9- [ ![ License] ( https://poser.pugx.org/chromadb/chromadb-php/license )] ( https://packagist.org/packages/chromadb/chromadb-php )
5+ [ ![ MIT Licensed] ( https://img.shields.io/badge/license-mit-blue.svg )] ( https://github.com/CodeWithKyrian/chromadb-php/blob/main/LICENSE )
6+ [ ![ GitHub Tests Action Status] ( https://img.shields.io/github/workflow/status/CodeWithKyrian/chromadb-php/Tests?label=tests )] ( https://github.com/CodeWithKyrian/chromadb-php/actions/workflows/test.yml )
107
118## Description
129
1310Chroma is an open-source vector database that allows you to store, search, and analyze high-dimensional data at scale.
1411It is designed to be fast, scalable, and reliable. It makes it easy to build LLM (Large Language Model) applications and
1512services that require high-dimensional vector search.
1613
17- Chroma PHP provides a simple and intuitive interface for interacting with ChromaDB from PHP. It enables you to:
14+ ChromaDB PHP provides a simple and intuitive interface for interacting with Chroma from PHP. It enables you to:
1815
1916- Create, read, update, and delete documents.
2017- Execute queries and aggregations.
@@ -154,7 +151,7 @@ $chromaDB = ChromaDB::client();
154151```
155152
156153By default, ChromaDB will try to connect to ` http://localhost:8000 ` using the default database name ` default_database `
157- and default tenant name ` default_tenant ` . You can however change these values by constructing the client using the
154+ and default tenant name ` default_tenant ` . You can however change these values by constructing the client using the
158155factory method:
159156
160157``` php
@@ -174,7 +171,7 @@ If the tenant or database doesn't exist, the package will automatically create t
174171
175172``` php
176173
177- $collection = $chromaDB ->createCollection('test-collection');
174+ $collection = $chroma ->createCollection('test-collection');
178175
179176```
180177
@@ -197,11 +194,14 @@ $metadatas = [
197194
198195$collection->add($ids, $embeddings, $metadatas);
199196```
197+
200198To insert documents into a collection, you need to provide the following:
201199
202200- ` ids ` : An array of document ids. The ids must be unique and must be strings.
203- - ` embeddings ` : An array of document embeddings. The embeddings must be a 1D array of floats with a length of 10. You can
204- compute the embeddings using any embedding model of your choice (just make sure that's what you use when querying as well).
201+ - ` embeddings ` : An array of document embeddings. The embeddings must be a 1D array of floats with a length of 10. You
202+ can
203+ compute the embeddings using any embedding model of your choice (just make sure that's what you use when querying as
204+ well).
205205- ` metadatas ` : An array of document metadatas. The metadatas must be an array of key-value pairs.
206206
207207If you don't have the embeddings, you can pass in the documents and provide an embedding function that will be used to
@@ -216,31 +216,33 @@ use CodeWithKyrian\ChromaDB\EmbeddingFunction\EmbeddingFunctionInterface;
216216
217217$embeddingFunction = new OpenAIEmbeddingFunction('api-key', 'org-id', 'model-name');
218218
219- $collection = $chromaDB ->createCollection('test-collection', embeddingFunction: $embeddingFunction);
219+ $collection = $chroma ->createCollection('test-collection', embeddingFunction: $embeddingFunction);
220220```
221221
222222The embedding function must be an instance of ` EmbeddingFunctionInterface ` . There are a few built-in embedding functions
223223that you can use:
224224
225- - ` OpenAIEmbeddingFunction ` : This embedding function uses the OpenAI API to compute the embeddings. You can use it like this:
225+ - ` OpenAIEmbeddingFunction ` : This embedding function uses the OpenAI API to compute the embeddings. You can use it like
226+ this:
226227 ``` php
227- use CodeWithKyrian\ChromaDB \EmbeddingFunction\OpenAIEmbeddingFunction;
228+ use CodeWithKyrian\Chroma \EmbeddingFunction\OpenAIEmbeddingFunction;
228229
229230 $embeddingFunction = new OpenAIEmbeddingFunction('api-key', 'org-id', 'model-name');
230231
231232 $collection = $chromaDB->createCollection('test-collection', embeddingFunction: $embeddingFunction);
232233 ```
233234
234- - `HuggingFaceEmbeddingFunction`: This embedding function uses the HuggingFace API to compute the embeddings. You can use it like this:
235+ - `HuggingFaceEmbeddingFunction`: This embedding function uses the HuggingFace API to compute the embeddings. You can
236+ use it like this:
235237
236238 ```php
237- use CodeWithKyrian\ChromaDB \EmbeddingFunction\HuggingFaceEmbeddingFunction;
239+ use CodeWithKyrian\Chroma \EmbeddingFunction\HuggingFaceEmbeddingFunction;
238240
239241 $embeddingFunction = new HuggingFaceEmbeddingFunction('api-key', 'model-name');
240242
241243 $collection = $chromaDB->createCollection('test-collection', embeddingFunction: $embeddingFunction);
242244 ```
243-
245+
244246You can also create your own embedding function by implementing the `EmbeddingFunctionInterface` interface.
245247
246248```php
@@ -253,9 +255,18 @@ $embeddingFunction = new class implements EmbeddingFunctionInterface {
253255 }
254256};
255257
256- $collection = $chromaDB ->createCollection('test-collection', embeddingFunction: $embeddingFunction);
258+ $collection = $chroma ->createCollection('test-collection', embeddingFunction: $embeddingFunction);
257259```
258260
261+ ## Contributors
262+
263+ - [ Kyrian Obikwelu] ( https://github.com/CodeWithKyrian )
264+ - Other contributors are welcome.
265+
266+ ## License
267+
268+ This project is licensed under the MIT License. See
269+ the [ LICENSE] ( https://github.com/codewithkyrian/chromadb-php/blob/main/LICENSE ) file for more information.
259270
260271
261272
0 commit comments