@kelvinjhu/lexiang-search 1.0.0
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/README.md +224 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +40 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants/api.constants.d.ts +21 -0
- package/dist/constants/api.constants.d.ts.map +1 -0
- package/dist/constants/api.constants.js +45 -0
- package/dist/constants/api.constants.js.map +1 -0
- package/dist/dto/ai-qa-request.dto.d.ts +32 -0
- package/dist/dto/ai-qa-request.dto.d.ts.map +1 -0
- package/dist/dto/ai-qa-request.dto.js +134 -0
- package/dist/dto/ai-qa-request.dto.js.map +1 -0
- package/dist/dto/ai-qa-response.dto.d.ts +46 -0
- package/dist/dto/ai-qa-response.dto.d.ts.map +1 -0
- package/dist/dto/ai-qa-response.dto.js +57 -0
- package/dist/dto/ai-qa-response.dto.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +120 -0
- package/dist/server.js.map +1 -0
- package/dist/services/ai-qa.service.d.ts +21 -0
- package/dist/services/ai-qa.service.d.ts.map +1 -0
- package/dist/services/ai-qa.service.js +81 -0
- package/dist/services/ai-qa.service.js.map +1 -0
- package/dist/services/lexiang-api.service.d.ts +41 -0
- package/dist/services/lexiang-api.service.d.ts.map +1 -0
- package/dist/services/lexiang-api.service.js +184 -0
- package/dist/services/lexiang-api.service.js.map +1 -0
- package/dist/tools/ai-qa-stream.tool.d.ts +91 -0
- package/dist/tools/ai-qa-stream.tool.d.ts.map +1 -0
- package/dist/tools/ai-qa-stream.tool.js +171 -0
- package/dist/tools/ai-qa-stream.tool.js.map +1 -0
- package/dist/tools/ai-qa.tool.d.ts +87 -0
- package/dist/tools/ai-qa.tool.d.ts.map +1 -0
- package/dist/tools/ai-qa.tool.js +118 -0
- package/dist/tools/ai-qa.tool.js.map +1 -0
- package/dist/types/lexiang-api.types.d.ts +78 -0
- package/dist/types/lexiang-api.types.d.ts.map +1 -0
- package/dist/types/lexiang-api.types.js +6 -0
- package/dist/types/lexiang-api.types.js.map +1 -0
- package/dist/types/mcp.types.d.ts +41 -0
- package/dist/types/mcp.types.d.ts.map +1 -0
- package/dist/types/mcp.types.js +6 -0
- package/dist/types/mcp.types.js.map +1 -0
- package/dist/utils/error-handler.d.ts +45 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +108 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +51 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validator.d.ts +20 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +76 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# 乐享知识库AI问答 MCP服务器
|
|
2
|
+
|
|
3
|
+
乐享知识库AI问答MCP服务器,基于Model Context Protocol(MCP)标准,提供AI问答功能。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- ✅ 支持非流式完整问答
|
|
8
|
+
- ✅ 支持SSE流式实时问答
|
|
9
|
+
- ✅ 支持多轮对话上下文管理
|
|
10
|
+
- ✅ 支持多种问答模式(普通/深度思考/专业研究)
|
|
11
|
+
- ✅ 支持知识范围限制(团队/知识库/知识节点)
|
|
12
|
+
- ✅ 完整的TypeScript类型定义
|
|
13
|
+
- ✅ 严格的参数校验
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @mcp/lexiang-search
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 配置
|
|
22
|
+
|
|
23
|
+
### 1. 环境变量(可选)
|
|
24
|
+
|
|
25
|
+
创建 `.env` 文件:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
LEXIANG_APP_KEY=your_app_key
|
|
29
|
+
LEXIANG_APP_SECRET=your_app_secret
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. MCP服务器配置
|
|
33
|
+
|
|
34
|
+
在调用方项目中配置MCP服务器:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"lexiang-qa": {
|
|
40
|
+
"command": "mcp-lexiang-search",
|
|
41
|
+
"args": []
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 使用方法
|
|
48
|
+
|
|
49
|
+
### 非流式问答
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
53
|
+
|
|
54
|
+
const client = new Client();
|
|
55
|
+
await client.connect('lexiang-qa');
|
|
56
|
+
|
|
57
|
+
// 调用工具
|
|
58
|
+
const result = await client.callTool({
|
|
59
|
+
name: 'ai_qa',
|
|
60
|
+
arguments: {
|
|
61
|
+
app_key: 'your_app_key',
|
|
62
|
+
app_secret: 'your_app_secret',
|
|
63
|
+
query: '乐享是什么?',
|
|
64
|
+
targets: [
|
|
65
|
+
{
|
|
66
|
+
type: 'team',
|
|
67
|
+
id: '74d76195adxxxxxxd49239d56e44f'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
qa_mode: 'normal'
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(result);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 流式问答
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const result = await client.callTool({
|
|
81
|
+
name: 'ai_qa_stream',
|
|
82
|
+
arguments: {
|
|
83
|
+
app_key: 'your_app_key',
|
|
84
|
+
app_secret: 'your_app_secret',
|
|
85
|
+
query: '介绍一下乐享的功能',
|
|
86
|
+
targets: [
|
|
87
|
+
{
|
|
88
|
+
type: 'space',
|
|
89
|
+
id: 'space_id_123'
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
qa_mode: 'reasoning'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// 处理流式响应
|
|
97
|
+
for await (const chunk of result) {
|
|
98
|
+
process.stdout.write(chunk.content);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 多轮对话
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// 第一轮问答
|
|
106
|
+
const result1 = await client.callTool({
|
|
107
|
+
name: 'ai_qa',
|
|
108
|
+
arguments: {
|
|
109
|
+
app_key: 'your_app_key',
|
|
110
|
+
app_secret: 'your_app_secret',
|
|
111
|
+
query: '乐享有哪些功能?',
|
|
112
|
+
targets: [{ type: 'team', id: 'team_id' }]
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const sessionId = result1.data.session_id;
|
|
117
|
+
|
|
118
|
+
// 第二轮问答(带上session_id)
|
|
119
|
+
const result2 = await client.callTool({
|
|
120
|
+
name: 'ai_qa',
|
|
121
|
+
arguments: {
|
|
122
|
+
app_key: 'your_app_key',
|
|
123
|
+
app_secret: 'your_app_secret',
|
|
124
|
+
query: '这些功能是怎么收费的?',
|
|
125
|
+
session_id: sessionId,
|
|
126
|
+
targets: [{ type: 'team', id: 'team_id' }]
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 工具参数
|
|
132
|
+
|
|
133
|
+
### ai_qa / ai_qa_stream
|
|
134
|
+
|
|
135
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
136
|
+
|--------|------|------|------|
|
|
137
|
+
| app_key | string | 是 | 乐享应用Key |
|
|
138
|
+
| app_secret | string | 是 | 乐享应用密钥 |
|
|
139
|
+
| query | string | 是 | 用户问题,最长1024字符 |
|
|
140
|
+
| targets | array | 是 | 知识范围数组,最多20个对象 |
|
|
141
|
+
| targets[].type | enum | 是 | space/team/team_code/kb_entry |
|
|
142
|
+
| targets[].id | string | 是 | 对应类型的实体ID |
|
|
143
|
+
| session_id | string | 否 | 会话ID,40字符,用于多轮对话 |
|
|
144
|
+
| new_session | boolean | 否 | 是否开启新会话,默认false |
|
|
145
|
+
| qa_mode | string | 否 | 问答模式,默认normal |
|
|
146
|
+
| skip_faq | boolean | 否 | 是否跳过FAQ,默认false |
|
|
147
|
+
| max_chars | number | 否 | 回答字数限制 |
|
|
148
|
+
| language | string | 否 | 语言,默认zh-CN |
|
|
149
|
+
|
|
150
|
+
### qa_mode 可选值
|
|
151
|
+
|
|
152
|
+
- `normal` - 默认模型快速回答
|
|
153
|
+
- `normal-ds-v3` - deepseek-v3-0324模型快速回答
|
|
154
|
+
- `normal-ds-v3.1` - deepseek-v3.1模型快速回答
|
|
155
|
+
- `normal-ds-v3.2` - deepseek-v3.2模型快速回答
|
|
156
|
+
- `reasoning` - deepseek-r1-0528模型深度思考
|
|
157
|
+
- `reasoning-ds-v3.1` - deepseek-v3.1-terminus-think模型深度思考
|
|
158
|
+
- `reasoning-ds-v3.2` - deepseek-v3.2-think模型深度思考
|
|
159
|
+
- `research` - deepseek-r1-0528模型专业研究
|
|
160
|
+
- `research-ds-v3.1` - deepseek-v3.1-terminus-think模型专业研究
|
|
161
|
+
- `research-ds-v3.2` - deepseek-v3.2-think模型专业研究
|
|
162
|
+
|
|
163
|
+
## 响应数据
|
|
164
|
+
|
|
165
|
+
### 非流式响应
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
{
|
|
169
|
+
"content": "腾讯乐享是腾讯公司推出的……",
|
|
170
|
+
"answer_source": "internal",
|
|
171
|
+
"session_id": "cc77ca018fe67dcb581f3b3c460894dedb9f6b80",
|
|
172
|
+
"reasoning_content": "嗯,用户询问\"乐享是什么?\"……",
|
|
173
|
+
"additional_content": {
|
|
174
|
+
"generated_question": "",
|
|
175
|
+
"reference_chunks": [
|
|
176
|
+
{
|
|
177
|
+
"content": "腾讯乐享是腾讯推出的……",
|
|
178
|
+
"target_id": "5dc00bd321a24568bb4787dec964cde2",
|
|
179
|
+
"target_type": "kb_entry",
|
|
180
|
+
"title": "腾讯乐享介绍",
|
|
181
|
+
"url": "/pages/5dc00bd321a24568bb4787dec964cde2"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"reference_docs": [
|
|
185
|
+
{
|
|
186
|
+
"title": "腾讯乐享介绍",
|
|
187
|
+
"url": "/pages/5dc00bd321a24568bb4787dec964cde2"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## 开发
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# 安装依赖
|
|
198
|
+
npm install
|
|
199
|
+
|
|
200
|
+
# 开发模式
|
|
201
|
+
npm run dev
|
|
202
|
+
|
|
203
|
+
# 构建
|
|
204
|
+
npm run build
|
|
205
|
+
|
|
206
|
+
# 测试
|
|
207
|
+
npm test
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 技术栈
|
|
211
|
+
|
|
212
|
+
- Node.js (LTS 18.x+)
|
|
213
|
+
- TypeScript 5.x (strict模式)
|
|
214
|
+
- Model Context Protocol (MCP)
|
|
215
|
+
- axios
|
|
216
|
+
- class-validator
|
|
217
|
+
|
|
218
|
+
## 许可证
|
|
219
|
+
|
|
220
|
+
MIT
|
|
221
|
+
|
|
222
|
+
## 文档
|
|
223
|
+
|
|
224
|
+
完整设计文档请查看 [DESIGN.md](./DESIGN.md)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* CLI入口文件
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const server_1 = require("./server");
|
|
8
|
+
const logger_1 = require("./utils/logger");
|
|
9
|
+
/**
|
|
10
|
+
* 启动MCP服务器
|
|
11
|
+
*/
|
|
12
|
+
async function main() {
|
|
13
|
+
const server = new server_1.LexiangMcpServer();
|
|
14
|
+
// 优雅关闭处理
|
|
15
|
+
const shutdown = async (signal) => {
|
|
16
|
+
logger_1.logger.info(`Received ${signal}, shutting down gracefully...`);
|
|
17
|
+
await server.stop();
|
|
18
|
+
process.exit(0);
|
|
19
|
+
};
|
|
20
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
21
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
22
|
+
// 未处理的Promise拒绝
|
|
23
|
+
process.on('unhandledRejection', (reason) => {
|
|
24
|
+
logger_1.logger.error('Unhandled Rejection', { reason });
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
// 未捕获的异常
|
|
28
|
+
process.on('uncaughtException', (error) => {
|
|
29
|
+
logger_1.logger.error('Uncaught Exception', { error });
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
// 启动服务器
|
|
33
|
+
await server.start();
|
|
34
|
+
}
|
|
35
|
+
// 启动应用
|
|
36
|
+
main().catch((error) => {
|
|
37
|
+
logger_1.logger.error('Fatal error', { error });
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";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AAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API常量定义
|
|
3
|
+
*/
|
|
4
|
+
export declare const LEXIANG_API_CONFIG: {
|
|
5
|
+
readonly BASE_URL: "https://lxapi.lexiangla.com";
|
|
6
|
+
readonly API_PATH: "/cgi-bin/v1/ai/qa";
|
|
7
|
+
readonly TOKEN_PATH: "/cgi-bin/token";
|
|
8
|
+
};
|
|
9
|
+
export declare const TIMEOUT_CONFIG: {
|
|
10
|
+
readonly DEFAULT: number;
|
|
11
|
+
readonly STREAM: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const TOKEN_CACHE_TTL: number;
|
|
14
|
+
export declare const SUPPORTED_QA_MODES: readonly ["normal", "normal-ds-v3", "normal-ds-v3.1", "normal-ds-v3.2", "reasoning", "reasoning-ds-v3.1", "reasoning-ds-v3.2", "research", "research-ds-v3.1", "research-ds-v3.2"];
|
|
15
|
+
export declare const SUPPORTED_TARGET_TYPES: readonly ["space", "team", "team_code", "kb_entry"];
|
|
16
|
+
export declare const DEFAULT_LANGUAGE = "zh-CN";
|
|
17
|
+
export declare const ANONYMOUS_STAFF_ID = "system-bot";
|
|
18
|
+
export declare const MAX_TARGETS_COUNT = 20;
|
|
19
|
+
export declare const SESSION_ID_LENGTH = 40;
|
|
20
|
+
export declare const MAX_QUERY_LENGTH = 1024;
|
|
21
|
+
//# sourceMappingURL=api.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.constants.d.ts","sourceRoot":"","sources":["../../src/constants/api.constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAGX,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAGX,eAAO,MAAM,eAAe,QAAsD,CAAC;AAGnF,eAAO,MAAM,kBAAkB,oLAWrB,CAAC;AAGX,eAAO,MAAM,sBAAsB,qDAAsD,CAAC;AAG1F,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAGxC,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAG/C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAGpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAGpC,eAAO,MAAM,gBAAgB,OAAO,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API常量定义
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MAX_QUERY_LENGTH = exports.SESSION_ID_LENGTH = exports.MAX_TARGETS_COUNT = exports.ANONYMOUS_STAFF_ID = exports.DEFAULT_LANGUAGE = exports.SUPPORTED_TARGET_TYPES = exports.SUPPORTED_QA_MODES = exports.TOKEN_CACHE_TTL = exports.TIMEOUT_CONFIG = exports.LEXIANG_API_CONFIG = void 0;
|
|
7
|
+
// 乐享API配置
|
|
8
|
+
exports.LEXIANG_API_CONFIG = {
|
|
9
|
+
BASE_URL: 'https://lxapi.lexiangla.com',
|
|
10
|
+
API_PATH: '/cgi-bin/v1/ai/qa',
|
|
11
|
+
TOKEN_PATH: '/cgi-bin/token',
|
|
12
|
+
};
|
|
13
|
+
// 请求超时配置(毫秒)
|
|
14
|
+
exports.TIMEOUT_CONFIG = {
|
|
15
|
+
DEFAULT: parseInt(process.env.REQUEST_TIMEOUT || '30000', 10),
|
|
16
|
+
STREAM: parseInt(process.env.STREAM_TIMEOUT || '60000', 10),
|
|
17
|
+
};
|
|
18
|
+
// Token缓存TTL(秒)
|
|
19
|
+
exports.TOKEN_CACHE_TTL = parseInt(process.env.TOKEN_CACHE_TTL || '3600', 10);
|
|
20
|
+
// 支持的问答模式
|
|
21
|
+
exports.SUPPORTED_QA_MODES = [
|
|
22
|
+
'normal',
|
|
23
|
+
'normal-ds-v3',
|
|
24
|
+
'normal-ds-v3.1',
|
|
25
|
+
'normal-ds-v3.2',
|
|
26
|
+
'reasoning',
|
|
27
|
+
'reasoning-ds-v3.1',
|
|
28
|
+
'reasoning-ds-v3.2',
|
|
29
|
+
'research',
|
|
30
|
+
'research-ds-v3.1',
|
|
31
|
+
'research-ds-v3.2',
|
|
32
|
+
];
|
|
33
|
+
// 支持的目标类型
|
|
34
|
+
exports.SUPPORTED_TARGET_TYPES = ['space', 'team', 'team_code', 'kb_entry'];
|
|
35
|
+
// 默认语言
|
|
36
|
+
exports.DEFAULT_LANGUAGE = 'zh-CN';
|
|
37
|
+
// 匿名用户ID
|
|
38
|
+
exports.ANONYMOUS_STAFF_ID = 'system-bot';
|
|
39
|
+
// 最大目标数量
|
|
40
|
+
exports.MAX_TARGETS_COUNT = 20;
|
|
41
|
+
// Session ID长度
|
|
42
|
+
exports.SESSION_ID_LENGTH = 40;
|
|
43
|
+
// Query最大长度
|
|
44
|
+
exports.MAX_QUERY_LENGTH = 1024;
|
|
45
|
+
//# sourceMappingURL=api.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.constants.js","sourceRoot":"","sources":["../../src/constants/api.constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,UAAU;AACG,QAAA,kBAAkB,GAAG;IAChC,QAAQ,EAAE,6BAA6B;IACvC,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,gBAAgB;CACpB,CAAC;AAEX,aAAa;AACA,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,EAAE,EAAE,CAAC;IAC7D,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,EAAE,EAAE,CAAC;CACnD,CAAC;AAEX,gBAAgB;AACH,QAAA,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;AAEnF,UAAU;AACG,QAAA,kBAAkB,GAAG;IAChC,QAAQ;IACR,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,mBAAmB;IACnB,UAAU;IACV,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AAEX,UAAU;AACG,QAAA,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAU,CAAC;AAE1F,OAAO;AACM,QAAA,gBAAgB,GAAG,OAAO,CAAC;AAExC,SAAS;AACI,QAAA,kBAAkB,GAAG,YAAY,CAAC;AAE/C,SAAS;AACI,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC,eAAe;AACF,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC,YAAY;AACC,QAAA,gBAAgB,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI问答请求DTO
|
|
3
|
+
*/
|
|
4
|
+
import { SUPPORTED_QA_MODES } from '../constants/api.constants';
|
|
5
|
+
import type { AiQaRequest } from '../types/lexiang-api.types';
|
|
6
|
+
/**
|
|
7
|
+
* 知识范围目标DTO
|
|
8
|
+
*/
|
|
9
|
+
export declare class TargetDto {
|
|
10
|
+
type: 'space' | 'team' | 'team_code' | 'kb_entry';
|
|
11
|
+
id: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* AI问答请求DTO
|
|
15
|
+
*/
|
|
16
|
+
export declare class AiQaRequestDto {
|
|
17
|
+
query: string;
|
|
18
|
+
app_key: string;
|
|
19
|
+
app_secret: string;
|
|
20
|
+
targets: TargetDto[];
|
|
21
|
+
session_id?: string;
|
|
22
|
+
new_session?: boolean;
|
|
23
|
+
qa_mode?: (typeof SUPPORTED_QA_MODES)[number];
|
|
24
|
+
skip_faq?: boolean;
|
|
25
|
+
max_chars?: number;
|
|
26
|
+
language?: string;
|
|
27
|
+
/**
|
|
28
|
+
* 转换为乐享API请求格式
|
|
29
|
+
*/
|
|
30
|
+
toLexiangRequest(): AiQaRequest;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ai-qa-request.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-qa-request.dto.d.ts","sourceRoot":"","sources":["../../src/dto/ai-qa-request.dto.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,OAAO,EAAE,kBAAkB,EAA4C,MAAM,4BAA4B,CAAC;AAC1G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,qBAAa,SAAS;IAEpB,IAAI,EAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;IAInD,EAAE,EAAG,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,cAAc;IAIzB,KAAK,EAAG,MAAM,CAAC;IAIf,OAAO,EAAG,MAAM,CAAC;IAIjB,UAAU,EAAG,MAAM,CAAC;IAOpB,OAAO,EAAG,SAAS,EAAE,CAAC;IAKtB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,OAAO,CAAC,EAAE,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;IAI9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,gBAAgB,IAAI,WAAW;CA6BhC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI问答请求DTO
|
|
4
|
+
*/
|
|
5
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
+
};
|
|
11
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AiQaRequestDto = exports.TargetDto = void 0;
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
const class_transformer_1 = require("class-transformer");
|
|
18
|
+
const api_constants_1 = require("../constants/api.constants");
|
|
19
|
+
/**
|
|
20
|
+
* 知识范围目标DTO
|
|
21
|
+
*/
|
|
22
|
+
class TargetDto {
|
|
23
|
+
type;
|
|
24
|
+
id;
|
|
25
|
+
}
|
|
26
|
+
exports.TargetDto = TargetDto;
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsIn)([...api_constants_1.SUPPORTED_TARGET_TYPES]),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], TargetDto.prototype, "type", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], TargetDto.prototype, "id", void 0);
|
|
36
|
+
/**
|
|
37
|
+
* AI问答请求DTO
|
|
38
|
+
*/
|
|
39
|
+
class AiQaRequestDto {
|
|
40
|
+
query;
|
|
41
|
+
app_key;
|
|
42
|
+
app_secret;
|
|
43
|
+
targets;
|
|
44
|
+
session_id;
|
|
45
|
+
new_session;
|
|
46
|
+
qa_mode;
|
|
47
|
+
skip_faq;
|
|
48
|
+
max_chars;
|
|
49
|
+
language;
|
|
50
|
+
/**
|
|
51
|
+
* 转换为乐享API请求格式
|
|
52
|
+
*/
|
|
53
|
+
toLexiangRequest() {
|
|
54
|
+
const request = {
|
|
55
|
+
query: this.query,
|
|
56
|
+
targets: this.targets,
|
|
57
|
+
language: this.language || api_constants_1.DEFAULT_LANGUAGE,
|
|
58
|
+
};
|
|
59
|
+
if (this.session_id) {
|
|
60
|
+
request.session_id = this.session_id;
|
|
61
|
+
}
|
|
62
|
+
if (this.new_session !== undefined) {
|
|
63
|
+
request.new_session = this.new_session;
|
|
64
|
+
}
|
|
65
|
+
if (this.qa_mode) {
|
|
66
|
+
request.qa_mode = this.qa_mode;
|
|
67
|
+
}
|
|
68
|
+
if (this.skip_faq !== undefined) {
|
|
69
|
+
request.skip_faq = this.skip_faq;
|
|
70
|
+
}
|
|
71
|
+
if (this.max_chars !== undefined) {
|
|
72
|
+
request.max_chars = this.max_chars;
|
|
73
|
+
}
|
|
74
|
+
return request;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.AiQaRequestDto = AiQaRequestDto;
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, class_validator_1.IsString)(),
|
|
80
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
81
|
+
(0, class_validator_1.MaxLength)(1024),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], AiQaRequestDto.prototype, "query", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, class_validator_1.IsString)(),
|
|
86
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], AiQaRequestDto.prototype, "app_key", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, class_validator_1.IsString)(),
|
|
91
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], AiQaRequestDto.prototype, "app_secret", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, class_validator_1.IsArray)(),
|
|
96
|
+
(0, class_validator_1.ArrayMinSize)(1),
|
|
97
|
+
(0, class_validator_1.ArrayMaxSize)(20),
|
|
98
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
99
|
+
(0, class_transformer_1.Type)(() => TargetDto),
|
|
100
|
+
__metadata("design:type", Array)
|
|
101
|
+
], AiQaRequestDto.prototype, "targets", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, class_validator_1.IsOptional)(),
|
|
104
|
+
(0, class_validator_1.IsString)(),
|
|
105
|
+
(0, class_validator_1.Length)(40, 40),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], AiQaRequestDto.prototype, "session_id", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, class_validator_1.IsOptional)(),
|
|
110
|
+
(0, class_validator_1.IsBoolean)(),
|
|
111
|
+
__metadata("design:type", Boolean)
|
|
112
|
+
], AiQaRequestDto.prototype, "new_session", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, class_validator_1.IsOptional)(),
|
|
115
|
+
(0, class_validator_1.IsIn)([...api_constants_1.SUPPORTED_QA_MODES]),
|
|
116
|
+
__metadata("design:type", Object)
|
|
117
|
+
], AiQaRequestDto.prototype, "qa_mode", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, class_validator_1.IsOptional)(),
|
|
120
|
+
(0, class_validator_1.IsBoolean)(),
|
|
121
|
+
__metadata("design:type", Boolean)
|
|
122
|
+
], AiQaRequestDto.prototype, "skip_faq", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, class_validator_1.IsOptional)(),
|
|
125
|
+
(0, class_validator_1.IsInt)(),
|
|
126
|
+
(0, class_validator_1.Min)(1),
|
|
127
|
+
__metadata("design:type", Number)
|
|
128
|
+
], AiQaRequestDto.prototype, "max_chars", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
(0, class_validator_1.IsOptional)(),
|
|
131
|
+
(0, class_validator_1.IsString)(),
|
|
132
|
+
__metadata("design:type", String)
|
|
133
|
+
], AiQaRequestDto.prototype, "language", void 0);
|
|
134
|
+
//# sourceMappingURL=ai-qa-request.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-qa-request.dto.js","sourceRoot":"","sources":["../../src/dto/ai-qa-request.dto.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;AAEH,qDAcyB;AACzB,yDAAyC;AACzC,8DAA0G;AAG1G;;GAEG;AACH,MAAa,SAAS;IAEpB,IAAI,CAA+C;IAInD,EAAE,CAAU;CACb;AAPD,8BAOC;AALC;IADC,IAAA,sBAAI,EAAC,CAAC,GAAG,sCAAsB,CAAC,CAAC;;uCACiB;AAInD;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qCACD;AAGd;;GAEG;AACH,MAAa,cAAc;IAIzB,KAAK,CAAU;IAIf,OAAO,CAAU;IAIjB,UAAU,CAAU;IAOpB,OAAO,CAAe;IAKtB,UAAU,CAAU;IAIpB,WAAW,CAAW;IAItB,OAAO,CAAuC;IAI9C,QAAQ,CAAW;IAKnB,SAAS,CAAU;IAInB,QAAQ,CAAU;IAElB;;OAEG;IACH,gBAAgB;QACd,MAAM,OAAO,GAAgB;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,gCAAgB;SAC5C,CAAC;QAEF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACvC,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACzC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,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C,CAAC,CAAC;;iDACY;AAInB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACO"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI问答响应DTO
|
|
3
|
+
*/
|
|
4
|
+
export declare class ReferenceChunkDto {
|
|
5
|
+
content: string;
|
|
6
|
+
target_id: string;
|
|
7
|
+
target_type: string;
|
|
8
|
+
title: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ReferenceDocDto {
|
|
12
|
+
title: string;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class AdditionalContentDto {
|
|
16
|
+
generated_question: string;
|
|
17
|
+
reference_chunks: ReferenceChunkDto[];
|
|
18
|
+
reference_docs: ReferenceDocDto[];
|
|
19
|
+
}
|
|
20
|
+
export declare class AiQaResponseDataDto {
|
|
21
|
+
content: string;
|
|
22
|
+
answer_source: string;
|
|
23
|
+
session_id: string;
|
|
24
|
+
reasoning_content?: string;
|
|
25
|
+
additional_content: AdditionalContentDto;
|
|
26
|
+
}
|
|
27
|
+
export declare class AiQaResponseDto {
|
|
28
|
+
code: number;
|
|
29
|
+
message: string;
|
|
30
|
+
request_id: string;
|
|
31
|
+
data: AiQaResponseDataDto;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 转换为MCP响应格式
|
|
35
|
+
*/
|
|
36
|
+
export declare function toMcpResponse(data: AiQaResponseDataDto): {
|
|
37
|
+
content: string;
|
|
38
|
+
answer_source: string;
|
|
39
|
+
session_id: string;
|
|
40
|
+
reasoning_content?: string;
|
|
41
|
+
reference_docs?: Array<{
|
|
42
|
+
title: string;
|
|
43
|
+
url: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=ai-qa-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-qa-response.dto.d.ts","sourceRoot":"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
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AiQaResponseDto = exports.AiQaResponseDataDto = exports.AdditionalContentDto = exports.ReferenceDocDto = exports.ReferenceChunkDto = void 0;
|
|
7
|
+
exports.toMcpResponse = toMcpResponse;
|
|
8
|
+
class ReferenceChunkDto {
|
|
9
|
+
content;
|
|
10
|
+
target_id;
|
|
11
|
+
target_type;
|
|
12
|
+
title;
|
|
13
|
+
url;
|
|
14
|
+
}
|
|
15
|
+
exports.ReferenceChunkDto = ReferenceChunkDto;
|
|
16
|
+
class ReferenceDocDto {
|
|
17
|
+
title;
|
|
18
|
+
url;
|
|
19
|
+
}
|
|
20
|
+
exports.ReferenceDocDto = ReferenceDocDto;
|
|
21
|
+
class AdditionalContentDto {
|
|
22
|
+
generated_question;
|
|
23
|
+
reference_chunks;
|
|
24
|
+
reference_docs;
|
|
25
|
+
}
|
|
26
|
+
exports.AdditionalContentDto = AdditionalContentDto;
|
|
27
|
+
class AiQaResponseDataDto {
|
|
28
|
+
content;
|
|
29
|
+
answer_source;
|
|
30
|
+
session_id;
|
|
31
|
+
reasoning_content;
|
|
32
|
+
additional_content;
|
|
33
|
+
}
|
|
34
|
+
exports.AiQaResponseDataDto = AiQaResponseDataDto;
|
|
35
|
+
class AiQaResponseDto {
|
|
36
|
+
code;
|
|
37
|
+
message;
|
|
38
|
+
request_id;
|
|
39
|
+
data;
|
|
40
|
+
}
|
|
41
|
+
exports.AiQaResponseDto = AiQaResponseDto;
|
|
42
|
+
/**
|
|
43
|
+
* 转换为MCP响应格式
|
|
44
|
+
*/
|
|
45
|
+
function toMcpResponse(data) {
|
|
46
|
+
return {
|
|
47
|
+
content: data.content,
|
|
48
|
+
answer_source: data.answer_source,
|
|
49
|
+
session_id: data.session_id,
|
|
50
|
+
reasoning_content: data.reasoning_content,
|
|
51
|
+
reference_docs: data.additional_content.reference_docs.map((doc) => ({
|
|
52
|
+
title: doc.title,
|
|
53
|
+
url: doc.url,
|
|
54
|
+
})),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ai-qa-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-qa-response.dto.js","sourceRoot":"","sources":["../../src/dto/ai-qa-response.dto.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAuCH,sCAiBC;AAtDD,MAAa,iBAAiB;IAC5B,OAAO,CAAU;IACjB,SAAS,CAAU;IACnB,WAAW,CAAU;IACrB,KAAK,CAAU;IACf,GAAG,CAAU;CACd;AAND,8CAMC;AAED,MAAa,eAAe;IAC1B,KAAK,CAAU;IACf,GAAG,CAAU;CACd;AAHD,0CAGC;AAED,MAAa,oBAAoB;IAC/B,kBAAkB,CAAU;IAC5B,gBAAgB,CAAuB;IACvC,cAAc,CAAqB;CACpC;AAJD,oDAIC;AAED,MAAa,mBAAmB;IAC9B,OAAO,CAAU;IACjB,aAAa,CAAU;IACvB,UAAU,CAAU;IACpB,iBAAiB,CAAU;IAC3B,kBAAkB,CAAwB;CAC3C;AAND,kDAMC;AAED,MAAa,eAAe;IAC1B,IAAI,CAAU;IACd,OAAO,CAAU;IACjB,UAAU,CAAU;IACpB,IAAI,CAAuB;CAC5B;AALD,0CAKC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAyB;IAOrD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACnE,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,GAAG,EAAE,GAAG,CAAC,GAAG;SACb,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|