You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

embeddings-splitter

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embeddings-splitter - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+4
-1
lib/helpers/getChunksByMaxToken.d.ts
import { TiktokenEmbedding } from '@dqbd/tiktoken';
export declare function getChunksByMaxToken(text: string, max_tokens?: number, encoding_name?: TiktokenEmbedding): Promise<any[]>;
export declare function getChunksByMaxToken(text: string, callback: (chunk: string) => void, { maxTokens, encoding_name }: {
maxTokens?: number;
encoding_name?: TiktokenEmbedding;
}): Promise<void>;
+3
-5

@@ -36,6 +36,5 @@ "use strict";

}
function getChunksByMaxToken(text, max_tokens = EMBEDDING_CTX_LENGTH, encoding_name = EMBEDDING_ENCODING) {
function getChunksByMaxToken(text, callback, { maxTokens = EMBEDDING_CTX_LENGTH, encoding_name = EMBEDDING_ENCODING }) {
return __awaiter(this, void 0, void 0, function* () {
const chunks = [];
for (const chunk of chunked_tokens(text, encoding_name, max_tokens)) {
for (const chunk of chunked_tokens(text, encoding_name, maxTokens)) {
const enc = (0, tiktoken_1.get_encoding)(encoding_name);

@@ -45,3 +44,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

const _chunk = new TextDecoder().decode(enc.decode(chunk));
chunks.push(_chunk);
callback(_chunk);
}

@@ -56,5 +55,4 @@ // removing for now but would be cool to add it as a seperate function

// }
return chunks;
});
}
exports.getChunksByMaxToken = getChunksByMaxToken;
{
"name": "embeddings-splitter",
"version": "0.1.0",
"version": "0.2.0",
"description": "A typescript library to split your long texts into smaller chunks to send them to OpenAI Embeddings API",

@@ -5,0 +5,0 @@ "main": "lib/index.js",