autocoder-rag-sdk 0.0.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 +22 -0
- package/README.md +105 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +247 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 AutoCoder Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# AutoCoder RAG SDK for Node.js
|
|
2
|
+
|
|
3
|
+
一个便于在Node.js/TypeScript代码中调用`auto-coder.rag run`功能的SDK,用于文档问答和检索增强生成。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🚀 **易于使用**: 提供简洁直观的API接口
|
|
8
|
+
- 🔄 **异步优先**: 基于Promise和AsyncGenerator的现代异步设计
|
|
9
|
+
- 📡 **流式处理**: 支持实时流式输出答案
|
|
10
|
+
- 🛠 **完整配置**: 支持所有auto-coder.rag run命令行选项
|
|
11
|
+
- 📦 **TypeScript优先**: 完整的类型定义和类型安全
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd rag-sdks/nodejs
|
|
17
|
+
pnpm install
|
|
18
|
+
pnpm run build
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 快速开始
|
|
22
|
+
|
|
23
|
+
### 基础用法
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { AutoCoderRAGClient } from 'autocoder-rag-sdk';
|
|
27
|
+
|
|
28
|
+
const client = new AutoCoderRAGClient('/path/to/docs');
|
|
29
|
+
|
|
30
|
+
const answer = await client.query('如何使用这个项目?');
|
|
31
|
+
console.log(answer);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 流式输出
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { AutoCoderRAGClient } from 'autocoder-rag-sdk';
|
|
38
|
+
|
|
39
|
+
const client = new AutoCoderRAGClient('/path/to/docs');
|
|
40
|
+
|
|
41
|
+
for await (const chunk of client.queryStream('这个项目的主要功能是什么?')) {
|
|
42
|
+
process.stdout.write(chunk);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 获取上下文
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { AutoCoderRAGClient } from 'autocoder-rag-sdk';
|
|
50
|
+
|
|
51
|
+
const client = new AutoCoderRAGClient('/path/to/docs');
|
|
52
|
+
|
|
53
|
+
const response = await client.queryWithContexts('如何安装?');
|
|
54
|
+
|
|
55
|
+
console.log(`答案: ${response.answer}`);
|
|
56
|
+
console.log(`上下文数量: ${response.contexts?.length || 0}`);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 高级配置
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { AutoCoderRAGClient, RAGConfig } from 'autocoder-rag-sdk';
|
|
63
|
+
|
|
64
|
+
const config: RAGConfig = {
|
|
65
|
+
docDir: '/path/to/docs',
|
|
66
|
+
model: 'v3_chat',
|
|
67
|
+
agentic: true, // 使用 AgenticRAG
|
|
68
|
+
productMode: 'pro',
|
|
69
|
+
enableHybridIndex: true,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const client = new AutoCoderRAGClient(config);
|
|
73
|
+
|
|
74
|
+
const answer = await client.query('项目架构是什么?');
|
|
75
|
+
console.log(answer);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API 文档
|
|
79
|
+
|
|
80
|
+
### AutoCoderRAGClient
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
class AutoCoderRAGClient {
|
|
84
|
+
constructor(config: RAGConfig | string);
|
|
85
|
+
query(question: string, options?: RAGQueryOptions): Promise<string>;
|
|
86
|
+
queryStream(question: string, options?: RAGQueryOptions): AsyncGenerator<string>;
|
|
87
|
+
queryWithContexts(question: string, options?: RAGQueryOptions): Promise<RAGResponse>;
|
|
88
|
+
getVersion(): string;
|
|
89
|
+
checkAvailability(): boolean;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 示例
|
|
94
|
+
|
|
95
|
+
运行示例:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm run example:basic
|
|
99
|
+
pnpm run example:stream
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 许可证
|
|
103
|
+
|
|
104
|
+
MIT License
|
|
105
|
+
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoCoder RAG SDK 客户端
|
|
3
|
+
*/
|
|
4
|
+
import { RAGConfig, RAGQueryOptions, RAGResponse } from './types';
|
|
5
|
+
export declare class AutoCoderRAGClient {
|
|
6
|
+
private config;
|
|
7
|
+
constructor(configOrDocDir: RAGConfig | string);
|
|
8
|
+
private getDefaultConfig;
|
|
9
|
+
private validateConfig;
|
|
10
|
+
query(question: string, options?: RAGQueryOptions): Promise<string>;
|
|
11
|
+
queryStream(question: string, options?: RAGQueryOptions): AsyncGenerator<string, void, unknown>;
|
|
12
|
+
queryWithContexts(question: string, options?: RAGQueryOptions): Promise<RAGResponse>;
|
|
13
|
+
private buildCommand;
|
|
14
|
+
getVersion(): string;
|
|
15
|
+
checkAvailability(): boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EAIZ,MAAM,SAAS,CAAC;AAOjB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAoB;gBAEtB,cAAc,EAAE,SAAS,GAAG,MAAM;IAa9C,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,cAAc;IAYhB,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC;IA2DX,WAAW,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;IAiDlC,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;IA6BvB,OAAO,CAAC,YAAY;IAiFpB,UAAU,IAAI,MAAM;IAYpB,iBAAiB,IAAI,OAAO;CAS7B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AutoCoder RAG SDK 客户端
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AutoCoderRAGClient = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class AutoCoderRAGClient {
|
|
11
|
+
constructor(configOrDocDir) {
|
|
12
|
+
if (typeof configOrDocDir === 'string') {
|
|
13
|
+
this.config = this.getDefaultConfig(configOrDocDir);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this.config = {
|
|
17
|
+
...this.getDefaultConfig(configOrDocDir.docDir),
|
|
18
|
+
...configOrDocDir,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
this.validateConfig();
|
|
22
|
+
}
|
|
23
|
+
getDefaultConfig(docDir) {
|
|
24
|
+
return {
|
|
25
|
+
docDir,
|
|
26
|
+
model: 'v3_chat',
|
|
27
|
+
timeout: 300000, // 默认5分钟(毫秒)
|
|
28
|
+
ragContextWindowLimit: 56000,
|
|
29
|
+
fullTextRatio: 0.7,
|
|
30
|
+
segmentRatio: 0.2,
|
|
31
|
+
ragDocFilterRelevance: 5,
|
|
32
|
+
agentic: false,
|
|
33
|
+
productMode: 'lite',
|
|
34
|
+
enableHybridIndex: false,
|
|
35
|
+
disableAutoWindow: false,
|
|
36
|
+
disableSegmentReorder: false,
|
|
37
|
+
recallModel: '',
|
|
38
|
+
chunkModel: '',
|
|
39
|
+
qaModel: '',
|
|
40
|
+
embModel: '',
|
|
41
|
+
agenticModel: '',
|
|
42
|
+
contextPruneModel: '',
|
|
43
|
+
tokenizerPath: undefined,
|
|
44
|
+
requiredExts: '',
|
|
45
|
+
rayAddress: 'auto',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
validateConfig() {
|
|
49
|
+
if (!(0, fs_1.existsSync)(this.config.docDir)) {
|
|
50
|
+
throw new types_1.ValidationError(`文档目录不存在: ${this.config.docDir}`);
|
|
51
|
+
}
|
|
52
|
+
if (!['lite', 'pro'].includes(this.config.productMode)) {
|
|
53
|
+
throw new types_1.ValidationError(`不支持的产品模式: ${this.config.productMode}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async query(question, options = {}) {
|
|
57
|
+
const opts = { outputFormat: 'text', ...options };
|
|
58
|
+
if (!['text', 'json', 'stream-json'].includes(opts.outputFormat)) {
|
|
59
|
+
throw new types_1.ValidationError(`不支持的输出格式: ${opts.outputFormat}`);
|
|
60
|
+
}
|
|
61
|
+
// 获取超时时间
|
|
62
|
+
const timeout = opts.timeout !== undefined ? opts.timeout : this.config.timeout;
|
|
63
|
+
const cmd = this.buildCommand(opts);
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const process = (0, child_process_1.spawn)(cmd[0], cmd.slice(1));
|
|
66
|
+
// 设置超时
|
|
67
|
+
const timeoutId = setTimeout(() => {
|
|
68
|
+
process.kill();
|
|
69
|
+
reject(new types_1.ExecutionError('查询执行超时'));
|
|
70
|
+
}, timeout);
|
|
71
|
+
let stdout = '';
|
|
72
|
+
let stderr = '';
|
|
73
|
+
// 发送问题
|
|
74
|
+
if (process.stdin) {
|
|
75
|
+
process.stdin.write(question);
|
|
76
|
+
process.stdin.end();
|
|
77
|
+
}
|
|
78
|
+
// 收集输出
|
|
79
|
+
process.stdout?.on('data', data => {
|
|
80
|
+
stdout += data.toString();
|
|
81
|
+
});
|
|
82
|
+
process.stderr?.on('data', data => {
|
|
83
|
+
stderr += data.toString();
|
|
84
|
+
});
|
|
85
|
+
process.on('close', code => {
|
|
86
|
+
clearTimeout(timeoutId); // 清除超时定时器
|
|
87
|
+
if (code !== 0) {
|
|
88
|
+
reject(new types_1.ExecutionError(stderr || `命令执行失败,退出码: ${code}`, code || undefined));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
resolve(stdout.trim());
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
process.on('error', err => {
|
|
95
|
+
reject(new types_1.RAGError(`进程错误: ${err.message}`));
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async *queryStream(question, options = {}) {
|
|
100
|
+
const opts = { outputFormat: 'text', ...options };
|
|
101
|
+
const cmd = this.buildCommand(opts);
|
|
102
|
+
const process = (0, child_process_1.spawn)(cmd[0], cmd.slice(1));
|
|
103
|
+
// 发送问题
|
|
104
|
+
if (process.stdin) {
|
|
105
|
+
process.stdin.write(question);
|
|
106
|
+
process.stdin.end();
|
|
107
|
+
}
|
|
108
|
+
// 流式输出
|
|
109
|
+
if (!process.stdout) {
|
|
110
|
+
throw new types_1.RAGError('无法获取进程输出');
|
|
111
|
+
}
|
|
112
|
+
let buffer = '';
|
|
113
|
+
for await (const chunk of process.stdout) {
|
|
114
|
+
buffer += chunk.toString();
|
|
115
|
+
const lines = buffer.split('\n');
|
|
116
|
+
// 保留最后一行(可能不完整)
|
|
117
|
+
buffer = lines.pop() || '';
|
|
118
|
+
for (const line of lines) {
|
|
119
|
+
yield line;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// 输出最后剩余的内容
|
|
123
|
+
if (buffer) {
|
|
124
|
+
yield buffer;
|
|
125
|
+
}
|
|
126
|
+
// 检查退出码
|
|
127
|
+
const exitCode = await new Promise(resolve => {
|
|
128
|
+
process.on('close', code => resolve(code));
|
|
129
|
+
});
|
|
130
|
+
if (exitCode !== 0) {
|
|
131
|
+
throw new types_1.ExecutionError(`命令执行失败,退出码: ${exitCode}`, exitCode || undefined);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async queryWithContexts(question, options = {}) {
|
|
135
|
+
const opts = { ...options, outputFormat: 'json' };
|
|
136
|
+
try {
|
|
137
|
+
const result = await this.query(question, opts);
|
|
138
|
+
const data = JSON.parse(result);
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
answer: data.answer || '',
|
|
142
|
+
contexts: data.contexts || [],
|
|
143
|
+
metadata: data.metadata || {},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error instanceof types_1.RAGError) {
|
|
148
|
+
return {
|
|
149
|
+
success: false,
|
|
150
|
+
answer: '',
|
|
151
|
+
error: error.message,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
answer: '',
|
|
157
|
+
error: `查询失败: ${error}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
buildCommand(options) {
|
|
162
|
+
const cmd = ['auto-coder.rag', 'run', '--doc_dir', this.config.docDir];
|
|
163
|
+
// 模型参数
|
|
164
|
+
const model = options.model || this.config.model;
|
|
165
|
+
if (model) {
|
|
166
|
+
cmd.push('--model', model);
|
|
167
|
+
}
|
|
168
|
+
// 输出格式
|
|
169
|
+
cmd.push('--output_format', options.outputFormat || 'text');
|
|
170
|
+
// RAG 模式
|
|
171
|
+
const agentic = options.agentic !== undefined ? options.agentic : this.config.agentic;
|
|
172
|
+
if (agentic) {
|
|
173
|
+
cmd.push('--agentic');
|
|
174
|
+
}
|
|
175
|
+
// 产品模式
|
|
176
|
+
const productMode = options.productMode || this.config.productMode;
|
|
177
|
+
if (productMode === 'pro') {
|
|
178
|
+
cmd.push('--pro');
|
|
179
|
+
}
|
|
180
|
+
else if (productMode === 'lite') {
|
|
181
|
+
cmd.push('--lite');
|
|
182
|
+
}
|
|
183
|
+
// RAG 参数
|
|
184
|
+
cmd.push('--rag_context_window_limit', String(this.config.ragContextWindowLimit), '--full_text_ratio', String(this.config.fullTextRatio), '--segment_ratio', String(this.config.segmentRatio), '--rag_doc_filter_relevance', String(this.config.ragDocFilterRelevance));
|
|
185
|
+
// 可选模型
|
|
186
|
+
if (this.config.recallModel) {
|
|
187
|
+
cmd.push('--recall_model', this.config.recallModel);
|
|
188
|
+
}
|
|
189
|
+
if (this.config.chunkModel) {
|
|
190
|
+
cmd.push('--chunk_model', this.config.chunkModel);
|
|
191
|
+
}
|
|
192
|
+
if (this.config.qaModel) {
|
|
193
|
+
cmd.push('--qa_model', this.config.qaModel);
|
|
194
|
+
}
|
|
195
|
+
if (this.config.embModel) {
|
|
196
|
+
cmd.push('--emb_model', this.config.embModel);
|
|
197
|
+
}
|
|
198
|
+
if (this.config.agenticModel) {
|
|
199
|
+
cmd.push('--agentic_model', this.config.agenticModel);
|
|
200
|
+
}
|
|
201
|
+
if (this.config.contextPruneModel) {
|
|
202
|
+
cmd.push('--context_prune_model', this.config.contextPruneModel);
|
|
203
|
+
}
|
|
204
|
+
// 索引选项
|
|
205
|
+
if (this.config.enableHybridIndex) {
|
|
206
|
+
cmd.push('--enable_hybrid_index');
|
|
207
|
+
}
|
|
208
|
+
if (this.config.disableAutoWindow) {
|
|
209
|
+
cmd.push('--disable_auto_window');
|
|
210
|
+
}
|
|
211
|
+
if (this.config.disableSegmentReorder) {
|
|
212
|
+
cmd.push('--disable_segment_reorder');
|
|
213
|
+
}
|
|
214
|
+
// 其他参数
|
|
215
|
+
if (this.config.requiredExts) {
|
|
216
|
+
cmd.push('--required_exts', this.config.requiredExts);
|
|
217
|
+
}
|
|
218
|
+
if (this.config.tokenizerPath) {
|
|
219
|
+
cmd.push('--tokenizer_path', this.config.tokenizerPath);
|
|
220
|
+
}
|
|
221
|
+
return cmd;
|
|
222
|
+
}
|
|
223
|
+
getVersion() {
|
|
224
|
+
try {
|
|
225
|
+
const result = (0, child_process_1.execSync)('auto-coder.rag --version', {
|
|
226
|
+
encoding: 'utf-8',
|
|
227
|
+
timeout: 60000, // 60秒超时
|
|
228
|
+
});
|
|
229
|
+
return result.trim();
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return 'unknown';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
checkAvailability() {
|
|
236
|
+
try {
|
|
237
|
+
(0, child_process_1.execSync)('which auto-coder.rag', { timeout: 60000 }); // 60秒超时
|
|
238
|
+
(0, child_process_1.execSync)('auto-coder.rag --help', { timeout: 60000 }); // 60秒超时
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.AutoCoderRAGClient = AutoCoderRAGClient;
|
|
247
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAgD;AAChD,2BAAgC;AAChC,mCAOiB;AAOjB,MAAa,kBAAkB;IAG7B,YAAY,cAAkC;QAC5C,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG;gBACZ,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC/C,GAAG,cAAc;aACG,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEO,gBAAgB,CAAC,MAAc;QACrC,OAAO;YACL,MAAM;YACN,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,MAAM,EAAG,YAAY;YAC9B,qBAAqB,EAAE,KA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AC/D,IAAA,wBAAQ,EAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAE,QAAQ;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AA9SD,gDA8SC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoCoder RAG SDK for Node.js
|
|
3
|
+
*
|
|
4
|
+
* 一个便于在Node.js代码中调用auto-coder.rag run功能的SDK。
|
|
5
|
+
*/
|
|
6
|
+
export { AutoCoderRAGClient } from './client';
|
|
7
|
+
export type { RAGConfig, RAGQueryOptions, RAGResponse, } from './types';
|
|
8
|
+
export { RAGError, ValidationError, ExecutionError } from './types';
|
|
9
|
+
export declare const VERSION = "1.0.0";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,YAAY,EACV,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEpE,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AutoCoder RAG SDK for Node.js
|
|
4
|
+
*
|
|
5
|
+
* 一个便于在Node.js代码中调用auto-coder.rag run功能的SDK。
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.VERSION = exports.ExecutionError = exports.ValidationError = exports.RAGError = exports.AutoCoderRAGClient = void 0;
|
|
9
|
+
var client_1 = require("./client");
|
|
10
|
+
Object.defineProperty(exports, "AutoCoderRAGClient", { enumerable: true, get: function () { return client_1.AutoCoderRAGClient; } });
|
|
11
|
+
var types_1 = require("./types");
|
|
12
|
+
Object.defineProperty(exports, "RAGError", { enumerable: true, get: function () { return types_1.RAGError; } });
|
|
13
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return types_1.ValidationError; } });
|
|
14
|
+
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return types_1.ExecutionError; } });
|
|
15
|
+
exports.VERSION = '1.0.0';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAM3B,iCAAoE;AAA3D,iGAAA,QAAQ,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,uGAAA,cAAc,OAAA;AAErC,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoCoder RAG SDK 类型定义
|
|
3
|
+
*/
|
|
4
|
+
export declare class RAGError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class ValidationError extends RAGError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class ExecutionError extends RAGError {
|
|
11
|
+
readonly exitCode?: number;
|
|
12
|
+
constructor(message: string, exitCode?: number);
|
|
13
|
+
}
|
|
14
|
+
export interface RAGConfig {
|
|
15
|
+
docDir: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
ragContextWindowLimit?: number;
|
|
19
|
+
fullTextRatio?: number;
|
|
20
|
+
segmentRatio?: number;
|
|
21
|
+
ragDocFilterRelevance?: number;
|
|
22
|
+
agentic?: boolean;
|
|
23
|
+
productMode?: 'lite' | 'pro';
|
|
24
|
+
enableHybridIndex?: boolean;
|
|
25
|
+
disableAutoWindow?: boolean;
|
|
26
|
+
disableSegmentReorder?: boolean;
|
|
27
|
+
recallModel?: string;
|
|
28
|
+
chunkModel?: string;
|
|
29
|
+
qaModel?: string;
|
|
30
|
+
embModel?: string;
|
|
31
|
+
agenticModel?: string;
|
|
32
|
+
contextPruneModel?: string;
|
|
33
|
+
tokenizerPath?: string;
|
|
34
|
+
requiredExts?: string;
|
|
35
|
+
rayAddress?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RAGQueryOptions {
|
|
38
|
+
outputFormat?: 'text' | 'json' | 'stream-json';
|
|
39
|
+
agentic?: boolean;
|
|
40
|
+
productMode?: 'lite' | 'pro';
|
|
41
|
+
model?: string;
|
|
42
|
+
timeout?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface RAGResponse {
|
|
45
|
+
success: boolean;
|
|
46
|
+
answer: string;
|
|
47
|
+
contexts?: string[];
|
|
48
|
+
error?: string;
|
|
49
|
+
metadata?: Record<string, any>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAK/C;AAED,MAAM,WAAW,SAAS;IAExB,MAAM,EAAE,MAAM,CAAC;IAGf,KAAK,CAA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ChC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AutoCoder RAG SDK 类型定义
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExecutionError = exports.ValidationError = exports.RAGError = void 0;
|
|
7
|
+
class RAGError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'RAGError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.RAGError = RAGError;
|
|
14
|
+
class ValidationError extends RAGError {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'ValidationError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ValidationError = ValidationError;
|
|
21
|
+
class ExecutionError extends RAGError {
|
|
22
|
+
constructor(message, exitCode) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'ExecutionError';
|
|
25
|
+
this.exitCode = exitCode;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ExecutionError = ExecutionError;
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AALD,4BAKC;AAED,MAAa,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,cAAe,SAAQ,QAAQ;IAG1C,YAAY,OAAe,EAAE,QAAiB;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AARD,wCAQC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "autocoder-rag-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Node.js SDK for AutoCoder RAG - 便于在Node.js代码中调用auto-coder.rag run功能",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"dev": "tsx --watch examples/basic-usage.ts",
|
|
15
|
+
"example:basic": "tsx examples/basic-usage.ts",
|
|
16
|
+
"example:stream": "tsx examples/stream-usage.ts",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"autocoder",
|
|
21
|
+
"rag",
|
|
22
|
+
"sdk",
|
|
23
|
+
"document-qa",
|
|
24
|
+
"ai",
|
|
25
|
+
"nodejs",
|
|
26
|
+
"typescript"
|
|
27
|
+
],
|
|
28
|
+
"author": "AutoCoder Team <support@autocoder.com>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/allwefantasy/auto-coder.git",
|
|
33
|
+
"directory": "rag-sdks/nodejs"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/allwefantasy/auto-coder/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/allwefantasy/auto-coder/tree/master/rag-sdks/nodejs",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=14.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"tsx": "^4.0.0",
|
|
45
|
+
"typescript": "^5.0.0"
|
|
46
|
+
},
|
|
47
|
+
"packageManager": "pnpm@10.12.1"
|
|
48
|
+
}
|
|
49
|
+
|