Skip to content

Commit d8a1b10

Browse files
Add GitHub workflow to run tests
1 parent d6a2a55 commit d8a1b10

3 files changed

Lines changed: 67 additions & 18 deletions

File tree

README.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
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

1310
Chroma is an open-source vector database that allows you to store, search, and analyze high-dimensional data at scale.
1411
It is designed to be fast, scalable, and reliable. It makes it easy to build LLM (Large Language Model) applications and
1512
services 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

156153
By 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
158155
factory 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+
200198
To 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

207207
If 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

222222
The embedding function must be an instance of `EmbeddingFunctionInterface`. There are a few built-in embedding functions
223223
that 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+
244246
You 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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codewithkyrian/chromadb-php",
3-
"description": "A PHP client for the ChromaDB open source embedding database API",
3+
"description": "A PHP client for the Chroma Open Source Embedding Database",
44
"type": "library",
55
"require": {
66
"php": "^8.1",

src/.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ ubuntu-latest ]
12+
php: [ 8.1, 8.2, 8.3 ]
13+
dependency-version: [ prefer-lowest, prefer-stable ]
14+
15+
name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Cache dependencies
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.composer/cache/files
25+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php }}
31+
extensions: dom, mbstring, zip
32+
coverage: none
33+
34+
- name: Install Composer dependencies
35+
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
36+
37+
- name: Run tests
38+
run: composer test

0 commit comments

Comments
 (0)