@opensumi/ide-ai-native 3.7.2-next-1739848467.0 → 3.7.2-next-1739945875.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 +3 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +68 -2
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +2 -2
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +16 -5
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +4 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +43 -0
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts +12 -0
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/ContextSelector.js +113 -0
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts +4 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/index.js +84 -0
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatContext/style.module.less +189 -0
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +25 -0
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +6 -0
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -0
- package/lib/browser/components/ChatToolRender.js +53 -0
- package/lib/browser/components/ChatToolRender.js.map +1 -0
- package/lib/browser/components/ChatToolRender.module.less +86 -0
- package/lib/browser/components/components.module.less +32 -31
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.contribution.d.ts +7 -0
- package/lib/browser/context/llm-context.contribution.d.ts.map +1 -0
- package/lib/browser/context/llm-context.contribution.js +21 -0
- package/lib/browser/context/llm-context.contribution.js.map +1 -0
- package/lib/browser/context/llm-context.service.d.ts +24 -0
- package/lib/browser/context/llm-context.service.d.ts.map +1 -0
- package/lib/browser/context/llm-context.service.js +136 -0
- package/lib/browser/context/llm-context.service.js.map +1 -0
- package/lib/browser/index.d.ts +11 -3
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +56 -3
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +25 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js +56 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +16 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js +53 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts +8 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js +16 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +9 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js +83 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts +9 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +92 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +8 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js +49 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts +10 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +119 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts +9 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js +97 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts +11 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +119 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +8 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +50 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts +8 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.js +57 -0
- package/lib/browser/mcp/tools/getSelectedText.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +21 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js +112 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +47 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js +147 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts +8 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/listDir.js +65 -0
- package/lib/browser/mcp/tools/listDir.js.map +1 -0
- package/lib/browser/mcp/tools/readFile.d.ts +8 -0
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/readFile.js +82 -0
- package/lib/browser/mcp/tools/readFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +79 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +84 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts +18 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js +96 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -0
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +60 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +45 -0
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +5 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/common/index.d.ts +9 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +37 -0
- package/lib/common/llm-context.d.ts.map +1 -0
- package/lib/common/llm-context.js +5 -0
- package/lib/common/llm-context.js.map +1 -0
- package/lib/common/mcp-server-manager.d.ts +40 -0
- package/lib/common/mcp-server-manager.d.ts.map +1 -0
- package/lib/common/mcp-server-manager.js +6 -0
- package/lib/common/mcp-server-manager.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +91 -0
- package/lib/common/tool-invocation-registry.d.ts.map +1 -0
- package/lib/common/tool-invocation-registry.js +90 -0
- package/lib/common/tool-invocation-registry.js.map +1 -0
- package/lib/common/types.d.ts +17 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +9 -0
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -0
- package/lib/node/anthropic/anthropic-language-model.js +26 -0
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -0
- package/lib/node/base-language-model.d.ts +14 -0
- package/lib/node/base-language-model.d.ts.map +1 -0
- package/lib/node/base-language-model.js +136 -0
- package/lib/node/base-language-model.js.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts +9 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.js +26 -0
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +19 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +91 -0
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -0
- package/lib/node/mcp/sumi-mcp-server.js +172 -0
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -0
- package/lib/node/mcp-server-manager-impl.d.ts +27 -0
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -0
- package/lib/node/mcp-server-manager-impl.js +127 -0
- package/lib/node/mcp-server-manager-impl.js.map +1 -0
- package/lib/node/mcp-server.d.ts +207 -0
- package/lib/node/mcp-server.d.ts.map +1 -0
- package/lib/node/mcp-server.js +91 -0
- package/lib/node/mcp-server.js.map +1 -0
- package/lib/node/openai/openai-language-model.d.ts +9 -0
- package/lib/node/openai/openai-language-model.d.ts.map +1 -0
- package/lib/node/openai/openai-language-model.js +29 -0
- package/lib/node/openai/openai-language-model.js.map +1 -0
- package/package.json +34 -22
- package/src/browser/ai-core.contribution.ts +77 -1
- package/src/browser/chat/chat-model.ts +24 -6
- package/src/browser/chat/chat-proxy.service.ts +42 -0
- package/src/browser/chat/chat.view.tsx +59 -6
- package/src/browser/components/ChatContext/ContextSelector.tsx +177 -0
- package/src/browser/components/ChatContext/index.tsx +135 -0
- package/src/browser/components/ChatContext/style.module.less +189 -0
- package/src/browser/components/ChatInput.tsx +1 -0
- package/src/browser/components/ChatReply.tsx +32 -0
- package/src/browser/components/ChatToolRender.module.less +86 -0
- package/src/browser/components/ChatToolRender.tsx +77 -0
- package/src/browser/components/components.module.less +32 -31
- package/src/browser/context/llm-context.contribution.ts +14 -0
- package/src/browser/context/llm-context.service.ts +156 -0
- package/src/browser/index.ts +68 -4
- package/src/browser/mcp/mcp-server-proxy.service.ts +53 -0
- package/src/browser/mcp/mcp-server.feature.registry.ts +54 -0
- package/src/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/src/browser/mcp/mcp-tools-dialog.view.tsx +24 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +83 -0
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +93 -0
- package/src/browser/mcp/tools/getCurrentFilePath.ts +49 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +123 -0
- package/src/browser/mcp/tools/getFileTextByPath.ts +97 -0
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +121 -0
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +50 -0
- package/src/browser/mcp/tools/getSelectedText.ts +57 -0
- package/src/browser/mcp/tools/handlers/ListDir.ts +117 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +174 -0
- package/src/browser/mcp/tools/listDir.ts +66 -0
- package/src/browser/mcp/tools/readFile.ts +82 -0
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +80 -0
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +91 -0
- package/src/browser/mcp/tools/runTerminalCmd.ts +107 -0
- package/src/browser/preferences/schema.ts +60 -0
- package/src/browser/types.ts +56 -0
- package/src/common/index.ts +14 -0
- package/src/common/llm-context.ts +41 -0
- package/src/common/mcp-server-manager.ts +46 -0
- package/src/common/tool-invocation-registry.ts +170 -0
- package/src/common/types.ts +22 -0
- package/src/node/anthropic/anthropic-language-model.ts +25 -0
- package/src/node/base-language-model.ts +163 -0
- package/src/node/deepseek/deepseek-language-model.ts +25 -0
- package/src/node/index.ts +21 -0
- package/src/node/mcp/sumi-mcp-server.ts +197 -0
- package/src/node/mcp-server-manager-impl.ts +148 -0
- package/src/node/mcp-server.ts +126 -0
- package/src/node/openai/openai-language-model.ts +25 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCPServerImpl = void 0;
|
|
4
|
+
// have to import with extension since the exports map is ./* -> ./dist/cjs/*
|
|
5
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
6
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
|
|
7
|
+
class MCPServerImpl {
|
|
8
|
+
constructor(name, command, args, env, logger) {
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.started = false;
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.command = command;
|
|
13
|
+
this.args = args;
|
|
14
|
+
this.env = env;
|
|
15
|
+
}
|
|
16
|
+
isStarted() {
|
|
17
|
+
return this.started;
|
|
18
|
+
}
|
|
19
|
+
getServerName() {
|
|
20
|
+
return this.name;
|
|
21
|
+
}
|
|
22
|
+
async start() {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (this.started) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(`Starting server "${this.name}" with command: ${this.command} and args: ${(_b = this.args) === null || _b === void 0 ? void 0 : _b.join(' ')} and env: ${JSON.stringify(this.env)}`);
|
|
28
|
+
// Filter process.env to exclude undefined values
|
|
29
|
+
const sanitizedEnv = Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== undefined));
|
|
30
|
+
const mergedEnv = {
|
|
31
|
+
...sanitizedEnv,
|
|
32
|
+
...(this.env || {}),
|
|
33
|
+
};
|
|
34
|
+
const transport = new stdio_js_1.StdioClientTransport({
|
|
35
|
+
command: this.command,
|
|
36
|
+
args: this.args,
|
|
37
|
+
env: mergedEnv,
|
|
38
|
+
});
|
|
39
|
+
transport.onerror = (error) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error('Transport Error:', error);
|
|
42
|
+
};
|
|
43
|
+
this.client = new index_js_1.Client({
|
|
44
|
+
name: 'opensumi-mcp-client',
|
|
45
|
+
version: '1.0.0',
|
|
46
|
+
}, {
|
|
47
|
+
capabilities: {},
|
|
48
|
+
});
|
|
49
|
+
this.client.onerror = (error) => {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error('Error in MCP client:', error);
|
|
52
|
+
};
|
|
53
|
+
await this.client.connect(transport);
|
|
54
|
+
this.started = true;
|
|
55
|
+
}
|
|
56
|
+
async callTool(toolName, arg_string) {
|
|
57
|
+
var _a;
|
|
58
|
+
let args;
|
|
59
|
+
try {
|
|
60
|
+
args = JSON.parse(arg_string);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`Failed to parse arguments for calling tool "${toolName}" in MCP server "${this.name}" with command "${this.command}".
|
|
64
|
+
Invalid JSON: ${arg_string}`, error);
|
|
65
|
+
}
|
|
66
|
+
const params = {
|
|
67
|
+
name: toolName,
|
|
68
|
+
arguments: args,
|
|
69
|
+
};
|
|
70
|
+
return this.client.callTool(params);
|
|
71
|
+
}
|
|
72
|
+
async getTools() {
|
|
73
|
+
return await this.client.listTools();
|
|
74
|
+
}
|
|
75
|
+
update(command, args, env) {
|
|
76
|
+
this.command = command;
|
|
77
|
+
this.args = args;
|
|
78
|
+
this.env = env;
|
|
79
|
+
}
|
|
80
|
+
stop() {
|
|
81
|
+
var _a;
|
|
82
|
+
if (!this.started || !this.client) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(`Stopping MCP server "${this.name}"`);
|
|
86
|
+
this.client.close();
|
|
87
|
+
this.started = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.MCPServerImpl = MCPServerImpl;
|
|
91
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/node/mcp-server.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OpenAIProvider } from '@ai-sdk/openai';
|
|
2
|
+
import { IAIBackServiceOption } from '@opensumi/ide-core-common';
|
|
3
|
+
import { BaseLanguageModel } from '../base-language-model';
|
|
4
|
+
export declare const DeepSeekModelIdentifier: unique symbol;
|
|
5
|
+
export declare class OpenAIModel extends BaseLanguageModel {
|
|
6
|
+
protected initializeProvider(options: IAIBackServiceOption): OpenAIProvider;
|
|
7
|
+
protected getModelIdentifier(provider: OpenAIProvider): import("ai").LanguageModelV1;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=openai-language-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-language-model.d.ts","sourceRoot":"","sources":["../../../src/node/openai/openai-language-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAA6B,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,qBACa,WAAY,SAAQ,iBAAiB;IAChD,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc;IAW3E,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,cAAc;CAGtD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAIModel = exports.DeepSeekModelIdentifier = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const openai_1 = require("@ai-sdk/openai");
|
|
6
|
+
const di_1 = require("@opensumi/di");
|
|
7
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
8
|
+
const base_language_model_1 = require("../base-language-model");
|
|
9
|
+
exports.DeepSeekModelIdentifier = Symbol('DeepSeekModelIdentifier');
|
|
10
|
+
let OpenAIModel = class OpenAIModel extends base_language_model_1.BaseLanguageModel {
|
|
11
|
+
initializeProvider(options) {
|
|
12
|
+
const apiKey = options.apiKey;
|
|
13
|
+
if (!apiKey) {
|
|
14
|
+
throw new Error(`Please provide OpenAI API Key in preferences (${ide_core_common_1.AINativeSettingSectionsId.OpenaiApiKey})`);
|
|
15
|
+
}
|
|
16
|
+
return (0, openai_1.createOpenAI)({
|
|
17
|
+
apiKey,
|
|
18
|
+
baseURL: options.baseURL || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getModelIdentifier(provider) {
|
|
22
|
+
return provider('qwen-max');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.OpenAIModel = OpenAIModel;
|
|
26
|
+
exports.OpenAIModel = OpenAIModel = tslib_1.__decorate([
|
|
27
|
+
(0, di_1.Injectable)()
|
|
28
|
+
], OpenAIModel);
|
|
29
|
+
//# sourceMappingURL=openai-language-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-language-model.js","sourceRoot":"","sources":["../../../src/node/openai/openai-language-model.ts"],"names":[],"mappings":";;;;AAAA,2CAA8D;AAE9D,qCAA0C;AAC1C,+DAA4F;AAE5F,gEAA2D;AAC9C,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAGlE,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,uCAAiB;IACtC,kBAAkB,CAAC,OAA6B;QACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,2CAAyB,CAAC,YAAY,GAAG,CAAC,CAAC;QAC9G,CAAC;QACD,OAAO,IAAA,qBAAY,EAAC;YAClB,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,mDAAmD;SAChF,CAAC,CAAC;IACL,CAAC;IAES,kBAAkB,CAAC,QAAwB;QACnD,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;CACF,CAAA;AAfY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAU,GAAE;GACA,WAAW,CAevB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.7.2-next-
|
|
3
|
+
"version": "3.7.2-next-1739945875.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -19,34 +19,46 @@
|
|
|
19
19
|
"url": "git@github.com:opensumi/core.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@opensumi/ide-
|
|
28
|
-
"@opensumi/ide-
|
|
29
|
-
"@opensumi/ide-
|
|
30
|
-
"@opensumi/ide-
|
|
31
|
-
"@opensumi/ide-
|
|
32
|
-
"@opensumi/ide-
|
|
33
|
-
"@opensumi/ide-
|
|
34
|
-
"@opensumi/ide-
|
|
35
|
-
"@opensumi/ide-
|
|
36
|
-
"@opensumi/ide-
|
|
37
|
-
"@opensumi/ide-
|
|
38
|
-
"@opensumi/ide-
|
|
39
|
-
"@opensumi/ide-
|
|
22
|
+
"@ai-sdk/anthropic": "^1.1.6",
|
|
23
|
+
"@ai-sdk/deepseek": "^0.1.8",
|
|
24
|
+
"@ai-sdk/openai": "^1.1.9",
|
|
25
|
+
"@anthropic-ai/sdk": "^0.36.3",
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
27
|
+
"@opensumi/ide-addons": "3.7.2-next-1739945875.0",
|
|
28
|
+
"@opensumi/ide-components": "3.7.2-next-1739945875.0",
|
|
29
|
+
"@opensumi/ide-connection": "3.7.2-next-1739945875.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.7.2-next-1739945875.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.7.2-next-1739945875.0",
|
|
32
|
+
"@opensumi/ide-debug": "3.7.2-next-1739945875.0",
|
|
33
|
+
"@opensumi/ide-design": "3.7.2-next-1739945875.0",
|
|
34
|
+
"@opensumi/ide-editor": "3.7.2-next-1739945875.0",
|
|
35
|
+
"@opensumi/ide-file-search": "3.7.2-next-1739945875.0",
|
|
36
|
+
"@opensumi/ide-file-service": "3.7.2-next-1739945875.0",
|
|
37
|
+
"@opensumi/ide-file-tree-next": "3.7.2-next-1739945875.0",
|
|
38
|
+
"@opensumi/ide-main-layout": "3.7.2-next-1739945875.0",
|
|
39
|
+
"@opensumi/ide-markers": "3.7.2-next-1739945875.0",
|
|
40
|
+
"@opensumi/ide-menu-bar": "3.7.2-next-1739945875.0",
|
|
41
|
+
"@opensumi/ide-monaco": "3.7.2-next-1739945875.0",
|
|
42
|
+
"@opensumi/ide-overlay": "3.7.2-next-1739945875.0",
|
|
43
|
+
"@opensumi/ide-preferences": "3.7.2-next-1739945875.0",
|
|
44
|
+
"@opensumi/ide-terminal-next": "3.7.2-next-1739945875.0",
|
|
45
|
+
"@opensumi/ide-theme": "3.7.2-next-1739945875.0",
|
|
46
|
+
"@opensumi/ide-utils": "3.7.2-next-1739945875.0",
|
|
47
|
+
"@opensumi/ide-workspace": "3.7.2-next-1739945875.0",
|
|
40
48
|
"@xterm/xterm": "5.5.0",
|
|
49
|
+
"ai": "^4.1.21",
|
|
41
50
|
"ansi-regex": "^2.0.0",
|
|
42
51
|
"dom-align": "^1.7.0",
|
|
52
|
+
"rc-collapse": "^4.0.0",
|
|
43
53
|
"react-chat-elements": "^12.0.10",
|
|
44
54
|
"react-highlight": "^0.15.0",
|
|
45
55
|
"tiktoken": "1.0.12",
|
|
46
|
-
"web-tree-sitter": "0.22.6"
|
|
56
|
+
"web-tree-sitter": "0.22.6",
|
|
57
|
+
"zod": "^3.23.8",
|
|
58
|
+
"zod-to-json-schema": "^3.24.1"
|
|
47
59
|
},
|
|
48
60
|
"devDependencies": {
|
|
49
|
-
"@opensumi/ide-core-browser": "3.7.2-next-
|
|
61
|
+
"@opensumi/ide-core-browser": "3.7.2-next-1739945875.0"
|
|
50
62
|
},
|
|
51
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e491fa42318a9b37cfedf17b812c905c000c9aff"
|
|
52
64
|
}
|
|
@@ -73,7 +73,10 @@ import {
|
|
|
73
73
|
AI_CHAT_VIEW_ID,
|
|
74
74
|
AI_MENU_BAR_DEBUG_TOOLBAR,
|
|
75
75
|
ChatProxyServiceToken,
|
|
76
|
+
ISumiMCPServerBackend,
|
|
77
|
+
SumiMCPServerProxyServicePath,
|
|
76
78
|
} from '../common';
|
|
79
|
+
import { MCPServerDescription } from '../common/mcp-server-manager';
|
|
77
80
|
|
|
78
81
|
import { ChatProxyService } from './chat/chat-proxy.service';
|
|
79
82
|
import { AIChatView } from './chat/chat.view';
|
|
@@ -97,10 +100,13 @@ import {
|
|
|
97
100
|
IChatFeatureRegistry,
|
|
98
101
|
IChatRenderRegistry,
|
|
99
102
|
IIntelligentCompletionsRegistry,
|
|
103
|
+
IMCPServerRegistry,
|
|
100
104
|
IProblemFixProviderRegistry,
|
|
101
105
|
IRenameCandidatesProviderRegistry,
|
|
102
106
|
IResolveConflictRegistry,
|
|
103
107
|
ITerminalProviderRegistry,
|
|
108
|
+
MCPServerContribution,
|
|
109
|
+
TokenMCPServerRegistry,
|
|
104
110
|
} from './types';
|
|
105
111
|
import { InlineChatEditorController } from './widget/inline-chat/inline-chat-editor.controller';
|
|
106
112
|
import { InlineChatFeatureRegistry } from './widget/inline-chat/inline-chat.feature.registry';
|
|
@@ -145,6 +151,12 @@ export class AINativeBrowserContribution
|
|
|
145
151
|
@Autowired(AINativeCoreContribution)
|
|
146
152
|
private readonly contributions: ContributionProvider<AINativeCoreContribution>;
|
|
147
153
|
|
|
154
|
+
@Autowired(MCPServerContribution)
|
|
155
|
+
private readonly mcpServerContributions: ContributionProvider<MCPServerContribution>;
|
|
156
|
+
|
|
157
|
+
@Autowired(TokenMCPServerRegistry)
|
|
158
|
+
private readonly mcpServerRegistry: IMCPServerRegistry;
|
|
159
|
+
|
|
148
160
|
@Autowired(InlineChatFeatureRegistryToken)
|
|
149
161
|
private readonly inlineChatFeatureRegistry: InlineChatFeatureRegistry;
|
|
150
162
|
|
|
@@ -208,6 +220,9 @@ export class AINativeBrowserContribution
|
|
|
208
220
|
@Autowired(CodeActionSingleHandler)
|
|
209
221
|
private readonly codeActionSingleHandler: CodeActionSingleHandler;
|
|
210
222
|
|
|
223
|
+
@Autowired(SumiMCPServerProxyServicePath)
|
|
224
|
+
private readonly sumiMCPServerBackendProxy: ISumiMCPServerBackend;
|
|
225
|
+
|
|
211
226
|
@Autowired(WorkbenchEditorService)
|
|
212
227
|
private readonly workbenchEditorService: WorkbenchEditorServiceImpl;
|
|
213
228
|
|
|
@@ -279,7 +294,7 @@ export class AINativeBrowserContribution
|
|
|
279
294
|
|
|
280
295
|
onDidStart() {
|
|
281
296
|
runWhenIdle(() => {
|
|
282
|
-
const { supportsRenameSuggestions, supportsInlineChat } = this.aiNativeConfigService.capabilities;
|
|
297
|
+
const { supportsRenameSuggestions, supportsInlineChat, supportsMCP } = this.aiNativeConfigService.capabilities;
|
|
283
298
|
const prefChatVisibleType = this.preferenceService.getValid(AINativeSettingSectionsId.ChatVisibleType);
|
|
284
299
|
|
|
285
300
|
if (prefChatVisibleType === 'always') {
|
|
@@ -295,6 +310,19 @@ export class AINativeBrowserContribution
|
|
|
295
310
|
if (supportsInlineChat) {
|
|
296
311
|
this.codeActionSingleHandler.load();
|
|
297
312
|
}
|
|
313
|
+
|
|
314
|
+
if (supportsMCP) {
|
|
315
|
+
// 初始化内置 MCP Server
|
|
316
|
+
this.sumiMCPServerBackendProxy.initBuiltinMCPServer();
|
|
317
|
+
|
|
318
|
+
// 从 preferences 获取并初始化外部 MCP Servers
|
|
319
|
+
const mcpServers = this.preferenceService.getValid<MCPServerDescription[]>(
|
|
320
|
+
AINativeSettingSectionsId.MCPServers,
|
|
321
|
+
);
|
|
322
|
+
if (mcpServers && mcpServers.length > 0) {
|
|
323
|
+
this.sumiMCPServerBackendProxy.initExternalMCPServers(mcpServers);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
298
326
|
});
|
|
299
327
|
}
|
|
300
328
|
|
|
@@ -308,6 +336,12 @@ export class AINativeBrowserContribution
|
|
|
308
336
|
contribution.registerTerminalProvider?.(this.terminalProviderRegistry);
|
|
309
337
|
contribution.registerIntelligentCompletionFeature?.(this.intelligentCompletionsRegistry);
|
|
310
338
|
contribution.registerProblemFixFeature?.(this.problemFixProviderRegistry);
|
|
339
|
+
contribution.registerChatAgentPromptProvider?.();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// 注册 Opensumi 框架提供的 MCP Server Tools 能力 (此时的 Opensumi 作为 MCP Server)
|
|
343
|
+
this.mcpServerContributions.getContributions().forEach((contribution) => {
|
|
344
|
+
contribution.registerMCPServer(this.mcpServerRegistry);
|
|
311
345
|
});
|
|
312
346
|
}
|
|
313
347
|
|
|
@@ -379,6 +413,48 @@ export class AINativeBrowserContribution
|
|
|
379
413
|
});
|
|
380
414
|
}
|
|
381
415
|
|
|
416
|
+
// Register language model API key settings
|
|
417
|
+
if (this.aiNativeConfigService.capabilities.supportsCustomLLMSettings) {
|
|
418
|
+
registry.registerSettingSection(AI_NATIVE_SETTING_GROUP_ID, {
|
|
419
|
+
title: localize('preference.ai.native.llm.apiSettings.title'),
|
|
420
|
+
preferences: [
|
|
421
|
+
{
|
|
422
|
+
id: AINativeSettingSectionsId.LLMModelSelection,
|
|
423
|
+
localized: 'preference.ai.native.llm.model.selection',
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: AINativeSettingSectionsId.DeepseekApiKey,
|
|
427
|
+
localized: 'preference.ai.native.deepseek.apiKey',
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: AINativeSettingSectionsId.AnthropicApiKey,
|
|
431
|
+
localized: 'preference.ai.native.anthropic.apiKey',
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
id: AINativeSettingSectionsId.OpenaiApiKey,
|
|
435
|
+
localized: 'preference.ai.native.openai.apiKey',
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
id: AINativeSettingSectionsId.OpenaiBaseURL,
|
|
439
|
+
localized: 'preference.ai.native.openai.baseURL',
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Register MCP server settings
|
|
446
|
+
if (this.aiNativeConfigService.capabilities.supportsMCP) {
|
|
447
|
+
registry.registerSettingSection(AI_NATIVE_SETTING_GROUP_ID, {
|
|
448
|
+
title: localize('preference.ai.native.mcp.settings.title'),
|
|
449
|
+
preferences: [
|
|
450
|
+
{
|
|
451
|
+
id: AINativeSettingSectionsId.MCPServers,
|
|
452
|
+
localized: 'preference.ai.native.mcp.servers',
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
382
458
|
if (this.aiNativeConfigService.capabilities.supportsInlineChat) {
|
|
383
459
|
registry.registerSettingSection(AI_NATIVE_SETTING_GROUP_ID, {
|
|
384
460
|
title: localize('preference.ai.native.inlineChat.title'),
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
IChatComponent,
|
|
7
7
|
IChatMarkdownContent,
|
|
8
8
|
IChatProgress,
|
|
9
|
+
IChatToolContent,
|
|
9
10
|
IChatTreeData,
|
|
10
11
|
ILogger,
|
|
11
12
|
memoize,
|
|
@@ -26,7 +27,12 @@ import {
|
|
|
26
27
|
import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
27
28
|
import { IChatSlashCommandItem } from '../types';
|
|
28
29
|
|
|
29
|
-
export type IChatProgressResponseContent =
|
|
30
|
+
export type IChatProgressResponseContent =
|
|
31
|
+
| IChatMarkdownContent
|
|
32
|
+
| IChatAsyncContent
|
|
33
|
+
| IChatTreeData
|
|
34
|
+
| IChatComponent
|
|
35
|
+
| IChatToolContent;
|
|
30
36
|
|
|
31
37
|
@Injectable({ multiple: true })
|
|
32
38
|
export class ChatResponseModel extends Disposable {
|
|
@@ -81,8 +87,8 @@ export class ChatResponseModel extends Disposable {
|
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
updateContent(progress: IChatProgress, quiet?: boolean): void {
|
|
90
|
+
const responsePartLength = this.#responseParts.length - 1;
|
|
84
91
|
if (progress.kind === 'content' || progress.kind === 'markdownContent') {
|
|
85
|
-
const responsePartLength = this.#responseParts.length - 1;
|
|
86
92
|
const lastResponsePart = this.#responseParts[responsePartLength];
|
|
87
93
|
|
|
88
94
|
if (!lastResponsePart || lastResponsePart.kind !== 'markdownContent') {
|
|
@@ -120,11 +126,20 @@ export class ChatResponseModel extends Disposable {
|
|
|
120
126
|
}
|
|
121
127
|
this.#updateResponseText(quiet);
|
|
122
128
|
});
|
|
123
|
-
} else if (progress.kind === 'treeData') {
|
|
129
|
+
} else if (progress.kind === 'treeData' || progress.kind === 'component') {
|
|
124
130
|
this.#responseParts.push(progress);
|
|
125
131
|
this.#updateResponseText(quiet);
|
|
126
|
-
} else if (progress.kind === '
|
|
127
|
-
this.#responseParts.
|
|
132
|
+
} else if (progress.kind === 'toolCall') {
|
|
133
|
+
const find = this.#responseParts.find(
|
|
134
|
+
(item) => item.kind === 'toolCall' && item.content.id === progress.content.id,
|
|
135
|
+
);
|
|
136
|
+
if (find) {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
find.content = progress.content;
|
|
139
|
+
// this.#responseParts[responsePartLength] = find;
|
|
140
|
+
} else {
|
|
141
|
+
this.#responseParts.push(progress);
|
|
142
|
+
}
|
|
128
143
|
this.#updateResponseText(quiet);
|
|
129
144
|
}
|
|
130
145
|
}
|
|
@@ -141,6 +156,9 @@ export class ChatResponseModel extends Disposable {
|
|
|
141
156
|
if (part.kind === 'component') {
|
|
142
157
|
return '';
|
|
143
158
|
}
|
|
159
|
+
if (part.kind === 'toolCall') {
|
|
160
|
+
return part.content.function.name;
|
|
161
|
+
}
|
|
144
162
|
return part.content.value;
|
|
145
163
|
})
|
|
146
164
|
.join('\n\n');
|
|
@@ -258,7 +276,7 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
258
276
|
|
|
259
277
|
const { kind } = progress;
|
|
260
278
|
|
|
261
|
-
const basicKind = ['content', 'markdownContent', 'asyncContent', 'treeData', 'component'];
|
|
279
|
+
const basicKind = ['content', 'markdownContent', 'asyncContent', 'treeData', 'component', 'toolCall'];
|
|
262
280
|
|
|
263
281
|
if (basicKind.includes(kind)) {
|
|
264
282
|
request.response.updateContent(progress, quiet);
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import { PreferenceService } from '@opensumi/ide-core-browser';
|
|
2
3
|
import {
|
|
3
4
|
AIBackSerivcePath,
|
|
4
5
|
CancellationToken,
|
|
6
|
+
ChatAgentViewServiceToken,
|
|
5
7
|
ChatFeatureRegistryToken,
|
|
6
8
|
ChatServiceToken,
|
|
7
9
|
Deferred,
|
|
8
10
|
Disposable,
|
|
9
11
|
IAIBackService,
|
|
10
12
|
IAIReporter,
|
|
13
|
+
IApplicationService,
|
|
11
14
|
IChatProgress,
|
|
12
15
|
uuid,
|
|
13
16
|
} from '@opensumi/ide-core-common';
|
|
17
|
+
import { AINativeSettingSectionsId } from '@opensumi/ide-core-common/lib/settings/ai-native';
|
|
14
18
|
import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
15
19
|
import { MonacoCommandRegistry } from '@opensumi/ide-editor/lib/browser/monaco-contrib/command/command.service';
|
|
20
|
+
import { IMessageService } from '@opensumi/ide-overlay';
|
|
16
21
|
import { listenReadable } from '@opensumi/ide-utils/lib/stream';
|
|
17
22
|
|
|
18
23
|
import {
|
|
@@ -22,6 +27,8 @@ import {
|
|
|
22
27
|
IChatAgentService,
|
|
23
28
|
IChatAgentWelcomeMessage,
|
|
24
29
|
} from '../../common';
|
|
30
|
+
import { ChatToolRender } from '../components/ChatToolRender';
|
|
31
|
+
import { IChatAgentViewService } from '../types';
|
|
25
32
|
|
|
26
33
|
import { ChatService } from './chat.api.service';
|
|
27
34
|
import { ChatFeatureRegistry } from './chat.feature.registry';
|
|
@@ -52,9 +59,27 @@ export class ChatProxyService extends Disposable {
|
|
|
52
59
|
@Autowired(IAIReporter)
|
|
53
60
|
private readonly aiReporter: IAIReporter;
|
|
54
61
|
|
|
62
|
+
@Autowired(ChatAgentViewServiceToken)
|
|
63
|
+
private readonly chatAgentViewService: IChatAgentViewService;
|
|
64
|
+
|
|
65
|
+
@Autowired(PreferenceService)
|
|
66
|
+
private readonly preferenceService: PreferenceService;
|
|
67
|
+
|
|
68
|
+
@Autowired(IApplicationService)
|
|
69
|
+
private readonly applicationService: IApplicationService;
|
|
70
|
+
|
|
71
|
+
@Autowired(IMessageService)
|
|
72
|
+
private readonly messageService: IMessageService;
|
|
73
|
+
|
|
55
74
|
private chatDeferred: Deferred<void> = new Deferred<void>();
|
|
56
75
|
|
|
57
76
|
public registerDefaultAgent() {
|
|
77
|
+
this.chatAgentViewService.registerChatComponent({
|
|
78
|
+
id: 'toolCall',
|
|
79
|
+
component: ChatToolRender,
|
|
80
|
+
initialProps: {},
|
|
81
|
+
});
|
|
82
|
+
|
|
58
83
|
this.addDispose(
|
|
59
84
|
this.chatAgentService.registerAgent({
|
|
60
85
|
id: ChatProxyService.AGENT_ID,
|
|
@@ -79,12 +104,28 @@ export class ChatProxyService extends Disposable {
|
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
|
|
107
|
+
const model = this.preferenceService.get<string>(AINativeSettingSectionsId.LLMModelSelection);
|
|
108
|
+
let apiKey: string = '';
|
|
109
|
+
let baseURL: string = '';
|
|
110
|
+
if (model === 'deepseek') {
|
|
111
|
+
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.DeepseekApiKey, '');
|
|
112
|
+
} else if (model === 'openai') {
|
|
113
|
+
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiApiKey, '');
|
|
114
|
+
baseURL = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiBaseURL, '');
|
|
115
|
+
} else {
|
|
116
|
+
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.AnthropicApiKey, '');
|
|
117
|
+
}
|
|
118
|
+
|
|
82
119
|
const stream = await this.aiBackService.requestStream(
|
|
83
120
|
prompt,
|
|
84
121
|
{
|
|
85
122
|
requestId: request.requestId,
|
|
86
123
|
sessionId: request.sessionId,
|
|
87
124
|
history: this.aiChatService.getHistoryMessages(),
|
|
125
|
+
clientId: this.applicationService.clientId,
|
|
126
|
+
apiKey,
|
|
127
|
+
model,
|
|
128
|
+
baseURL,
|
|
88
129
|
},
|
|
89
130
|
token,
|
|
90
131
|
);
|
|
@@ -97,6 +138,7 @@ export class ChatProxyService extends Disposable {
|
|
|
97
138
|
this.chatDeferred.resolve();
|
|
98
139
|
},
|
|
99
140
|
onError: (error) => {
|
|
141
|
+
this.messageService.error(error.message);
|
|
100
142
|
this.aiReporter.end(request.sessionId + '_' + request.requestId, {
|
|
101
143
|
message: error.message,
|
|
102
144
|
success: false,
|