langchain-rag-chat 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/core/RAGChat.d.ts +104 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +26964 -0
- package/dist/loaders/index.d.ts +6 -0
- package/dist/loaders/load.d.ts +31 -0
- package/dist/loaders/pdfLoader.d.ts +12 -0
- package/dist/loaders/webLoader.d.ts +16 -0
- package/dist/models/chatModel.d.ts +2 -0
- package/dist/models/embedModel.d.ts +13 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/prompts/answerPrompt.d.ts +6 -0
- package/dist/prompts/classifyPrompt.d.ts +7 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/multiQueryPrompt.d.ts +7 -0
- package/dist/utils/concurrency.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { loadResources } from './load';
|
|
2
|
+
export { loadPDF } from './pdfLoader';
|
|
3
|
+
export { loadWebPage } from './webLoader';
|
|
4
|
+
export type { Resource, LoadOptions, CustomLoder } from './load';
|
|
5
|
+
export type { PDFLoader } from './pdfLoader';
|
|
6
|
+
export type { WebURL } from './webLoader';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Document } from '@langchain/core/documents';
|
|
2
|
+
import { RecursiveCharacterTextSplitterParams } from '@langchain/classic/text_splitter';
|
|
3
|
+
export interface Resource {
|
|
4
|
+
/**
|
|
5
|
+
* source assets path
|
|
6
|
+
*/
|
|
7
|
+
url: string;
|
|
8
|
+
/**
|
|
9
|
+
* web site
|
|
10
|
+
*/
|
|
11
|
+
selector?: string;
|
|
12
|
+
/**
|
|
13
|
+
* pdf
|
|
14
|
+
*/
|
|
15
|
+
pageSplitter?: boolean;
|
|
16
|
+
text?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CustomLoder {
|
|
19
|
+
[K: string]: (resource: Resource) => Promise<Document<any>[]>;
|
|
20
|
+
}
|
|
21
|
+
export interface LoadOptions {
|
|
22
|
+
resource: Resource[];
|
|
23
|
+
/**
|
|
24
|
+
* concurrency
|
|
25
|
+
* @default 3
|
|
26
|
+
*/
|
|
27
|
+
concurrencyCount?: number;
|
|
28
|
+
splitterOptions?: RecursiveCharacterTextSplitterParams;
|
|
29
|
+
loader?: CustomLoder | null;
|
|
30
|
+
}
|
|
31
|
+
export declare function loadResources(options: LoadOptions): Promise<Document<Record<string, any>>[][]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Document } from '@langchain/core/documents';
|
|
2
|
+
import { LoadParameters } from 'pdf-parse';
|
|
3
|
+
export interface PDFLoader extends LoadParameters {
|
|
4
|
+
/**
|
|
5
|
+
* web url
|
|
6
|
+
*/
|
|
7
|
+
url: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadPDF(options: PDFLoader): Promise<Document<{
|
|
10
|
+
source: string;
|
|
11
|
+
page: number;
|
|
12
|
+
}>[]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Document } from '@langchain/core/documents';
|
|
2
|
+
export interface WebURL {
|
|
3
|
+
/**
|
|
4
|
+
* web url
|
|
5
|
+
*/
|
|
6
|
+
url: string;
|
|
7
|
+
/**
|
|
8
|
+
* css selector
|
|
9
|
+
* @default "body"
|
|
10
|
+
*/
|
|
11
|
+
selector?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function loadWebPage(options: WebURL): Promise<Document<{
|
|
14
|
+
source: string;
|
|
15
|
+
selector: string;
|
|
16
|
+
}>[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OpenAIEmbeddings, OpenAIEmbeddingsParams, OpenAIApiKey, ClientOptions } from '@langchain/openai';
|
|
2
|
+
export interface EmbeddingModelOptions extends Partial<OpenAIEmbeddingsParams> {
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The OpenAI API key to use.
|
|
6
|
+
* Alias for `apiKey`.
|
|
7
|
+
*/
|
|
8
|
+
openAIApiKey?: OpenAIApiKey;
|
|
9
|
+
/** The OpenAI API key to use. */
|
|
10
|
+
apiKey?: OpenAIApiKey;
|
|
11
|
+
configuration?: ClientOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare function createEmbeddingModel(options: EmbeddingModelOptions): OpenAIEmbeddings<number[]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export interface Answer {
|
|
3
|
+
question: string;
|
|
4
|
+
context: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const answerPrompt: ChatPromptTemplate<import('@langchain/core/prompts').ParamsFromFString<"Please answer the user's question based on the content of the following document. If there is insufficient information in the document, do your best to answer the user's question within your capabilities, and then clearly indicate whether the answer is based on the content of the document.\nDocument:\n{context}\nUser question:\n{question}">, any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export interface Classify {
|
|
3
|
+
category: string;
|
|
4
|
+
question: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const classifyPrompt: ChatPromptTemplate<import('@langchain/core/prompts').ParamsFromFString<"Classify user questions into the following categories: {category}.\n{content}\nSpecial note: Only output the classification names, do not output explanations.\nUser question: {question}">, any>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { multiQueryPrompt } from './multiQueryPrompt';
|
|
2
|
+
export { classifyPrompt } from './classifyPrompt';
|
|
3
|
+
export { answerPrompt } from './answerPrompt';
|
|
4
|
+
export type { MultiQuery } from './multiQueryPrompt';
|
|
5
|
+
export type { Classify } from './classifyPrompt';
|
|
6
|
+
export type { Answer } from './answerPrompt';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export interface MultiQuery {
|
|
3
|
+
queryCount: number;
|
|
4
|
+
separator: string;
|
|
5
|
+
question: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const multiQueryPrompt: ChatPromptTemplate<import('@langchain/core/prompts').ParamsFromFString<"You are an AI language model assistant. Your task is to generate {queryCount}\ndifferent versions of the given user question to retrieve relevant documents from a vector database.\nBy generating multiple perspectives on the user question, your goal is to help the user overcome some of\nthe limitations of the distance-based similarity search.\nProvide these alternative questions separated by '{separator}'.\nOriginal question: {question}">, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { concurrency } from './concurrency';
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "langchain-rag-chat",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A RAG chat library built with LangChain",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"build": "tsc --noEmit && vite build",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"pack:check": "npm pack --dry-run"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"rag",
|
|
28
|
+
"langchain",
|
|
29
|
+
"retrieval",
|
|
30
|
+
"ai"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@langchain/classic": "^1.0.48",
|
|
35
|
+
"@langchain/core": "^1.2.11",
|
|
36
|
+
"@langchain/openai": "^1.5.13",
|
|
37
|
+
"cheerio": "^1.2.0",
|
|
38
|
+
"langchain": "^1.5.11",
|
|
39
|
+
"pdf-parse": "^2.4.5"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"typescript": "~6.0.3",
|
|
43
|
+
"vite": "^8.2.2",
|
|
44
|
+
"vite-plugin-dts": "^5.1.0"
|
|
45
|
+
}
|
|
46
|
+
}
|