chroma-core / chroma

the AI-native open-source embedding database
https://www.trychroma.com/
Apache License 2.0
15.45k stars 1.3k forks source link

[Feature Request]: custome embeddiings #2747

Closed ucas010 closed 2 months ago

ucas010 commented 2 months ago

Describe the problem

I get the embeddings just from a URL from cloud , such as

import requests
import json

url = "http://12.25.1.11:8021/query2emb"

payload = json.dumps({
   "inputs": "我擦"
})
headers = {
   'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

then how i set the Embedding function ?

Describe the proposed solution

want to support the URL requests

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

ucas010 commented 2 months ago

i got the bug refer to the https://docs.trychroma.com/guides/embeddings

from chromadb import Documents, EmbeddingFunction, Embeddings

class MyEmbeddingFunction(EmbeddingFunction):
    def __call__(self, input: Documents) -> Embeddings:
        # embed the documents somehow
        return embeddings

could u pls help me ?

jeffchuber commented 2 months ago

@ucas010 the simple way to do this is to generate the embeddings yourself outside of chroma and pass them to add and query

collection = client.get_or_create_collection(name='example')
collection.add(embeddings=[...], ...)
collection.query(query_embeddings=[..], ...)