Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@langchain/community

Package Overview
Dependencies
Maintainers
10
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/community - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

9

dist/vectorstores/libsql.d.ts

@@ -56,11 +56,2 @@ import type { Client } from "@libsql/client";

/**
* Deletes vectors from the store.
* @param {Object} params - Delete parameters.
* @param {string[] | number[]} [params.ids] - The ids of the vectors to delete.
* @returns {Promise<void>}
*/
delete(params: {
ids?: string[] | number[];
}): Promise<void>;
/**
* Creates a new LibSQLVectorStore instance from texts.

@@ -67,0 +58,0 @@ * @param {string[]} texts - The texts to add to the store.

30

dist/vectorstores/libsql.js

@@ -70,3 +70,6 @@ import { VectorStore } from "@langchain/core/vectorstores";

const chunk = rows.slice(i, i + batchSize);
const insertQueries = chunk.map((row) => `INSERT INTO ${this.table} (content, metadata, ${this.column}) VALUES (${row.content}, ${row.metadata}, vector(${row.embedding})) RETURNING id`);
const insertQueries = chunk.map((row) => ({
sql: `INSERT INTO ${this.table} (content, metadata, ${this.column}) VALUES (?, ?, ?) RETURNING id`,
args: [row.content, row.metadata, row.embedding],
}));
const results = await this.db.batch(insertQueries);

@@ -100,10 +103,12 @@ for (const result of results) {

const sql = `
SELECT content, metadata, vector_distance_cos(${this.column}, vector(${queryVector})) AS distance
FROM vector_top_k('${this.table}_idx', vector(${queryVector}), ${k})
JOIN ${this.table} ON ${this.table}.rowid = id
SELECT ${this.table}.id, ${this.table}.content, ${this.table}.metadata, vector_distance_cos(${this.table}.${this.column}, vector('${queryVector}')) AS distance
FROM vector_top_k('idx_${this.table}_${this.column}', vector('${queryVector}'), ${k}) AS top_k
JOIN ${this.table} ON top_k.rowid = ${this.table}.id
`;
const results = await this.db.execute(sql);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return results.rows.map((row) => {
const metadata = JSON.parse(row.metadata);
const doc = new Document({
id: row.id,
metadata,

@@ -116,19 +121,2 @@ pageContent: row.content,

/**
* Deletes vectors from the store.
* @param {Object} params - Delete parameters.
* @param {string[] | number[]} [params.ids] - The ids of the vectors to delete.
* @returns {Promise<void>}
*/
async delete(params) {
if (!params.ids) {
await this.db.execute(`DELETE FROM ${this.table}`);
return;
}
const idsToDelete = params.ids.join(", ");
await this.db.execute({
sql: `DELETE FROM ${this.table} WHERE id IN (?)`,
args: [idsToDelete],
});
}
/**
* Creates a new LibSQLVectorStore instance from texts.

@@ -135,0 +123,0 @@ * @param {string[]} texts - The texts to add to the store.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc