Skip to content

Commit

Permalink
Merge pull request #115 from llm-tools/monorepo
Browse files Browse the repository at this point in the history
Monorepo
  • Loading branch information
adhityan authored Oct 4, 2024
2 parents ddcea24 + 566df16 commit afb0d7f
Show file tree
Hide file tree
Showing 62 changed files with 249 additions and 437 deletions.
4 changes: 4 additions & 0 deletions core/embedjs-interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1 (2024-10-04)

Temporarily disabled dynamic, url and local path loaders as they required install of all modules from the monorepo. They will be reenabled soon.

## 0.1.0 (2024-10-03)

This component has been extracted and is now published as part of a workspace monorepo managed by [NX](https://nx.dev/). There are many reasons that prompted this move, but the most critical issue was to decouple the need to install all dependencies for a single usecase. While we add (and continue to add) more and more loaders, databases, caches and models - the number of shared dependencies grew a lot. Most projects will not use all these combinations and it made no sense to have them all installed for everyone. Further, issues with dependent packages raised vulnerabilities that affected all projects - clearly something we did not intend.
Expand Down
2 changes: 1 addition & 1 deletion core/embedjs-interfaces/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@llm-tools/embedjs-interfaces",
"version": "0.1.0",
"version": "0.1.1",
"description": "Interfaces for extending the embedjs ecosystem",
"dependencies": {
"debug": "^4.3.7",
Expand Down
4 changes: 4 additions & 0 deletions core/embedjs-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1 (2024-10-04)

Temporarily disabled dynamic, url and local path loaders as they required install of all modules from the monorepo. They will be reenabled soon.

## 0.1.0 (2024-10-03)

This component has been extracted and is now published as part of a workspace monorepo managed by [NX](https://nx.dev/). There are many reasons that prompted this move, but the most critical issue was to decouple the need to install all dependencies for a single usecase. While we add (and continue to add) more and more loaders, databases, caches and models - the number of shared dependencies grew a lot. Most projects will not use all these combinations and it made no sense to have them all installed for everyone. Further, issues with dependent packages raised vulnerabilities that affected all projects - clearly something we did not intend.
Expand Down
4 changes: 2 additions & 2 deletions core/embedjs-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@llm-tools/embedjs-utils",
"version": "0.1.0",
"version": "0.1.1",
"description": "Useful util functions when extending the embedjs ecosystem",
"dependencies": {
"@llm-tools/embedjs-interfaces": "0.1.0"
"@llm-tools/embedjs-interfaces": "0.1.1"
},
"type": "module",
"main": "./src/index.js",
Expand Down
4 changes: 4 additions & 0 deletions core/embedjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1 (2024-10-04)

Temporarily disabled dynamic, url and local path loaders as they required install of all modules from the monorepo. They will be reenabled soon.

## 0.1.0 (2024-10-03)

This component has been extracted and is now published as part of a workspace monorepo managed by [NX](https://nx.dev/). There are many reasons that prompted this move, but the most critical issue was to decouple the need to install all dependencies for a single usecase. While we add (and continue to add) more and more loaders, databases, caches and models - the number of shared dependencies grew a lot. Most projects will not use all these combinations and it made no sense to have them all installed for everyone. Further, issues with dependent packages raised vulnerabilities that affected all projects - clearly something we did not intend.
Expand Down
6 changes: 3 additions & 3 deletions core/embedjs/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "module",
"name": "@llm-tools/embedjs",
"version": "0.1.0",
"version": "0.1.1",
"description": "A NodeJS RAG framework to easily work with LLMs and custom datasets",
"dependencies": {
"@llm-tools/embedjs-interfaces": "0.1.0",
"@llm-tools/embedjs-utils": "0.1.0",
"@llm-tools/embedjs-interfaces": "0.1.1",
"@llm-tools/embedjs-utils": "0.1.1",
"axios": "^1.7.7",
"debug": "^4.3.7",
"langchain": "^0.3.2",
Expand Down
145 changes: 0 additions & 145 deletions core/embedjs/src/core/dynamic-loader-selector.ts

This file was deleted.

21 changes: 5 additions & 16 deletions core/embedjs/src/core/rag-application-builder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { RAGApplication } from './rag-application.js';
import { LoaderParam } from './dynamic-loader-selector.js';
import {
BaseCache,
BaseConversation,
BaseDb,
BaseEmbeddings,
BaseLoader,
BaseModel,
SIMPLE_MODELS,
} from '@llm-tools/embedjs-interfaces';
import { OpenAi } from '@llm-tools/embedjs-openai';

export class RAGApplicationBuilder {
private temperature: number;
Expand All @@ -18,7 +16,7 @@ export class RAGApplicationBuilder {
private searchResultCount: number;
private embeddingModel: BaseEmbeddings;
private embeddingRelevanceCutOff: number;
private loaders: LoaderParam[];
private loaders: BaseLoader[];
private vectorDb: BaseDb;
private conversations: BaseConversation;

Expand All @@ -32,7 +30,6 @@ export class RAGApplicationBuilder {
Do not use words like context or training data when responding. You can say you do not have all the information but do not indicate that you are not a reliable source.`;

this.setModel(SIMPLE_MODELS.OPENAI_GPT4_O);
this.embeddingRelevanceCutOff = 0;
}

Expand All @@ -42,7 +39,7 @@ export class RAGApplicationBuilder {
return entity;
}

addLoader(loader: LoaderParam) {
addLoader(loader: BaseLoader) {
this.loaders.push(loader);
return this;
}
Expand Down Expand Up @@ -86,17 +83,9 @@ export class RAGApplicationBuilder {
return this;
}

setModel(model: 'NO_MODEL' | SIMPLE_MODELS | BaseModel) {
setModel(model: 'NO_MODEL' | BaseModel) {
if (typeof model === 'object') this.model = model;
else {
if (model === SIMPLE_MODELS.OPENAI_GPT4_O) this.model = new OpenAi({ modelName: 'gpt-4o' });
else if (model === SIMPLE_MODELS['OPENAI_GPT4_TURBO'])
this.model = new OpenAi({ modelName: 'gpt-4-turbo' });
else if (model === SIMPLE_MODELS['OPENAI_GPT3.5_TURBO'])
this.model = new OpenAi({ modelName: 'gpt-3.5-turbo' });
else this.model = null;
}

else this.model = null;
return this;
}

Expand Down
15 changes: 6 additions & 9 deletions core/embedjs/src/core/rag-application.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import createDebugMessages from 'debug';

import { DynamicLoader, LoaderParam } from './dynamic-loader-selector.js';
import { RAGApplicationBuilder } from './rag-application-builder.js';
import { RAGEmbedding } from './rag-embedding.js';
import { RAGApplicationBuilder } from './rag-application-builder.js';
import { InMemoryConversation } from '../conversation/memory-conversations.js';
import {
AddLoaderReturn,
Expand All @@ -17,7 +16,6 @@ import {
QueryResponse,
} from '@llm-tools/embedjs-interfaces';
import { cleanString, getUnique } from '@llm-tools/embedjs-utils';
import { OpenAi3SmallEmbeddings } from '@llm-tools/embedjs-openai';

export class RAGApplication {
private readonly debug = createDebugMessages('embedjs:core');
Expand All @@ -28,7 +26,7 @@ export class RAGApplication {
private readonly model: BaseModel;
private readonly embeddingRelevanceCutOff: number;

private readonly rawLoaders: LoaderParam[];
private readonly rawLoaders: BaseLoader[];
private loaders: BaseLoader[];

constructor(llmBuilder: RAGApplicationBuilder) {
Expand All @@ -52,7 +50,7 @@ export class RAGApplication {
this.searchResultCount = llmBuilder.getSearchResultCount();
this.embeddingRelevanceCutOff = llmBuilder.getEmbeddingRelevanceCutOff();

RAGEmbedding.init(llmBuilder.getEmbeddingModel() ?? new OpenAi3SmallEmbeddings());
RAGEmbedding.init(llmBuilder.getEmbeddingModel());
}

/**
Expand Down Expand Up @@ -84,7 +82,7 @@ export class RAGApplication {
* cache, and pre-loaders.
*/
public async init() {
this.loaders = await DynamicLoader.createLoaders(this.rawLoaders);
this.loaders = this.rawLoaders;

if (this.model) {
await this.model.init();
Expand Down Expand Up @@ -116,9 +114,8 @@ export class RAGApplication {
* - `uniqueId`: Unique identifier of the loader
* - `loaderType`: Name of the loader's constructor class
*/
public async addLoader(loaderParam: LoaderParam): Promise<AddLoaderReturn> {
const loader = await DynamicLoader.createLoader(loaderParam);
return this._addLoader(loader);
public async addLoader(loaderParam: BaseLoader): Promise<AddLoaderReturn> {
return this._addLoader(loaderParam);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions core/embedjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ import { RAGApplication } from './core/rag-application.js';
import { RAGApplicationBuilder } from './core/rag-application-builder.js';
import { TextLoader } from './loaders/text-loader.js';
import { JsonLoader } from './loaders/json-loader.js';
import { LocalPathLoader } from './loaders/local-path-loader.js';
import { UrlLoader } from './loaders/url-loader.js';
import { SIMPLE_MODELS } from '@llm-tools/embedjs-interfaces';

export { RAGApplication, RAGApplicationBuilder, TextLoader, JsonLoader, UrlLoader, LocalPathLoader, SIMPLE_MODELS };
export { RAGApplication, RAGApplicationBuilder, TextLoader, JsonLoader };
62 changes: 0 additions & 62 deletions core/embedjs/src/loaders/local-path-loader.ts

This file was deleted.

Loading

0 comments on commit afb0d7f

Please sign in to comment.