chromadb 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chromadb.d.ts +7 -0
- package/dist/chromadb.legacy-esm.js +46 -0
- package/dist/chromadb.mjs +46 -0
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +46 -0
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +7 -0
- package/dist/cjs/cli.cjs +3 -0
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cli.mjs +3 -0
- package/dist/cli.mjs.map +1 -1
- package/package.json +6 -6
- package/src/api/sdk.gen.ts +18 -1
- package/src/api/types.gen.ts +46 -0
- package/src/chroma-client.ts +32 -0
- package/src/cli.ts +4 -0
package/dist/cjs/chromadb.d.cts
CHANGED
|
@@ -1492,6 +1492,13 @@ declare class ChromaClient {
|
|
|
1492
1492
|
* @throws Error if the collection does not exist
|
|
1493
1493
|
*/
|
|
1494
1494
|
getCollectionByCrn(crn: string): Promise<Collection>;
|
|
1495
|
+
/**
|
|
1496
|
+
* Retrieves an existing collection by its ID.
|
|
1497
|
+
* @param id - The UUID of the collection to retrieve
|
|
1498
|
+
* @returns Promise resolving to the Collection instance
|
|
1499
|
+
* @throws Error if the collection does not exist
|
|
1500
|
+
*/
|
|
1501
|
+
getCollectionById(id: string): Promise<Collection>;
|
|
1495
1502
|
/**
|
|
1496
1503
|
* Retrieves multiple collections by name.
|
|
1497
1504
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|
package/dist/cjs/cli.cjs
CHANGED
package/dist/cjs/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts","../../src/bindings.ts"],"sourcesContent":["#!/usr/bin/env node\nimport semver from \"semver\";\nimport binding from \"./bindings\";\n\ninterface NpmPackageData {\n \"dist-tags\": {\n latest: string;\n [tag: string]: string;\n };\n}\n\nconst getLatestVersion = async (packageName: string): Promise<string> => {\n const response = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!response.ok) {\n throw new Error(`Failed to fetch package data: ${response.statusText}`);\n }\n const data: NpmPackageData = await response.json();\n return data[\"dist-tags\"].latest;\n};\n\nconst update = async (): Promise<void> => {\n try {\n const installedVersion = process.env.CHROMADB_VERSION || \"0.0.0\";\n const latestVersion = await getLatestVersion(\"chromadb\");\n\n if (semver.lt(installedVersion, latestVersion)) {\n console.log(`\\nA new chromadb version (${latestVersion}) is available!`);\n console.log(\"\\n\\x1b[4mUpdat with npm\\x1b[0m\");\n console.log(\"npm install chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with pnpm\\x1b[0m\");\n console.log(\"pnpm add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with yarn\\x1b[0m\");\n console.log(\"yarn add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with bun\\x1b[0m\");\n console.log(\"bun add chromadb@latest\\n\");\n } else {\n console.log(\n `\\nYour chromadb version (${latestVersion}) is up-to-date!\\n`,\n );\n }\n } catch (error) {\n console.error(\"Error checking versions:\", error);\n }\n};\n\nconst main = async () => {\n const args: string[] = process.argv.slice(2);\n if (args.length > 0 && args[0] === \"update\") {\n await update();\n return;\n }\n\n binding.cli([\"chroma\", ...args]);\n};\n\nmain().finally();\n","import { createRequire } from \"module\";\nimport os from \"os\";\n\nconst require = createRequire(import.meta.url);\nconst platform = os.platform();\nconst arch = os.arch();\n\nlet binding: any;\n\nif (platform === \"darwin\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-darwin-arm64\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-darwin-x64\");\n } else {\n throw new Error(`Unsupported architecture on macOS: ${arch}`);\n }\n} else if (platform === \"linux\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-linux-arm64-gnu\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-linux-x64-gnu\");\n } else {\n throw new Error(`Unsupported architecture on Linux: ${arch}`);\n }\n} else if (platform === \"win32\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-win32-arm64-msvc\");\n } else {\n throw new Error(\n `Unsupported Windows architecture: ${arch}. Only ARM64 is supported.`,\n );\n }\n} else {\n throw new Error(`Unsupported platform: ${platform}`);\n}\n\nexport default binding;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oBAAmB;;;ACDnB,oBAA8B;AAC9B,gBAAe;AADf;AAGA,IAAMA,eAAU,6BAAc,YAAY,GAAG;AAC7C,IAAM,WAAW,UAAAC,QAAG,SAAS;AAC7B,IAAM,OAAO,UAAAA,QAAG,KAAK;AAErB,IAAI;AAEJ,IAAI,aAAa,UAAU;AACzB,MAAI,SAAS,SAAS;AACpB,cAAUD,SAAQ,mCAAmC;AAAA,EACvD,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,iCAAiC;AAAA,EACrD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,sCAAsC;AAAA,EAC1D,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,oCAAoC;AAAA,EACxD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,uCAAuC;AAAA,EAC3D,OAAO;AACL,UAAM,IAAI;AAAA,MACR,qCAAqC,IAAI;AAAA,IAC3C;AAAA,EACF;AACF,OAAO;AACL,QAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AACrD;AAEA,IAAO,mBAAQ;;;AD1Bf,IAAM,mBAAmB,OAAO,gBAAyC;AACvE,QAAM,WAAW,MAAM,MAAM,8BAA8B,WAAW,EAAE;AACxE,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,iCAAiC,SAAS,UAAU,EAAE;AAAA,EACxE;AACA,QAAM,OAAuB,MAAM,SAAS,KAAK;AACjD,SAAO,KAAK,WAAW,EAAE;AAC3B;AAEA,IAAM,SAAS,YAA2B;AACxC,MAAI;AACF,UAAM,mBAAmB,QAAQ,IAAI,oBAAoB;AACzD,UAAM,gBAAgB,MAAM,iBAAiB,UAAU;AAEvD,QAAI,cAAAE,QAAO,GAAG,kBAAkB,aAAa,GAAG;AAC9C,cAAQ,IAAI;AAAA,0BAA6B,aAAa,iBAAiB;AACvE,cAAQ,IAAI,gCAAgC;AAC5C,cAAQ,IAAI,6BAA6B;AAEzC,cAAQ,IAAI,iCAAiC;AAC7C,cAAQ,IAAI,0BAA0B;AAEtC,cAAQ,IAAI,iCAAiC;AAC7C,cAAQ,IAAI,0BAA0B;AAEtC,cAAQ,IAAI,gCAAgC;AAC5C,cAAQ,IAAI,2BAA2B;AAAA,IACzC,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,yBAA4B,aAAa;AAAA;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,4BAA4B,KAAK;AAAA,EACjD;AACF;AAEA,IAAM,OAAO,YAAY;AACvB,QAAM,OAAiB,QAAQ,KAAK,MAAM,CAAC;AAC3C,MAAI,KAAK,SAAS,KAAK,KAAK,CAAC,MAAM,UAAU;AAC3C,UAAM,OAAO;AACb;AAAA,EACF;AAEA,mBAAQ,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;AACjC;AAEA,KAAK,EAAE,QAAQ;","names":["require","os","semver"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts","../../src/bindings.ts"],"sourcesContent":["#!/usr/bin/env node\nimport semver from \"semver\";\nimport binding from \"./bindings\";\n\ninterface NpmPackageData {\n \"dist-tags\": {\n latest: string;\n [tag: string]: string;\n };\n}\n\nconst getLatestVersion = async (packageName: string): Promise<string> => {\n const response = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!response.ok) {\n throw new Error(`Failed to fetch package data: ${response.statusText}`);\n }\n const data: NpmPackageData = await response.json();\n return data[\"dist-tags\"].latest;\n};\n\nconst update = async (): Promise<void> => {\n try {\n const installedVersion = process.env.CHROMADB_VERSION || \"0.0.0\";\n const latestVersion = await getLatestVersion(\"chromadb\");\n\n if (semver.lt(installedVersion, latestVersion)) {\n console.log(`\\nA new chromadb version (${latestVersion}) is available!`);\n console.log(\"\\n\\x1b[4mUpdat with npm\\x1b[0m\");\n console.log(\"npm install chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with pnpm\\x1b[0m\");\n console.log(\"pnpm add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with yarn\\x1b[0m\");\n console.log(\"yarn add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with bun\\x1b[0m\");\n console.log(\"bun add chromadb@latest\\n\");\n } else {\n console.log(\n `\\nYour chromadb version (${latestVersion}) is up-to-date!\\n`,\n );\n }\n } catch (error) {\n console.error(\"Error checking versions:\", error);\n }\n};\n\nconst main = async () => {\n const args: string[] = process.argv.slice(2);\n if (args.length > 0 && args[0] === \"update\") {\n await update();\n return;\n }\n\n process.on(\"SIGINT\", () => {\n process.exit(0);\n });\n\n binding.cli([\"chroma\", ...args]);\n};\n\nmain().finally();\n","import { createRequire } from \"module\";\nimport os from \"os\";\n\nconst require = createRequire(import.meta.url);\nconst platform = os.platform();\nconst arch = os.arch();\n\nlet binding: any;\n\nif (platform === \"darwin\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-darwin-arm64\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-darwin-x64\");\n } else {\n throw new Error(`Unsupported architecture on macOS: ${arch}`);\n }\n} else if (platform === \"linux\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-linux-arm64-gnu\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-linux-x64-gnu\");\n } else {\n throw new Error(`Unsupported architecture on Linux: ${arch}`);\n }\n} else if (platform === \"win32\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-win32-arm64-msvc\");\n } else {\n throw new Error(\n `Unsupported Windows architecture: ${arch}. Only ARM64 is supported.`,\n );\n }\n} else {\n throw new Error(`Unsupported platform: ${platform}`);\n}\n\nexport default binding;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oBAAmB;;;ACDnB,oBAA8B;AAC9B,gBAAe;AADf;AAGA,IAAMA,eAAU,6BAAc,YAAY,GAAG;AAC7C,IAAM,WAAW,UAAAC,QAAG,SAAS;AAC7B,IAAM,OAAO,UAAAA,QAAG,KAAK;AAErB,IAAI;AAEJ,IAAI,aAAa,UAAU;AACzB,MAAI,SAAS,SAAS;AACpB,cAAUD,SAAQ,mCAAmC;AAAA,EACvD,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,iCAAiC;AAAA,EACrD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,sCAAsC;AAAA,EAC1D,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,oCAAoC;AAAA,EACxD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,uCAAuC;AAAA,EAC3D,OAAO;AACL,UAAM,IAAI;AAAA,MACR,qCAAqC,IAAI;AAAA,IAC3C;AAAA,EACF;AACF,OAAO;AACL,QAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AACrD;AAEA,IAAO,mBAAQ;;;AD1Bf,IAAM,mBAAmB,OAAO,gBAAyC;AACvE,QAAM,WAAW,MAAM,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src/cli.ts","../src/bindings.ts"],"sourcesContent":["#!/usr/bin/env node\nimport semver from \"semver\";\nimport binding from \"./bindings\";\n\ninterface NpmPackageData {\n \"dist-tags\": {\n latest: string;\n [tag: string]: string;\n };\n}\n\nconst getLatestVersion = async (packageName: string): Promise<string> => {\n const response = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!response.ok) {\n throw new Error(`Failed to fetch package data: ${response.statusText}`);\n }\n const data: NpmPackageData = await response.json();\n return data[\"dist-tags\"].latest;\n};\n\nconst update = async (): Promise<void> => {\n try {\n const installedVersion = process.env.CHROMADB_VERSION || \"0.0.0\";\n const latestVersion = await getLatestVersion(\"chromadb\");\n\n if (semver.lt(installedVersion, latestVersion)) {\n console.log(`\\nA new chromadb version (${latestVersion}) is available!`);\n console.log(\"\\n\\x1b[4mUpdat with npm\\x1b[0m\");\n console.log(\"npm install chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with pnpm\\x1b[0m\");\n console.log(\"pnpm add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with yarn\\x1b[0m\");\n console.log(\"yarn add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with bun\\x1b[0m\");\n console.log(\"bun add chromadb@latest\\n\");\n } else {\n console.log(\n `\\nYour chromadb version (${latestVersion}) is up-to-date!\\n`,\n );\n }\n } catch (error) {\n console.error(\"Error checking versions:\", error);\n }\n};\n\nconst main = async () => {\n const args: string[] = process.argv.slice(2);\n if (args.length > 0 && args[0] === \"update\") {\n await update();\n return;\n }\n\n binding.cli([\"chroma\", ...args]);\n};\n\nmain().finally();\n","import { createRequire } from \"module\";\nimport os from \"os\";\n\nconst require = createRequire(import.meta.url);\nconst platform = os.platform();\nconst arch = os.arch();\n\nlet binding: any;\n\nif (platform === \"darwin\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-darwin-arm64\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-darwin-x64\");\n } else {\n throw new Error(`Unsupported architecture on macOS: ${arch}`);\n }\n} else if (platform === \"linux\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-linux-arm64-gnu\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-linux-x64-gnu\");\n } else {\n throw new Error(`Unsupported architecture on Linux: ${arch}`);\n }\n} else if (platform === \"win32\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-win32-arm64-msvc\");\n } else {\n throw new Error(\n `Unsupported Windows architecture: ${arch}. Only ARM64 is supported.`,\n );\n }\n} else {\n throw new Error(`Unsupported platform: ${platform}`);\n}\n\nexport default binding;\n"],"mappings":";;;;AACA,OAAO,YAAY;;;ACDnB,SAAS,qBAAqB;AAC9B,OAAO,QAAQ;AAEf,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,WAAW,GAAG,SAAS;AAC7B,IAAM,OAAO,GAAG,KAAK;AAErB,IAAI;AAEJ,IAAI,aAAa,UAAU;AACzB,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,mCAAmC;AAAA,EACvD,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,iCAAiC;AAAA,EACrD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,sCAAsC;AAAA,EAC1D,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,oCAAoC;AAAA,EACxD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,uCAAuC;AAAA,EAC3D,OAAO;AACL,UAAM,IAAI;AAAA,MACR,qCAAqC,IAAI;AAAA,IAC3C;AAAA,EACF;AACF,OAAO;AACL,QAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AACrD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ding from \"./bindings\";\n\ninterface NpmPackageData {\n \"dist-tags\": {\n latest: string;\n [tag: string]: string;\n };\n}\n\nconst getLatestVersion = async (packageName: string): Promise<string> => {\n const response = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!response.ok) {\n throw new Error(`Failed to fetch package data: ${response.statusText}`);\n }\n const data: NpmPackageData = await response.json();\n return data[\"dist-tags\"].latest;\n};\n\nconst update = async (): Promise<void> => {\n try {\n const installedVersion = process.env.CHROMADB_VERSION || \"0.0.0\";\n const latestVersion = await getLatestVersion(\"chromadb\");\n\n if (semver.lt(installedVersion, latestVersion)) {\n console.log(`\\nA new chromadb version (${latestVersion}) is available!`);\n console.log(\"\\n\\x1b[4mUpdat with npm\\x1b[0m\");\n console.log(\"npm install chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with pnpm\\x1b[0m\");\n console.log(\"pnpm add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with yarn\\x1b[0m\");\n console.log(\"yarn add chromadb@latest\");\n\n console.log(\"\\n\\x1b[4mUpdat with bun\\x1b[0m\");\n console.log(\"bun add chromadb@latest\\n\");\n } else {\n console.log(\n `\\nYour chromadb version (${latestVersion}) is up-to-date!\\n`,\n );\n }\n } catch (error) {\n console.error(\"Error checking versions:\", error);\n }\n};\n\nconst main = async () => {\n const args: string[] = process.argv.slice(2);\n if (args.length > 0 && args[0] === \"update\") {\n await update();\n return;\n }\n\n process.on(\"SIGINT\", () => {\n process.exit(0);\n });\n\n binding.cli([\"chroma\", ...args]);\n};\n\nmain().finally();\n","import { createRequire } from \"module\";\nimport os from \"os\";\n\nconst require = createRequire(import.meta.url);\nconst platform = os.platform();\nconst arch = os.arch();\n\nlet binding: any;\n\nif (platform === \"darwin\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-darwin-arm64\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-darwin-x64\");\n } else {\n throw new Error(`Unsupported architecture on macOS: ${arch}`);\n }\n} else if (platform === \"linux\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-linux-arm64-gnu\");\n } else if (arch === \"x64\") {\n binding = require(\"chromadb-js-bindings-linux-x64-gnu\");\n } else {\n throw new Error(`Unsupported architecture on Linux: ${arch}`);\n }\n} else if (platform === \"win32\") {\n if (arch === \"arm64\") {\n binding = require(\"chromadb-js-bindings-win32-arm64-msvc\");\n } else {\n throw new Error(\n `Unsupported Windows architecture: ${arch}. Only ARM64 is supported.`,\n );\n }\n} else {\n throw new Error(`Unsupported platform: ${platform}`);\n}\n\nexport default binding;\n"],"mappings":";;;;AACA,OAAO,YAAY;;;ACDnB,SAAS,qBAAqB;AAC9B,OAAO,QAAQ;AAEf,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,WAAW,GAAG,SAAS;AAC7B,IAAM,OAAO,GAAG,KAAK;AAErB,IAAI;AAEJ,IAAI,aAAa,UAAU;AACzB,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,mCAAmC;AAAA,EACvD,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,iCAAiC;AAAA,EACrD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,sCAAsC;AAAA,EAC1D,WAAW,SAAS,OAAO;AACzB,cAAUA,SAAQ,oCAAoC;AAAA,EACxD,OAAO;AACL,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAAA,EAC9D;AACF,WAAW,aAAa,SAAS;AAC/B,MAAI,SAAS,SAAS;AACpB,cAAUA,SAAQ,uCAAuC;AAAA,EAC3D,OAAO;AACL,UAAM,IAAI;AAAA,MACR,qCAAqC,IAAI;AAAA,IAC3C;AAAA,EACF;AACF,OAAO;AACL,QAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AACrD;AAEA,IAAO,mBAAQ;;;AD1B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
{
|
|
2
2
|
"name": "chromadb",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "A JavaScript interface for chroma",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chroma",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"@chroma-core/default-embed": "^0.1.9"
|
|
61
61
|
},
|
|
62
62
|
"optionalDependencies": {
|
|
63
|
-
"chromadb-js-bindings-darwin-arm64": "^1.3.
|
|
64
|
-
"chromadb-js-bindings-darwin-x64": "^1.3.
|
|
65
|
-
"chromadb-js-bindings-linux-arm64-gnu": "^1.3.
|
|
66
|
-
"chromadb-js-bindings-linux-x64-gnu": "^1.3.
|
|
67
|
-
"chromadb-js-bindings-win32-x64-msvc": "^1.3.
|
|
63
|
+
"chromadb-js-bindings-darwin-arm64": "^1.3.3",
|
|
64
|
+
"chromadb-js-bindings-darwin-x64": "^1.3.3",
|
|
65
|
+
"chromadb-js-bindings-linux-arm64-gnu": "^1.3.3",
|
|
66
|
+
"chromadb-js-bindings-linux-x64-gnu": "^1.3.3",
|
|
67
|
+
"chromadb-js-bindings-win32-x64-msvc": "^1.3.3"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=20"
|
package/src/api/sdk.gen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
3
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
4
|
-
import type { GetUserIdentityData, GetUserIdentityResponse2, GetUserIdentityError, GetCollectionByCrnData, GetCollectionByCrnResponse, GetCollectionByCrnError, HealthcheckData, HealthcheckResponse, HealthcheckError, HeartbeatData, HeartbeatResponse2, HeartbeatError, PreFlightChecksData, PreFlightChecksResponse, PreFlightChecksError, ResetData, ResetResponse, ResetError, CreateTenantData, CreateTenantResponse2, CreateTenantError, GetTenantData, GetTenantResponse2, GetTenantError, UpdateTenantData, UpdateTenantResponse2, UpdateTenantError, ListDatabasesData, ListDatabasesResponse, ListDatabasesError, CreateDatabaseData, CreateDatabaseResponse2, CreateDatabaseError, DeleteDatabaseData, DeleteDatabaseResponse2, DeleteDatabaseError, GetDatabaseData, GetDatabaseResponse, GetDatabaseError, ListCollectionsData, ListCollectionsResponse, ListCollectionsError, CreateCollectionData, CreateCollectionResponse, CreateCollectionError, DeleteCollectionData, DeleteCollectionResponse2, DeleteCollectionError, GetCollectionData, GetCollectionResponse, GetCollectionError, UpdateCollectionData, UpdateCollectionResponse2, UpdateCollectionError, CollectionAddData, CollectionAddResponse, DetachFunctionData, DetachFunctionResponse2, DetachFunctionError, CollectionCountData, CollectionCountResponse, CollectionCountError, CollectionDeleteData, CollectionDeleteResponse, CollectionDeleteError, ForkCollectionData, ForkCollectionResponse, ForkCollectionError, ForkCountData, ForkCountResponse2, ForkCountError, AttachFunctionData, AttachFunctionResponse2, AttachFunctionError, GetAttachedFunctionData, GetAttachedFunctionResponse2, GetAttachedFunctionError, CollectionGetData, CollectionGetResponse, CollectionGetError, IndexingStatusData, IndexingStatusResponse, IndexingStatusError, CollectionQueryData, CollectionQueryResponse, CollectionQueryError, CollectionSearchData, CollectionSearchResponse, CollectionSearchError, CollectionUpdateData, CollectionUpdateResponse, CollectionUpsertData, CollectionUpsertResponse, CollectionUpsertError, CountCollectionsData, CountCollectionsResponse, CountCollectionsError, VersionData, VersionResponse } from './types.gen';
|
|
4
|
+
import type { GetUserIdentityData, GetUserIdentityResponse2, GetUserIdentityError, GetCollectionByCrnData, GetCollectionByCrnResponse, GetCollectionByCrnError, HealthcheckData, HealthcheckResponse, HealthcheckError, HeartbeatData, HeartbeatResponse2, HeartbeatError, PreFlightChecksData, PreFlightChecksResponse, PreFlightChecksError, ResetData, ResetResponse, ResetError, CreateTenantData, CreateTenantResponse2, CreateTenantError, GetTenantData, GetTenantResponse2, GetTenantError, UpdateTenantData, UpdateTenantResponse2, UpdateTenantError, ListDatabasesData, ListDatabasesResponse, ListDatabasesError, CreateDatabaseData, CreateDatabaseResponse2, CreateDatabaseError, DeleteDatabaseData, DeleteDatabaseResponse2, DeleteDatabaseError, GetDatabaseData, GetDatabaseResponse, GetDatabaseError, ListCollectionsData, ListCollectionsResponse, ListCollectionsError, CreateCollectionData, CreateCollectionResponse, CreateCollectionError, GetCollectionByIdData, GetCollectionByIdResponse, GetCollectionByIdError, DeleteCollectionData, DeleteCollectionResponse2, DeleteCollectionError, GetCollectionData, GetCollectionResponse, GetCollectionError, UpdateCollectionData, UpdateCollectionResponse2, UpdateCollectionError, CollectionAddData, CollectionAddResponse, DetachFunctionData, DetachFunctionResponse2, DetachFunctionError, CollectionCountData, CollectionCountResponse, CollectionCountError, CollectionDeleteData, CollectionDeleteResponse, CollectionDeleteError, ForkCollectionData, ForkCollectionResponse, ForkCollectionError, ForkCountData, ForkCountResponse2, ForkCountError, AttachFunctionData, AttachFunctionResponse2, AttachFunctionError, GetAttachedFunctionData, GetAttachedFunctionResponse2, GetAttachedFunctionError, CollectionGetData, CollectionGetResponse, CollectionGetError, IndexingStatusData, IndexingStatusResponse, IndexingStatusError, CollectionQueryData, CollectionQueryResponse, CollectionQueryError, CollectionSearchData, CollectionSearchResponse, CollectionSearchError, CollectionUpdateData, CollectionUpdateResponse, CollectionUpsertData, CollectionUpsertResponse, CollectionUpsertError, CountCollectionsData, CountCollectionsResponse, CountCollectionsError, VersionData, VersionResponse } from './types.gen';
|
|
5
5
|
import { client as _heyApiClient } from './client.gen';
|
|
6
6
|
|
|
7
7
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
@@ -94,6 +94,23 @@ export class CollectionService {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Get collection by ID
|
|
99
|
+
* Returns a collection by its UUID within a specific tenant and database.
|
|
100
|
+
*/
|
|
101
|
+
public static getCollectionById<ThrowOnError extends boolean = true>(options: Options<GetCollectionByIdData, ThrowOnError>) {
|
|
102
|
+
return (options.client ?? _heyApiClient).get<GetCollectionByIdResponse, GetCollectionByIdError, ThrowOnError>({
|
|
103
|
+
security: [
|
|
104
|
+
{
|
|
105
|
+
name: 'x-chroma-token',
|
|
106
|
+
type: 'apiKey'
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}',
|
|
110
|
+
...options
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
/**
|
|
98
115
|
* Delete collection
|
|
99
116
|
* Deletes a collection in a database.
|
package/src/api/types.gen.ts
CHANGED
|
@@ -1307,6 +1307,52 @@ export type CreateCollectionResponses = {
|
|
|
1307
1307
|
|
|
1308
1308
|
export type CreateCollectionResponse = CreateCollectionResponses[keyof CreateCollectionResponses];
|
|
1309
1309
|
|
|
1310
|
+
export type GetCollectionByIdData = {
|
|
1311
|
+
body?: never;
|
|
1312
|
+
path: {
|
|
1313
|
+
/**
|
|
1314
|
+
* Tenant ID
|
|
1315
|
+
*/
|
|
1316
|
+
tenant: string;
|
|
1317
|
+
/**
|
|
1318
|
+
* Database name
|
|
1319
|
+
*/
|
|
1320
|
+
database: string;
|
|
1321
|
+
/**
|
|
1322
|
+
* Collection UUID
|
|
1323
|
+
*/
|
|
1324
|
+
collection_id: string;
|
|
1325
|
+
};
|
|
1326
|
+
query?: never;
|
|
1327
|
+
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}';
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
export type GetCollectionByIdErrors = {
|
|
1331
|
+
/**
|
|
1332
|
+
* Unauthorized
|
|
1333
|
+
*/
|
|
1334
|
+
401: ErrorResponse;
|
|
1335
|
+
/**
|
|
1336
|
+
* Collection not found
|
|
1337
|
+
*/
|
|
1338
|
+
404: ErrorResponse;
|
|
1339
|
+
/**
|
|
1340
|
+
* Server error
|
|
1341
|
+
*/
|
|
1342
|
+
500: ErrorResponse;
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
export type GetCollectionByIdError = GetCollectionByIdErrors[keyof GetCollectionByIdErrors];
|
|
1346
|
+
|
|
1347
|
+
export type GetCollectionByIdResponses = {
|
|
1348
|
+
/**
|
|
1349
|
+
* Collection found
|
|
1350
|
+
*/
|
|
1351
|
+
200: Collection;
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
export type GetCollectionByIdResponse = GetCollectionByIdResponses[keyof GetCollectionByIdResponses];
|
|
1355
|
+
|
|
1310
1356
|
export type DeleteCollectionData = {
|
|
1311
1357
|
body?: never;
|
|
1312
1358
|
path: {
|
package/src/chroma-client.ts
CHANGED
|
@@ -440,6 +440,38 @@ export class ChromaClient {
|
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Retrieves an existing collection by its ID.
|
|
445
|
+
* @param id - The UUID of the collection to retrieve
|
|
446
|
+
* @returns Promise resolving to the Collection instance
|
|
447
|
+
* @throws Error if the collection does not exist
|
|
448
|
+
*/
|
|
449
|
+
public async getCollectionById(id: string): Promise<Collection> {
|
|
450
|
+
const { data } = await CollectionService.getCollectionById({
|
|
451
|
+
client: this.apiClient,
|
|
452
|
+
path: { ...(await this._path()), collection_id: id },
|
|
453
|
+
});
|
|
454
|
+
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
455
|
+
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
456
|
+
const resolvedEmbeddingFunction =
|
|
457
|
+
(await getEmbeddingFunction({
|
|
458
|
+
efConfig: data.configuration_json.embedding_function ?? undefined,
|
|
459
|
+
client: this,
|
|
460
|
+
})) ?? schemaEmbeddingFunction;
|
|
461
|
+
return new CollectionImpl({
|
|
462
|
+
chromaClient: this,
|
|
463
|
+
apiClient: this.apiClient,
|
|
464
|
+
name: data.name,
|
|
465
|
+
tenant: data.tenant,
|
|
466
|
+
database: data.database,
|
|
467
|
+
configuration: data.configuration_json,
|
|
468
|
+
metadata: deserializeMetadata(data.metadata ?? undefined) ?? undefined,
|
|
469
|
+
embeddingFunction: resolvedEmbeddingFunction,
|
|
470
|
+
id: data.id,
|
|
471
|
+
schema,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
443
475
|
/**
|
|
444
476
|
* Retrieves multiple collections by name.
|
|
445
477
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|