├── .github
└── workflows
│ ├── integration-test.yml
│ └── release.yml
├── .gitignore
├── CODEOWNERS
├── LICENSE.md
├── README.md
├── pom.xml
└── src
├── main
├── java
│ └── tech
│ │ └── amikos
│ │ └── chromadb
│ │ ├── ChromaException.java
│ │ ├── Client.java
│ │ ├── Collection.java
│ │ ├── Constants.java
│ │ ├── EFException.java
│ │ ├── Embedding.java
│ │ └── embeddings
│ │ ├── DefaultEmbeddingFunction.java
│ │ ├── EmbeddingFunction.java
│ │ ├── WithParam.java
│ │ ├── cohere
│ │ ├── CohereEmbeddingFunction.java
│ │ ├── CreateEmbeddingRequest.java
│ │ └── CreateEmbeddingResponse.java
│ │ ├── hf
│ │ ├── CreateEmbeddingRequest.java
│ │ ├── CreateEmbeddingResponse.java
│ │ └── HuggingFaceEmbeddingFunction.java
│ │ ├── ollama
│ │ ├── CreateEmbeddingRequest.java
│ │ ├── CreateEmbeddingResponse.java
│ │ └── OllamaEmbeddingFunction.java
│ │ └── openai
│ │ ├── CreateEmbeddingRequest.java
│ │ ├── CreateEmbeddingResponse.java
│ │ └── OpenAIEmbeddingFunction.java
└── resources
│ └── openapi
│ ├── api.yaml
│ └── openai.yaml
└── test
└── java
└── tech
└── amikos
└── chromadb
├── TestAPI.java
├── Utils.java
└── embeddings
├── TestDefaultEmbeddings.java
├── cohere
└── TestCohereEmbeddings.java
├── hf
└── TestHuggingFaceEmbeddings.java
├── ollama
└── TestOllamaEmbeddings.java
└── openai
└── TestOpenAIEmbeddings.java
/.github/workflows/integration-test.yml:
--------------------------------------------------------------------------------
1 | name: Integration test
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | - "**"
8 |
9 | jobs:
10 | integration-test:
11 | strategy:
12 | matrix:
13 | chroma-version: [0.4.24, 0.5.0, 0.5.5, 0.5.15 ]
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v3
17 | - name: Set up JDK 8
18 | uses: actions/setup-java@v3
19 | with:
20 | java-version: '8'
21 | distribution: 'adopt'
22 | cache: maven
23 | - name: Test with Maven
24 | run: mvn --batch-mode clean test
25 | env:
26 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
27 | COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
28 | HF_API_KEY: ${{ secrets.HF_API_KEY }}
29 | CHROMA_VERSION: ${{ matrix.chroma-version }}
30 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: release
2 |
3 | on:
4 | release:
5 | types: [created]
6 | branches: [ "main" ]
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - name: Set up JDK 8
14 | uses: actions/setup-java@v3
15 | with:
16 | java-version: '8'
17 | distribution: 'adopt'
18 | cache: maven
19 | server-id: ossrh
20 | server-username: MAVEN_USERNAME
21 | server-password: MAVEN_PASSWORD
22 |
23 | - id: install-secret-key
24 | name: Install gpg secret key
25 | run: |
26 | # Install gpg secret key
27 | cat <(echo -e "${GPG_KEY}") | gpg --batch --import
28 | # Verify gpg secret key
29 | gpg --list-secret-keys --keyid-format LONG
30 | env:
31 | GPG_KEY: ${{ secrets.AMIKOS_OSS_GPG_SECRET_KEY }}
32 | - name: Version bump
33 | run: |
34 | mvn \
35 | --no-transfer-progress \
36 | --batch-mode \
37 | -Dgpg.skip=true \
38 | -DskipTests \
39 | versions:set \
40 | -DnewVersion=${{ github.ref_name }}
41 | - name: Publish package
42 | run: |
43 | mvn \
44 | --no-transfer-progress \
45 | --batch-mode \
46 | -Dgpg.passphrase=${GPG_PASSPHRASE} \
47 | -DskipTests \
48 | clean package deploy
49 | env:
50 | # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
52 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
53 | GPG_PASSPHRASE: ${{ secrets.AMIKOS_OSS_GPG_SECRET_KEY_PASSWORD }}
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/
8 | **.iml
9 |
10 | ### Eclipse ###
11 | .apt_generated
12 | .classpath
13 | .factorypath
14 | .project
15 | .settings
16 | .springBeans
17 | .sts4-cache
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | build/
26 | !**/src/main/**/build/
27 | !**/src/test/**/build/
28 |
29 | ### VS Code ###
30 | .vscode/
31 |
32 | ### Mac OS ###
33 | .DS_Store*.class
34 | *.log
35 | *.ctxt
36 | .mtj.tmp/
37 | *.jar
38 | *.war
39 | *.nar
40 | *.ear
41 | *.zip
42 | *.tar.gz
43 | *.rar
44 | hs_err_pid*
45 | replay_pid*
46 | cmake-build-*/
47 | .idea/**/mongoSettings.xml
48 | out/
49 | .idea_modules/
50 | atlassian-ide-plugin.xml
51 | .idea/replstate.xml
52 | .idea/sonarlint/
53 | com_crashlytics_export_strings.xml
54 | crashlytics.properties
55 | crashlytics-build.properties
56 | fabric.properties
57 | .idea/httpRequests
58 | .idea/caches/build_file_checksums.ser
59 | **.env
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @tazarov
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2023 Amikos Tech Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chroma Vector Database Java Client
2 |
3 | This is a very basic/naive implementation in Java of the Chroma Vector Database API.
4 |
5 | This client works with Chroma Versions `0.4.3+`
6 |
7 | ## Features
8 |
9 | ### Embeddings Support
10 |
11 | - ✅ Default Embedding Function (all-mini-lm model)
12 | - ✅ OpenAI Embedding Function
13 | - ✅ Cohere Embedding Function
14 | - ✅ HuggingFace Embedding Function (Inference API)
15 | - ✅ Ollama Embedding Function
16 | - ✅ Hugging Face Text Embedding Inference (HFEI) API
17 | - [ ] Sentence Transformers
18 | - [ ] PaLM API
19 | - [ ] Custom Embedding Function
20 | - [ ] Cloudflare Workers AI
21 |
22 | ### Feature Parity with ChromaDB API
23 |
24 | - [x] Reset
25 | - [x] Heartbeat
26 | - [x] List Collections
27 | - [x] Get Version
28 | - [x] Create Collection
29 | - [x] Delete Collection
30 | - [x] Collection Add
31 | - [x] Collection Get (partial without additional parameters)
32 | - [x] Collection Count
33 | - [x] Collection Query
34 | - [x] Collection Modify
35 | - [x] Collection Update
36 | - [x] Collection Upsert
37 | - [x] Collection Create Index
38 | - [x] Collection Delete - delete documents in collection
39 |
40 | ## TODO
41 |
42 | - [x] Push the package to Maven
43 | Central - https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven
44 | - ⚒️ Fluent API - make it easier for users to make use of the library
45 | - [ ] Support for PaLM API
46 | - [x] Support for Sentence Transformers with Hugging Face API
47 | - ⚒️ Authentication ⚒️
48 |
49 | ## Usage
50 |
51 | Add Maven dependency:
52 |
53 | ```xml
54 |
55 |
56 | io.github.amikos-tech
57 | chromadb-java-client
58 | 0.1.7
59 |
60 | ```
61 |
62 | Ensure you have a running instance of Chroma running. We recommend one of the two following options:
63 |
64 | - Official documentation - https://docs.trychroma.com/usage-guide#running-chroma-in-clientserver-mode
65 | - If you are a fan of Kubernetes, you can use the Helm chart - https://github.com/amikos-tech/chromadb-chart (Note: You
66 | will need `Docker`, `minikube` and `kubectl` installed)
67 |
68 | ### Default Embedding Function
69 |
70 | Since version `0.1.6` the library also offers a built-in default embedding function which does not rely on any external
71 | API to generate embeddings and works in the same way it works in core Chroma Python package.
72 |
73 | ```java
74 | package tech.amikos;
75 |
76 | import tech.amikos.chromadb.*;
77 | import tech.amikos.chromadb.Collection;
78 | import tech.amikos.chromadb.embeddings.DefaultEmbeddingFunction;
79 |
80 | import java.util.*;
81 |
82 | public class Main {
83 | public static void main(String[] args) {
84 | try {
85 | Client client = new Client(System.getenv("CHROMA_URL"));
86 | client.reset();
87 | EmbeddingFunction ef = new DefaultEmbeddingFunction();
88 | Collection collection = client.createCollection("test-collection", null, true, ef);
89 | List