codekingpro/portable-devtools
114k
1# Embedding Function Schemas
2
3This directory contains JSON schemas for all embedding functions in Chroma. The purpose of having this schema is to support cross language compatibility, and to validate that changes in one client library do not accidentally diverge from others.
4
5## Schema Structure
6
7Each schema follows the JSON Schema Draft-07 specification and includes:
8
9- `version`: The version of the schema
10- `title`: The title of the schema
11- `description`: A description of the schema
12- `properties`: The properties that can be configured for the embedding function
13- `required`: The properties that are required for the embedding function
14- `additionalProperties`: Whether additional properties are allowed (always set to `false` to ensure strict validation)
15
16## Usage
17
18The schemas can be used to validate the configuration of embedding functions using the `validate_config` function:
19
20```python
21from chromadb.utils.embedding_functions.schemas import validate_config
22
23# Validate a configuration
24config = {
25 "api_key_env_var": "CHROMA_OPENAI_API_KEY",
26 "model_name": "text-embedding-ada-002"
27}
28validate_config(config, "openai")
29```
30
31## Adding New Schemas
32
33To add a new schema:
34
351. Create a new JSON file in this directory with the name of the embedding function (e.g., `new_function.json`)
362. Define the schema following the JSON Schema Draft-07 specification
373. Update the embedding function to use the schema for validation
38
39## Schema Versioning
40
41Each schema includes a version number to support future changes to embedding function configurations. When making changes to a schema, increment the version number to ensure backward compatibility.
42 