Socket
Socket
Sign inDemoInstall

chromadb

Package Overview
Dependencies
2
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.8 to 1.2.0

41

dist/main/index.js

@@ -6,2 +6,20 @@ "use strict";

const configuration_1 = require("./generated/configuration");
// a function to convert a non-Array object to an Array
function toArray(obj) {
if (Array.isArray(obj)) {
return obj;
}
else {
return [obj];
}
}
// a function to convert an array to array of arrays
function toArrayOfArrays(obj) {
if (Array.isArray(obj[0])) {
return obj;
}
else {
return [obj];
}
}
class Collection {

@@ -13,9 +31,18 @@ constructor(name, api) {

async add(ids, embeddings, metadatas, documents, increment_index = true) {
const idsArray = toArray(ids);
const embeddingsArray = toArrayOfArrays(embeddings);
const metadatasArray = toArray(metadatas);
const documentsArray = toArray(documents);
if (idsArray.length !== embeddingsArray.length ||
idsArray.length !== metadatasArray.length ||
idsArray.length !== documentsArray.length) {
throw new Error("ids, embeddings, metadatas, and documents must all be the same length");
}
return await this.api.add({
collectionName: this.name,
addEmbedding: {
ids,
embeddings,
documents,
metadatas,
ids: idsArray,
embeddings: embeddingsArray,
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,

@@ -30,6 +57,7 @@ },

async get(ids, where, limit, offset) {
const idsArray = toArray(ids);
return await this.api.get({
collectionName: this.name,
getEmbedding: {
ids,
ids: idsArray,
where,

@@ -42,6 +70,7 @@ limit,

async query(query_embeddings, n_results = 10, where) {
const query_embeddingsArray = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
query_embeddings,
query_embeddings: query_embeddingsArray,
where,

@@ -48,0 +77,0 @@ n_results,

import { DefaultApi } from "./generated/api";
import { Configuration } from "./generated/configuration";
// a function to convert a non-Array object to an Array
function toArray(obj) {
if (Array.isArray(obj)) {
return obj;
}
else {
return [obj];
}
}
// a function to convert an array to array of arrays
function toArrayOfArrays(obj) {
if (Array.isArray(obj[0])) {
return obj;
}
else {
return [obj];
}
}
export class Collection {

@@ -9,9 +27,18 @@ constructor(name, api) {

async add(ids, embeddings, metadatas, documents, increment_index = true) {
const idsArray = toArray(ids);
const embeddingsArray = toArrayOfArrays(embeddings);
const metadatasArray = toArray(metadatas);
const documentsArray = toArray(documents);
if (idsArray.length !== embeddingsArray.length ||
idsArray.length !== metadatasArray.length ||
idsArray.length !== documentsArray.length) {
throw new Error("ids, embeddings, metadatas, and documents must all be the same length");
}
return await this.api.add({
collectionName: this.name,
addEmbedding: {
ids,
embeddings,
documents,
metadatas,
ids: idsArray,
embeddings: embeddingsArray,
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,

@@ -26,6 +53,7 @@ },

async get(ids, where, limit, offset) {
const idsArray = toArray(ids);
return await this.api.get({
collectionName: this.name,
getEmbedding: {
ids,
ids: idsArray,
where,

@@ -38,6 +66,7 @@ limit,

async query(query_embeddings, n_results = 10, where) {
const query_embeddingsArray = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
query_embeddings,
query_embeddings: query_embeddingsArray,
where,

@@ -44,0 +73,0 @@ n_results,

2

package.json
{
"name": "chromadb",
"version": "1.1.8",
"version": "1.2.0",
"description": "A JavaScript interface for chroma",

@@ -5,0 +5,0 @@ "keywords": [],

import { DefaultApi } from "./generated/api";
import { Configuration } from "./generated/configuration";
// a function to convert a non-Array object to an Array
function toArray<T>(obj: T | Array<T>): Array<T> {
if (Array.isArray(obj)) {
return obj;
} else {
return [obj];
}
}
// a function to convert an array to array of arrays
function toArrayOfArrays<T>(obj: Array<Array<T>> | Array<T>): Array<Array<T>> {
if (Array.isArray(obj[0])) {
return obj as Array<Array<T>>;
} else {
return [obj] as Array<Array<T>>;
}
}
export class Collection {

@@ -20,9 +38,25 @@ private name: string;

) {
const idsArray = toArray(ids);
const embeddingsArray = toArrayOfArrays(embeddings);
const metadatasArray = toArray(metadatas);
const documentsArray = toArray(documents);
if (
idsArray.length !== embeddingsArray.length ||
idsArray.length !== metadatasArray.length ||
idsArray.length !== documentsArray.length
) {
throw new Error(
"ids, embeddings, metadatas, and documents must all be the same length",
);
}
return await this.api.add({
collectionName: this.name,
addEmbedding: {
ids,
embeddings,
documents,
metadatas,
ids: idsArray,
embeddings: embeddingsArray,
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,

@@ -44,6 +78,8 @@ },

) {
const idsArray = toArray(ids);
return await this.api.get({
collectionName: this.name,
getEmbedding: {
ids,
ids: idsArray,
where,

@@ -61,6 +97,8 @@ limit,

) {
const query_embeddingsArray = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
query_embeddings,
query_embeddings: query_embeddingsArray,
where,

@@ -67,0 +105,0 @@ n_results,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc