Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/llm-tools/embedJs
Browse files Browse the repository at this point in the history
  • Loading branch information
adhityan-kv-shift committed Jul 4, 2024
2 parents b1bf8ef + b0f8958 commit 7e31411
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 244 deletions.
236 changes: 9 additions & 227 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@llm-tools/embedjs",
"version": "0.0.89",
"version": "0.0.90",
"description": "A NodeJS RAG framework to easily work with LLMs and custom datasets",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -59,7 +59,7 @@
"@huggingface/inference": "^2.7.0",
"@langchain/anthropic": "^0.2.3",
"@langchain/cohere": "^0.1.0",
"@langchain/community": "^0.2.16",
"@langchain/community": "^0.2.17",
"@langchain/core": "^0.2.12",
"@langchain/google-vertexai": "^0.0.19",
"@langchain/mistralai": "^0.0.25",
Expand Down
11 changes: 8 additions & 3 deletions src/embeddings/ada-embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { OpenAIEmbeddings } from '@langchain/openai';
import { ClientOptions, OpenAIEmbeddings } from '@langchain/openai';
import { BaseEmbeddings } from '../interfaces/base-embeddings.js';

export class AdaEmbeddings implements BaseEmbeddings {
private model: OpenAIEmbeddings;

constructor() {
this.model = new OpenAIEmbeddings({ modelName: 'text-embedding-ada-002', maxConcurrency: 3, maxRetries: 5 });
constructor(options?: { configuration?: ClientOptions; maxConcurrency: number; maxRetries: number }) {
this.model = new OpenAIEmbeddings({
modelName: 'text-embedding-ada-002',
configuration: options?.configuration,
maxConcurrency: options?.maxConcurrency ?? 3,
maxRetries: options?.maxRetries ?? 5,
});
}

getDimensions(): number {
Expand Down
17 changes: 11 additions & 6 deletions src/embeddings/openai-3large-embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { OpenAIEmbeddings } from '@langchain/openai';
import { ClientOptions, OpenAIEmbeddings } from '@langchain/openai';
import { BaseEmbeddings } from '../interfaces/base-embeddings.js';

export class OpenAi3LargeEmbeddings implements BaseEmbeddings {
private model: OpenAIEmbeddings;
private readonly dynamicDimension: number;

constructor(params?: { dynamicDimension?: number }) {
this.dynamicDimension = params?.dynamicDimension ?? 3072;
constructor(options?: {
configuration?: ClientOptions;
dynamicDimension?: number;
maxConcurrency: number;
maxRetries: number;
}) {
this.dynamicDimension = options?.dynamicDimension ?? 3072;

this.model = new OpenAIEmbeddings({
modelName: 'text-embedding-3-large',
maxConcurrency: 3,
maxRetries: 5,
dimensions: this.dynamicDimension,
configuration: options?.configuration,
maxConcurrency: options?.maxConcurrency ?? 3,
maxRetries: options?.maxRetries ?? 5,
});
}

Expand Down
11 changes: 8 additions & 3 deletions src/embeddings/openai-3small-embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { OpenAIEmbeddings } from '@langchain/openai';
import { ClientOptions, OpenAIEmbeddings } from '@langchain/openai';
import { BaseEmbeddings } from '../interfaces/base-embeddings.js';

export class OpenAi3SmallEmbeddings implements BaseEmbeddings {
private model: OpenAIEmbeddings;

constructor() {
this.model = new OpenAIEmbeddings({ modelName: 'text-embedding-3-small', maxConcurrency: 3, maxRetries: 5 });
constructor(options?: { configuration?: ClientOptions; maxConcurrency: number; maxRetries: number }) {
this.model = new OpenAIEmbeddings({
modelName: 'text-embedding-3-small',
configuration: options?.configuration,
maxConcurrency: options?.maxConcurrency ?? 3,
maxRetries: options?.maxRetries ?? 5,
});
}

getDimensions(): number {
Expand Down
Loading

0 comments on commit 7e31411

Please sign in to comment.