tabby-ai-assistant 1.0.12 → 1.0.13
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 +113 -55
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/services/core/config-provider.service.ts +4 -12
- package/src/services/providers/anthropic-provider.service.ts +0 -172
- package/src/services/providers/base-provider.service.ts +225 -14
- package/src/services/providers/glm-provider.service.ts +0 -195
- package/src/services/providers/minimax-provider.service.ts +0 -198
- package/src/services/providers/ollama-provider.service.ts +0 -160
- package/src/services/providers/openai-compatible.service.ts +1 -143
- package/src/services/providers/openai-provider.service.ts +1 -143
- package/src/services/providers/vllm-provider.service.ts +0 -160
- package/src/types/provider.types.ts +206 -75
- package/src/index.ts.backup +0 -165
- package/src/services/chat/chat-history.service.ts.backup +0 -239
- package/webpack.config.js.backup +0 -57
|
@@ -233,10 +233,6 @@ export class OpenAiCompatibleProviderService extends BaseAiProvider {
|
|
|
233
233
|
return result;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
protected getDefaultBaseURL(): string {
|
|
237
|
-
return 'http://localhost:11434/v1';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
236
|
protected transformMessages(messages: any[]): any[] {
|
|
241
237
|
return messages.map(msg => ({
|
|
242
238
|
role: msg.role,
|
|
@@ -262,142 +258,4 @@ export class OpenAiCompatibleProviderService extends BaseAiProvider {
|
|
|
262
258
|
} : undefined
|
|
263
259
|
};
|
|
264
260
|
}
|
|
265
|
-
|
|
266
|
-
private buildCommandPrompt(request: CommandRequest): string {
|
|
267
|
-
let prompt = `请将以下自然语言描述转换为准确的终端命令:\n\n"${request.naturalLanguage}"\n\n`;
|
|
268
|
-
|
|
269
|
-
if (request.context) {
|
|
270
|
-
prompt += `当前环境:\n`;
|
|
271
|
-
if (request.context.currentDirectory) {
|
|
272
|
-
prompt += `- 当前目录:${request.context.currentDirectory}\n`;
|
|
273
|
-
}
|
|
274
|
-
if (request.context.operatingSystem) {
|
|
275
|
-
prompt += `- 操作系统:${request.context.operatingSystem}\n`;
|
|
276
|
-
}
|
|
277
|
-
if (request.context.shell) {
|
|
278
|
-
prompt += `- Shell:${request.context.shell}\n`;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
prompt += `\n请直接返回JSON格式:\n`;
|
|
283
|
-
prompt += `{\n`;
|
|
284
|
-
prompt += ` "command": "具体命令",\n`;
|
|
285
|
-
prompt += ` "explanation": "命令解释",\n`;
|
|
286
|
-
prompt += ` "confidence": 0.95\n`;
|
|
287
|
-
prompt += `}\n`;
|
|
288
|
-
|
|
289
|
-
return prompt;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
private buildExplainPrompt(request: ExplainRequest): string {
|
|
293
|
-
let prompt = `请详细解释以下终端命令:\n\n\`${request.command}\`\n\n`;
|
|
294
|
-
|
|
295
|
-
if (request.context?.currentDirectory) {
|
|
296
|
-
prompt += `当前目录:${request.context.currentDirectory}\n`;
|
|
297
|
-
}
|
|
298
|
-
if (request.context?.operatingSystem) {
|
|
299
|
-
prompt += `操作系统:${request.context.operatingSystem}\n`;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
303
|
-
prompt += `{\n`;
|
|
304
|
-
prompt += ` "explanation": "整体解释",\n`;
|
|
305
|
-
prompt += ` "breakdown": [\n`;
|
|
306
|
-
prompt += ` {"part": "命令部分", "description": "说明"}\n`;
|
|
307
|
-
prompt += ` ],\n`;
|
|
308
|
-
prompt += ` "examples": ["使用示例"]\n`;
|
|
309
|
-
prompt += `}\n`;
|
|
310
|
-
|
|
311
|
-
return prompt;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
private buildAnalysisPrompt(request: AnalysisRequest): string {
|
|
315
|
-
let prompt = `请分析以下命令执行结果:\n\n`;
|
|
316
|
-
prompt += `命令:${request.command}\n`;
|
|
317
|
-
prompt += `退出码:${request.exitCode}\n`;
|
|
318
|
-
prompt += `输出:\n${request.output}\n\n`;
|
|
319
|
-
|
|
320
|
-
if (request.context?.workingDirectory) {
|
|
321
|
-
prompt += `工作目录:${request.context.workingDirectory}\n`;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
325
|
-
prompt += `{\n`;
|
|
326
|
-
prompt += ` "summary": "结果总结",\n`;
|
|
327
|
-
prompt += ` "insights": ["洞察1", "洞察2"],\n`;
|
|
328
|
-
prompt += ` "success": true/false,\n`;
|
|
329
|
-
prompt += ` "issues": [\n`;
|
|
330
|
-
prompt += ` {"severity": "warning|error|info", "message": "问题描述", "suggestion": "建议"}\n`;
|
|
331
|
-
prompt += ` ]\n`;
|
|
332
|
-
prompt += `}\n`;
|
|
333
|
-
|
|
334
|
-
return prompt;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private parseCommandResponse(content: string): CommandResponse {
|
|
338
|
-
try {
|
|
339
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
340
|
-
if (match) {
|
|
341
|
-
const parsed = JSON.parse(match[0]);
|
|
342
|
-
return {
|
|
343
|
-
command: parsed.command || '',
|
|
344
|
-
explanation: parsed.explanation || '',
|
|
345
|
-
confidence: parsed.confidence || 0.5
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
} catch (error) {
|
|
349
|
-
this.logger.warn('Failed to parse command response as JSON', error);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
const lines = content.split('\n').map(l => l.trim()).filter(l => l);
|
|
353
|
-
return {
|
|
354
|
-
command: lines[0] || '',
|
|
355
|
-
explanation: lines.slice(1).join(' ') || 'AI生成的命令',
|
|
356
|
-
confidence: 0.5
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
private parseExplainResponse(content: string): ExplainResponse {
|
|
361
|
-
try {
|
|
362
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
363
|
-
if (match) {
|
|
364
|
-
const parsed = JSON.parse(match[0]);
|
|
365
|
-
return {
|
|
366
|
-
explanation: parsed.explanation || '',
|
|
367
|
-
breakdown: parsed.breakdown || [],
|
|
368
|
-
examples: parsed.examples || []
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
} catch (error) {
|
|
372
|
-
this.logger.warn('Failed to parse explain response as JSON', error);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return {
|
|
376
|
-
explanation: content,
|
|
377
|
-
breakdown: []
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
private parseAnalysisResponse(content: string): AnalysisResponse {
|
|
382
|
-
try {
|
|
383
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
384
|
-
if (match) {
|
|
385
|
-
const parsed = JSON.parse(match[0]);
|
|
386
|
-
return {
|
|
387
|
-
summary: parsed.summary || '',
|
|
388
|
-
insights: parsed.insights || [],
|
|
389
|
-
success: parsed.success !== false,
|
|
390
|
-
issues: parsed.issues || []
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
} catch (error) {
|
|
394
|
-
this.logger.warn('Failed to parse analysis response as JSON', error);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return {
|
|
398
|
-
summary: content,
|
|
399
|
-
insights: [],
|
|
400
|
-
success: true
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
}
|
|
261
|
+
}
|
|
@@ -215,10 +215,6 @@ export class OpenAiProviderService extends BaseAiProvider {
|
|
|
215
215
|
return result;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
protected getDefaultBaseURL(): string {
|
|
219
|
-
return 'https://api.openai.com/v1';
|
|
220
|
-
}
|
|
221
|
-
|
|
222
218
|
protected transformMessages(messages: any[]): any[] {
|
|
223
219
|
return messages.map(msg => ({
|
|
224
220
|
role: msg.role,
|
|
@@ -244,142 +240,4 @@ export class OpenAiProviderService extends BaseAiProvider {
|
|
|
244
240
|
} : undefined
|
|
245
241
|
};
|
|
246
242
|
}
|
|
247
|
-
|
|
248
|
-
private buildCommandPrompt(request: CommandRequest): string {
|
|
249
|
-
let prompt = `请将以下自然语言描述转换为准确的终端命令:\n\n"${request.naturalLanguage}"\n\n`;
|
|
250
|
-
|
|
251
|
-
if (request.context) {
|
|
252
|
-
prompt += `当前环境:\n`;
|
|
253
|
-
if (request.context.currentDirectory) {
|
|
254
|
-
prompt += `- 当前目录:${request.context.currentDirectory}\n`;
|
|
255
|
-
}
|
|
256
|
-
if (request.context.operatingSystem) {
|
|
257
|
-
prompt += `- 操作系统:${request.context.operatingSystem}\n`;
|
|
258
|
-
}
|
|
259
|
-
if (request.context.shell) {
|
|
260
|
-
prompt += `- Shell:${request.context.shell}\n`;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
prompt += `\n请直接返回JSON格式:\n`;
|
|
265
|
-
prompt += `{\n`;
|
|
266
|
-
prompt += ` "command": "具体命令",\n`;
|
|
267
|
-
prompt += ` "explanation": "命令解释",\n`;
|
|
268
|
-
prompt += ` "confidence": 0.95\n`;
|
|
269
|
-
prompt += `}\n`;
|
|
270
|
-
|
|
271
|
-
return prompt;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
private buildExplainPrompt(request: ExplainRequest): string {
|
|
275
|
-
let prompt = `请详细解释以下终端命令:\n\n\`${request.command}\`\n\n`;
|
|
276
|
-
|
|
277
|
-
if (request.context?.currentDirectory) {
|
|
278
|
-
prompt += `当前目录:${request.context.currentDirectory}\n`;
|
|
279
|
-
}
|
|
280
|
-
if (request.context?.operatingSystem) {
|
|
281
|
-
prompt += `操作系统:${request.context.operatingSystem}\n`;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
285
|
-
prompt += `{\n`;
|
|
286
|
-
prompt += ` "explanation": "整体解释",\n`;
|
|
287
|
-
prompt += ` "breakdown": [\n`;
|
|
288
|
-
prompt += ` {"part": "命令部分", "description": "说明"}\n`;
|
|
289
|
-
prompt += ` ],\n`;
|
|
290
|
-
prompt += ` "examples": ["使用示例"]\n`;
|
|
291
|
-
prompt += `}\n`;
|
|
292
|
-
|
|
293
|
-
return prompt;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
private buildAnalysisPrompt(request: AnalysisRequest): string {
|
|
297
|
-
let prompt = `请分析以下命令执行结果:\n\n`;
|
|
298
|
-
prompt += `命令:${request.command}\n`;
|
|
299
|
-
prompt += `退出码:${request.exitCode}\n`;
|
|
300
|
-
prompt += `输出:\n${request.output}\n\n`;
|
|
301
|
-
|
|
302
|
-
if (request.context?.workingDirectory) {
|
|
303
|
-
prompt += `工作目录:${request.context.workingDirectory}\n`;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
307
|
-
prompt += `{\n`;
|
|
308
|
-
prompt += ` "summary": "结果总结",\n`;
|
|
309
|
-
prompt += ` "insights": ["洞察1", "洞察2"],\n`;
|
|
310
|
-
prompt += ` "success": true/false,\n`;
|
|
311
|
-
prompt += ` "issues": [\n`;
|
|
312
|
-
prompt += ` {"severity": "warning|error|info", "message": "问题描述", "suggestion": "建议"}\n`;
|
|
313
|
-
prompt += ` ]\n`;
|
|
314
|
-
prompt += `}\n`;
|
|
315
|
-
|
|
316
|
-
return prompt;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
private parseCommandResponse(content: string): CommandResponse {
|
|
320
|
-
try {
|
|
321
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
322
|
-
if (match) {
|
|
323
|
-
const parsed = JSON.parse(match[0]);
|
|
324
|
-
return {
|
|
325
|
-
command: parsed.command || '',
|
|
326
|
-
explanation: parsed.explanation || '',
|
|
327
|
-
confidence: parsed.confidence || 0.5
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
} catch (error) {
|
|
331
|
-
this.logger.warn('Failed to parse command response as JSON', error);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const lines = content.split('\n').map(l => l.trim()).filter(l => l);
|
|
335
|
-
return {
|
|
336
|
-
command: lines[0] || '',
|
|
337
|
-
explanation: lines.slice(1).join(' ') || 'AI生成的命令',
|
|
338
|
-
confidence: 0.5
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
private parseExplainResponse(content: string): ExplainResponse {
|
|
343
|
-
try {
|
|
344
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
345
|
-
if (match) {
|
|
346
|
-
const parsed = JSON.parse(match[0]);
|
|
347
|
-
return {
|
|
348
|
-
explanation: parsed.explanation || '',
|
|
349
|
-
breakdown: parsed.breakdown || [],
|
|
350
|
-
examples: parsed.examples || []
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
} catch (error) {
|
|
354
|
-
this.logger.warn('Failed to parse explain response as JSON', error);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return {
|
|
358
|
-
explanation: content,
|
|
359
|
-
breakdown: []
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
private parseAnalysisResponse(content: string): AnalysisResponse {
|
|
364
|
-
try {
|
|
365
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
366
|
-
if (match) {
|
|
367
|
-
const parsed = JSON.parse(match[0]);
|
|
368
|
-
return {
|
|
369
|
-
summary: parsed.summary || '',
|
|
370
|
-
insights: parsed.insights || [],
|
|
371
|
-
success: parsed.success !== false,
|
|
372
|
-
issues: parsed.issues || []
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
} catch (error) {
|
|
376
|
-
this.logger.warn('Failed to parse analysis response as JSON', error);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return {
|
|
380
|
-
summary: content,
|
|
381
|
-
insights: [],
|
|
382
|
-
success: true
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
}
|
|
243
|
+
}
|
|
@@ -28,10 +28,6 @@ export class VllmProviderService extends BaseAiProvider {
|
|
|
28
28
|
super(logger);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
protected getDefaultBaseURL(): string {
|
|
32
|
-
return 'http://localhost:8000/v1';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
31
|
/**
|
|
36
32
|
* 获取认证头
|
|
37
33
|
*/
|
|
@@ -304,160 +300,4 @@ export class VllmProviderService extends BaseAiProvider {
|
|
|
304
300
|
content: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)
|
|
305
301
|
}));
|
|
306
302
|
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* 构建命令生成提示
|
|
310
|
-
*/
|
|
311
|
-
private buildCommandPrompt(request: CommandRequest): string {
|
|
312
|
-
let prompt = `请将以下自然语言描述转换为准确的终端命令:\n\n"${request.naturalLanguage}"\n\n`;
|
|
313
|
-
|
|
314
|
-
if (request.context) {
|
|
315
|
-
prompt += `当前环境:\n`;
|
|
316
|
-
if (request.context.currentDirectory) {
|
|
317
|
-
prompt += `- 当前目录:${request.context.currentDirectory}\n`;
|
|
318
|
-
}
|
|
319
|
-
if (request.context.operatingSystem) {
|
|
320
|
-
prompt += `- 操作系统:${request.context.operatingSystem}\n`;
|
|
321
|
-
}
|
|
322
|
-
if (request.context.shell) {
|
|
323
|
-
prompt += `- Shell:${request.context.shell}\n`;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
prompt += `\n请直接返回JSON格式:\n`;
|
|
328
|
-
prompt += `{\n`;
|
|
329
|
-
prompt += ` "command": "具体命令",\n`;
|
|
330
|
-
prompt += ` "explanation": "命令解释",\n`;
|
|
331
|
-
prompt += ` "confidence": 0.95\n`;
|
|
332
|
-
prompt += `}\n`;
|
|
333
|
-
|
|
334
|
-
return prompt;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* 构建命令解释提示
|
|
339
|
-
*/
|
|
340
|
-
private buildExplainPrompt(request: ExplainRequest): string {
|
|
341
|
-
let prompt = `请详细解释以下终端命令:\n\n\`${request.command}\`\n\n`;
|
|
342
|
-
|
|
343
|
-
if (request.context?.currentDirectory) {
|
|
344
|
-
prompt += `当前目录:${request.context.currentDirectory}\n`;
|
|
345
|
-
}
|
|
346
|
-
if (request.context?.operatingSystem) {
|
|
347
|
-
prompt += `操作系统:${request.context.operatingSystem}\n`;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
351
|
-
prompt += `{\n`;
|
|
352
|
-
prompt += ` "explanation": "整体解释",\n`;
|
|
353
|
-
prompt += ` "breakdown": [\n`;
|
|
354
|
-
prompt += ` {"part": "命令部分", "description": "说明"}\n`;
|
|
355
|
-
prompt += ` ],\n`;
|
|
356
|
-
prompt += ` "examples": ["使用示例"]\n`;
|
|
357
|
-
prompt += `}\n`;
|
|
358
|
-
|
|
359
|
-
return prompt;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* 构建结果分析提示
|
|
364
|
-
*/
|
|
365
|
-
private buildAnalysisPrompt(request: AnalysisRequest): string {
|
|
366
|
-
let prompt = `请分析以下命令执行结果:\n\n`;
|
|
367
|
-
prompt += `命令:${request.command}\n`;
|
|
368
|
-
prompt += `退出码:${request.exitCode}\n`;
|
|
369
|
-
prompt += `输出:\n${request.output}\n\n`;
|
|
370
|
-
|
|
371
|
-
if (request.context?.workingDirectory) {
|
|
372
|
-
prompt += `工作目录:${request.context.workingDirectory}\n`;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
prompt += `\n请按以下JSON格式返回:\n`;
|
|
376
|
-
prompt += `{\n`;
|
|
377
|
-
prompt += ` "summary": "结果总结",\n`;
|
|
378
|
-
prompt += ` "insights": ["洞察1", "洞察2"],\n`;
|
|
379
|
-
prompt += ` "success": true/false,\n`;
|
|
380
|
-
prompt += ` "issues": [\n`;
|
|
381
|
-
prompt += ` {"severity": "warning|error|info", "message": "问题描述", "suggestion": "建议"}\n`;
|
|
382
|
-
prompt += ` ]\n`;
|
|
383
|
-
prompt += `}\n`;
|
|
384
|
-
|
|
385
|
-
return prompt;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* 解析命令响应
|
|
390
|
-
*/
|
|
391
|
-
private parseCommandResponse(content: string): CommandResponse {
|
|
392
|
-
try {
|
|
393
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
394
|
-
if (match) {
|
|
395
|
-
const parsed = JSON.parse(match[0]);
|
|
396
|
-
return {
|
|
397
|
-
command: parsed.command || '',
|
|
398
|
-
explanation: parsed.explanation || '',
|
|
399
|
-
confidence: parsed.confidence || 0.5
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
} catch (error) {
|
|
403
|
-
this.logger.warn('Failed to parse vLLM command response as JSON', error);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const lines = content.split('\n').map(l => l.trim()).filter(l => l);
|
|
407
|
-
return {
|
|
408
|
-
command: lines[0] || '',
|
|
409
|
-
explanation: lines.slice(1).join(' ') || 'AI生成的命令',
|
|
410
|
-
confidence: 0.5
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* 解析解释响应
|
|
416
|
-
*/
|
|
417
|
-
private parseExplainResponse(content: string): ExplainResponse {
|
|
418
|
-
try {
|
|
419
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
420
|
-
if (match) {
|
|
421
|
-
const parsed = JSON.parse(match[0]);
|
|
422
|
-
return {
|
|
423
|
-
explanation: parsed.explanation || '',
|
|
424
|
-
breakdown: parsed.breakdown || [],
|
|
425
|
-
examples: parsed.examples || []
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
} catch (error) {
|
|
429
|
-
this.logger.warn('Failed to parse vLLM explain response as JSON', error);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return {
|
|
433
|
-
explanation: content,
|
|
434
|
-
breakdown: []
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* 解析分析响应
|
|
440
|
-
*/
|
|
441
|
-
private parseAnalysisResponse(content: string): AnalysisResponse {
|
|
442
|
-
try {
|
|
443
|
-
const match = content.match(/\{[\s\S]*\}/);
|
|
444
|
-
if (match) {
|
|
445
|
-
const parsed = JSON.parse(match[0]);
|
|
446
|
-
return {
|
|
447
|
-
summary: parsed.summary || '',
|
|
448
|
-
insights: parsed.insights || [],
|
|
449
|
-
success: parsed.success !== false,
|
|
450
|
-
issues: parsed.issues || []
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
} catch (error) {
|
|
454
|
-
this.logger.warn('Failed to parse vLLM analysis response as JSON', error);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return {
|
|
458
|
-
summary: content,
|
|
459
|
-
insights: [],
|
|
460
|
-
success: true
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
303
|
}
|