@opensumi/ide-ai-native 3.7.2-next-1740064823.0 → 3.7.2-next-1740107209.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/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +4 -0
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +6 -0
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +5 -23
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +1 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +8 -1
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +4 -0
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +10 -1
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +2 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.d.ts +1 -0
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +3 -3
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts +1 -0
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +2 -2
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +6 -8
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +2 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +40 -19
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/components.module.less +3 -2
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +7 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +67 -0
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -0
- package/lib/browser/mcp/base-apply.service.js +290 -0
- package/lib/browser/mcp/base-apply.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +6 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +2 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +5 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +15 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts +3 -0
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/EditFile.js +101 -0
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/components/index.module.less +67 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +1 -2
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/editFile.d.ts +8 -0
- package/lib/browser/mcp/tools/editFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/editFile.js +95 -0
- package/lib/browser/mcp/tools/editFile.js.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +1 -1
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +1 -2
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +1 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.js +1 -2
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +1 -2
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getFileTextByPath.js +1 -2
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +1 -2
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +1 -2
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +1 -1
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getSelectedText.js +1 -2
- package/lib/browser/mcp/tools/getSelectedText.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts +10 -0
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js +28 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +6 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +14 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/utils.d.ts +2 -0
- package/lib/browser/mcp/tools/handlers/utils.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/utils.js +7 -0
- package/lib/browser/mcp/tools/handlers/utils.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +2 -4
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/readFile.js +2 -4
- package/lib/browser/mcp/tools/readFile.js.map +1 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +6 -5
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +1 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +1 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +1 -2
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +1 -2
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +5 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +14 -10
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +1 -2
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +1 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +3 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +14 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -0
- package/lib/common/prompts/context-prompt-provider.js +38 -0
- package/lib/common/prompts/context-prompt-provider.js.map +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +3 -1
- package/lib/common/utils.js.map +1 -1
- package/lib/node/base-language-model.d.ts +2 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +8 -4
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +2 -1
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +1 -1
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +2 -2
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +23 -25
- package/src/browser/ai-core.contribution.ts +4 -0
- package/src/browser/chat/chat-agent.service.ts +7 -0
- package/src/browser/chat/chat-model.ts +0 -2
- package/src/browser/chat/chat-proxy.service.ts +12 -2
- package/src/browser/chat/chat.internal.service.ts +12 -1
- package/src/browser/chat/chat.view.tsx +2 -1
- package/src/browser/components/ChatEditor.tsx +13 -10
- package/src/browser/components/ChatMarkdown.tsx +3 -1
- package/src/browser/components/ChatReply.tsx +8 -15
- package/src/browser/components/ChatToolRender.tsx +41 -20
- package/src/browser/components/components.module.less +3 -2
- package/src/browser/index.ts +7 -0
- package/src/browser/mcp/base-apply.service.ts +349 -0
- package/src/browser/mcp/mcp-server-proxy.service.ts +4 -2
- package/src/browser/mcp/mcp-server.feature.registry.ts +25 -3
- package/src/browser/mcp/tools/components/EditFile.tsx +144 -0
- package/src/browser/mcp/tools/components/index.module.less +67 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +1 -2
- package/src/browser/mcp/tools/editFile.ts +100 -0
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +1 -2
- package/src/browser/mcp/tools/getCurrentFilePath.ts +1 -2
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -2
- package/src/browser/mcp/tools/getFileTextByPath.ts +1 -2
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -2
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +1 -2
- package/src/browser/mcp/tools/getSelectedText.ts +1 -2
- package/src/browser/mcp/tools/handlers/EditFile.ts +21 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +19 -1
- package/src/browser/mcp/tools/handlers/utils.ts +3 -0
- package/src/browser/mcp/tools/listDir.ts +2 -4
- package/src/browser/mcp/tools/readFile.ts +2 -4
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +8 -7
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +1 -2
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -2
- package/src/browser/preferences/schema.ts +5 -0
- package/src/browser/types.ts +15 -11
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -0
- package/src/common/index.ts +1 -0
- package/src/common/prompts/context-prompt-provider.ts +46 -0
- package/src/common/utils.ts +2 -0
- package/src/node/base-language-model.ts +17 -4
- package/src/node/mcp-server-manager-impl.ts +2 -1
- package/src/node/openai/openai-language-model.ts +2 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
5
4
|
import { Domain } from '@opensumi/ide-core-common';
|
|
@@ -25,13 +24,13 @@ export class ReplaceOpenEditorFileTool implements MCPServerContribution {
|
|
|
25
24
|
name: 'replace_open_in_editor_file_text',
|
|
26
25
|
description:
|
|
27
26
|
'Replaces the entire content of the currently active file in the IDE editor with specified new text. ' +
|
|
28
|
-
|
|
27
|
+
"Use this tool when you need to completely overwrite the current file's content. " +
|
|
29
28
|
'Requires a text parameter containing the new content. ' +
|
|
30
29
|
'Returns one of three possible responses: ' +
|
|
31
30
|
'"ok" if the file content was successfully replaced, ' +
|
|
32
31
|
'"no file open" if no editor is active, ' +
|
|
33
32
|
'"unknown error" if the operation fails.',
|
|
34
|
-
inputSchema
|
|
33
|
+
inputSchema,
|
|
35
34
|
handler: this.handler.bind(this),
|
|
36
35
|
};
|
|
37
36
|
}
|
|
@@ -60,10 +59,12 @@ export class ReplaceOpenEditorFileTool implements MCPServerContribution {
|
|
|
60
59
|
const fullRange = model.getFullModelRange();
|
|
61
60
|
|
|
62
61
|
// Execute the replacement
|
|
63
|
-
editor.monacoEditor.executeEdits('mcp.tool.replace-file', [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
editor.monacoEditor.executeEdits('mcp.tool.replace-file', [
|
|
63
|
+
{
|
|
64
|
+
range: fullRange,
|
|
65
|
+
text: args.text,
|
|
66
|
+
},
|
|
67
|
+
]);
|
|
67
68
|
|
|
68
69
|
logger.appendLine('Successfully replaced file content');
|
|
69
70
|
return {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
5
4
|
import { Domain } from '@opensumi/ide-core-common';
|
|
@@ -34,7 +33,7 @@ export class ReplaceOpenEditorFileByDiffPreviewerTool implements MCPServerContri
|
|
|
34
33
|
'"ok" if the file content was successfully replaced, ' +
|
|
35
34
|
'"no file open" if no editor is active, ' +
|
|
36
35
|
'"unknown error" if the operation fails.',
|
|
37
|
-
inputSchema
|
|
36
|
+
inputSchema,
|
|
38
37
|
handler: this.handler.bind(this),
|
|
39
38
|
};
|
|
40
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
2
|
|
|
4
3
|
import { Autowired } from '@opensumi/di';
|
|
5
4
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
@@ -48,7 +47,7 @@ export class RunTerminalCommandTool implements MCPServerContribution {
|
|
|
48
47
|
name: 'run_terminal_cmd',
|
|
49
48
|
description:
|
|
50
49
|
"PROPOSE a command to run on behalf of the user.\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\n\nAdhere to these rules:\n1. Based on the contents of the conversation, you will be told if you are in the same shell as a previous step or a new shell.\n2. If in a new shell, you should `cd` to the right directory and do necessary setup in addition to running the command.\n3. If in the same shell, the state will persist, no need to do things like `cd` to the same directory.\n4. For ANY commands that would use a pager, you should append ` | cat` to the command (or whatever is appropriate). You MUST do this for: git, less, head, tail, more, etc.\n5. For commands that are long running/expected to run indefinitely until interruption, please run them in the background. To run jobs in the background, set `is_background` to true rather than changing the details of the command.\n6. Dont include any newlines in the command.",
|
|
51
|
-
inputSchema
|
|
50
|
+
inputSchema,
|
|
52
51
|
handler: this.handler.bind(this),
|
|
53
52
|
};
|
|
54
53
|
}
|
|
@@ -122,5 +122,10 @@ export const aiNativePreferenceSchema: PreferenceSchema = {
|
|
|
122
122
|
type: 'boolean',
|
|
123
123
|
default: false,
|
|
124
124
|
},
|
|
125
|
+
[AINativeSettingSectionsId.SystemPrompt]: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
default: '',
|
|
128
|
+
description: localize('preference.ai.native.chat.system.prompt.description'),
|
|
129
|
+
},
|
|
125
130
|
},
|
|
126
131
|
};
|
package/src/browser/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
2
3
|
|
|
3
4
|
import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native/index';
|
|
4
5
|
import {
|
|
@@ -349,8 +350,9 @@ export interface MCPLogger {
|
|
|
349
350
|
|
|
350
351
|
export interface MCPToolDefinition {
|
|
351
352
|
name: string;
|
|
353
|
+
label?: string;
|
|
352
354
|
description: string;
|
|
353
|
-
inputSchema: any
|
|
355
|
+
inputSchema: ZodSchema<any>; // JSON Schema
|
|
354
356
|
handler: (
|
|
355
357
|
args: any,
|
|
356
358
|
logger: MCPLogger,
|
|
@@ -360,9 +362,21 @@ export interface MCPToolDefinition {
|
|
|
360
362
|
}>;
|
|
361
363
|
}
|
|
362
364
|
|
|
365
|
+
export interface IMCPServerToolComponentProps {
|
|
366
|
+
state?: 'streaming-start' | 'streaming' | 'complete' | 'result';
|
|
367
|
+
args?: Record<string, any>;
|
|
368
|
+
result?: any;
|
|
369
|
+
index?: number;
|
|
370
|
+
messageId?: string;
|
|
371
|
+
toolCallId?: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
363
374
|
export interface IMCPServerRegistry {
|
|
364
375
|
registerMCPTool(tool: MCPToolDefinition): void;
|
|
365
376
|
getMCPTools(): MCPToolDefinition[];
|
|
377
|
+
getMCPTool(name: string): MCPToolDefinition | undefined;
|
|
378
|
+
registerToolComponent(name: string, component: React.FC<IMCPServerToolComponentProps>): void;
|
|
379
|
+
getToolComponent(name: string): React.FC<IMCPServerToolComponentProps> | undefined;
|
|
366
380
|
callMCPTool(
|
|
367
381
|
name: string,
|
|
368
382
|
args: any,
|
|
@@ -405,13 +419,3 @@ export interface IAIMiddleware {
|
|
|
405
419
|
provideInlineCompletions?: IProvideInlineCompletionsSignature;
|
|
406
420
|
};
|
|
407
421
|
}
|
|
408
|
-
|
|
409
|
-
export const ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
410
|
-
|
|
411
|
-
export interface ChatAgentPromptProvider {
|
|
412
|
-
/**
|
|
413
|
-
* 提供上下文提示
|
|
414
|
-
* @param context 上下文
|
|
415
|
-
*/
|
|
416
|
-
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
417
|
-
}
|
|
@@ -69,6 +69,10 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
69
69
|
|
|
70
70
|
public livePreviewDiffDecorationModel: LivePreviewDiffDecorationModel;
|
|
71
71
|
|
|
72
|
+
public get uri() {
|
|
73
|
+
return this.originalModel.uri;
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
constructor(private readonly monacoEditor: ICodeEditor) {
|
|
73
77
|
super();
|
|
74
78
|
|
|
@@ -426,6 +426,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
426
426
|
uri: this.model.uri,
|
|
427
427
|
totalPartialEditCount: this.partialEditWidgetList.length,
|
|
428
428
|
resolvedPartialEditCount: this.partialEditWidgetList.filter((w) => w.isHidden).length,
|
|
429
|
+
acceptPartialEditCount: this.partialEditWidgetList.filter((w) => w.isAccepted).length,
|
|
429
430
|
currentPartialEdit: {
|
|
430
431
|
addedLinesCount,
|
|
431
432
|
deletedLinesCount,
|
package/src/common/index.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { MaybePromise } from '@opensumi/ide-core-common/lib/utils';
|
|
3
|
+
|
|
4
|
+
import { SerializedContext } from '../llm-context';
|
|
5
|
+
|
|
6
|
+
export const ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
7
|
+
|
|
8
|
+
export interface ChatAgentPromptProvider {
|
|
9
|
+
/**
|
|
10
|
+
* 提供上下文提示
|
|
11
|
+
* @param context 上下文
|
|
12
|
+
*/
|
|
13
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
|
|
18
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string> {
|
|
19
|
+
return `
|
|
20
|
+
<additional_data>
|
|
21
|
+
Below are some potentially helpful/relevant pieces of information for figuring out to respond
|
|
22
|
+
<recently_viewed_files>
|
|
23
|
+
${context.recentlyViewFiles.map((file, idx) => `${idx + 1} : ${file}`)}
|
|
24
|
+
</recently_viewed_files>
|
|
25
|
+
<attached_files>
|
|
26
|
+
${context.attachedFiles.map(
|
|
27
|
+
(file) =>
|
|
28
|
+
`
|
|
29
|
+
<file_contents>
|
|
30
|
+
\`\`\`${file.language} ${file.path}
|
|
31
|
+
${file.content}
|
|
32
|
+
\`\`\`
|
|
33
|
+
</file_contents>
|
|
34
|
+
<linter_errors>
|
|
35
|
+
${file.lineErrors.join('\n')}
|
|
36
|
+
</linter_errors>
|
|
37
|
+
`,
|
|
38
|
+
)}
|
|
39
|
+
|
|
40
|
+
</attached_files>
|
|
41
|
+
</additional_data>
|
|
42
|
+
<user_query>
|
|
43
|
+
${userMessage}
|
|
44
|
+
</user_query>`;
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/common/utils.ts
CHANGED
|
@@ -52,6 +52,11 @@ export abstract class BaseLanguageModel {
|
|
|
52
52
|
allFunctions,
|
|
53
53
|
chatReadableStream,
|
|
54
54
|
options.history || [],
|
|
55
|
+
options.modelId,
|
|
56
|
+
options.temperature,
|
|
57
|
+
options.topP,
|
|
58
|
+
options.topK,
|
|
59
|
+
options.providerOptions,
|
|
55
60
|
cancellationToken,
|
|
56
61
|
);
|
|
57
62
|
}
|
|
@@ -65,7 +70,7 @@ export abstract class BaseLanguageModel {
|
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
protected abstract getModelIdentifier(provider: any): any;
|
|
73
|
+
protected abstract getModelIdentifier(provider: any, modelId?: string): any;
|
|
69
74
|
|
|
70
75
|
protected async handleStreamingRequest(
|
|
71
76
|
provider: any,
|
|
@@ -73,6 +78,11 @@ export abstract class BaseLanguageModel {
|
|
|
73
78
|
tools: ToolRequest[],
|
|
74
79
|
chatReadableStream: ChatReadableStream,
|
|
75
80
|
history: IChatMessage[] = [],
|
|
81
|
+
modelId?: string,
|
|
82
|
+
temperature?: number,
|
|
83
|
+
topP?: number,
|
|
84
|
+
topK?: number,
|
|
85
|
+
providerOptions?: Record<string, any>,
|
|
76
86
|
cancellationToken?: CancellationToken,
|
|
77
87
|
): Promise<any> {
|
|
78
88
|
try {
|
|
@@ -92,15 +102,18 @@ export abstract class BaseLanguageModel {
|
|
|
92
102
|
})),
|
|
93
103
|
{ role: 'user', content: request },
|
|
94
104
|
];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
model: this.getModelIdentifier(provider),
|
|
105
|
+
const stream = streamText({
|
|
106
|
+
model: this.getModelIdentifier(provider, modelId),
|
|
98
107
|
maxTokens: 4096,
|
|
99
108
|
tools: aiTools,
|
|
100
109
|
messages,
|
|
101
110
|
abortSignal: abortController.signal,
|
|
102
111
|
experimental_toolCallStreaming: true,
|
|
103
112
|
maxSteps: 12,
|
|
113
|
+
temperature,
|
|
114
|
+
topP: topP || 0.8,
|
|
115
|
+
topK: topK || 1,
|
|
116
|
+
providerOptions,
|
|
104
117
|
});
|
|
105
118
|
|
|
106
119
|
for await (const chunk of stream.fullStream) {
|
|
@@ -2,6 +2,7 @@ import { ILogger } from '@opensumi/ide-core-common';
|
|
|
2
2
|
|
|
3
3
|
import { MCPServerDescription, MCPServerManager, MCPTool } from '../common/mcp-server-manager';
|
|
4
4
|
import { IToolInvocationRegistryManager, ToolRequest } from '../common/tool-invocation-registry';
|
|
5
|
+
import { getToolName } from '../common/utils';
|
|
5
6
|
|
|
6
7
|
import { BuiltinMCPServer } from './mcp/sumi-mcp-server';
|
|
7
8
|
import { IMCPServer, MCPServerImpl } from './mcp-server';
|
|
@@ -62,7 +63,7 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
private convertToToolRequest(tool: MCPTool, serverName: string): ToolRequest {
|
|
65
|
-
const id =
|
|
66
|
+
const id = getToolName(tool.name, serverName);
|
|
66
67
|
|
|
67
68
|
return {
|
|
68
69
|
id,
|
|
@@ -19,7 +19,7 @@ export class OpenAIModel extends BaseLanguageModel {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
protected getModelIdentifier(provider: OpenAIProvider) {
|
|
23
|
-
return provider('qwen-max');
|
|
22
|
+
protected getModelIdentifier(provider: OpenAIProvider, modelId?: string) {
|
|
23
|
+
return provider(modelId || 'qwen-max');
|
|
24
24
|
}
|
|
25
25
|
}
|