@opensumi/ide-ai-native 3.8.3-next-1741940731.0 → 3.8.3-next-1741942697.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 +1 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +7 -1
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +3 -2
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +1 -0
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +2 -2
- 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 +10 -7
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.d.ts +2 -1
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +5 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts +3 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +51 -3
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/components.module.less +49 -0
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +17 -3
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +1 -0
- package/lib/browser/components/mention-input/types.d.ts +3 -1
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/image-upload/image-upload.feature.registry.d.ts +8 -0
- package/lib/browser/contrib/image-upload/image-upload.feature.registry.d.ts.map +1 -0
- package/lib/browser/contrib/image-upload/image-upload.feature.registry.js +19 -0
- package/lib/browser/contrib/image-upload/image-upload.feature.registry.js.map +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +5 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.view.js +1 -11
- package/lib/browser/mcp/config/components/mcp-config.view.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +0 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/types.d.ts +14 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/common/index.d.ts +6 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/node/base-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +15 -4
- package/lib/node/base-language-model.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/ai-core.contribution.ts +6 -0
- package/src/browser/chat/chat-manager.service.ts +3 -2
- package/src/browser/chat/chat-proxy.service.ts +1 -0
- package/src/browser/chat/chat.internal.service.ts +2 -2
- package/src/browser/chat/chat.view.tsx +18 -8
- package/src/browser/components/ChatEditor.tsx +8 -0
- package/src/browser/components/ChatInput.tsx +2 -2
- package/src/browser/components/ChatMentionInput.tsx +92 -4
- package/src/browser/components/components.module.less +49 -0
- package/src/browser/components/mention-input/mention-input.module.less +1 -0
- package/src/browser/components/mention-input/mention-input.tsx +18 -1
- package/src/browser/components/mention-input/types.ts +3 -1
- package/src/browser/context/llm-context.service.ts +2 -0
- package/src/browser/contrib/image-upload/image-upload.feature.registry.ts +18 -0
- package/src/browser/index.ts +8 -0
- package/src/browser/mcp/config/components/mcp-config.view.tsx +1 -11
- package/src/browser/model/msg-history-manager.ts +1 -1
- package/src/browser/types.ts +17 -1
- package/src/common/index.ts +7 -8
- package/src/common/llm-context.ts +2 -0
- package/src/node/base-language-model.ts +25 -3
package/src/browser/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataContent } from 'ai';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
@@ -140,13 +141,14 @@ export type ChatWelcomeRender = (props: {
|
|
|
140
141
|
export type ChatAIRoleRender = (props: { content: string }) => React.ReactElement | React.JSX.Element;
|
|
141
142
|
export type ChatUserRoleRender = (props: {
|
|
142
143
|
content: string;
|
|
144
|
+
images?: string[];
|
|
143
145
|
agentId?: string;
|
|
144
146
|
command?: string;
|
|
145
147
|
}) => React.ReactElement | React.JSX.Element;
|
|
146
148
|
export type ChatThinkingRender = (props: { thinkingText?: string }) => React.ReactElement | React.JSX.Element;
|
|
147
149
|
export type ChatThinkingResultRender = (props: { thinkingResult?: string }) => React.ReactElement | React.JSX.Element;
|
|
148
150
|
export type ChatInputRender = (props: {
|
|
149
|
-
onSend: (value: string, agentId?: string, command?: string) => void;
|
|
151
|
+
onSend: (value: string, images?: string[], agentId?: string, command?: string) => void;
|
|
150
152
|
onValueChange?: (value: string) => void;
|
|
151
153
|
onExpand?: (value: boolean) => void;
|
|
152
154
|
placeholder?: string;
|
|
@@ -289,6 +291,15 @@ export interface IProblemFixProviderRegistry {
|
|
|
289
291
|
registerHoverFixProvider(handler: IHoverFixHandler): void;
|
|
290
292
|
}
|
|
291
293
|
|
|
294
|
+
export interface IImageUploadProvider {
|
|
295
|
+
imageUpload(file: File): Promise<DataContent | URL>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface IImageUploadProviderRegistry {
|
|
299
|
+
registerImageUploadProvider(provider: IImageUploadProvider): void;
|
|
300
|
+
getImageUploadProvider(): IImageUploadProvider | undefined;
|
|
301
|
+
}
|
|
302
|
+
|
|
292
303
|
export const AINativeCoreContribution = Symbol('AINativeCoreContribution');
|
|
293
304
|
|
|
294
305
|
export interface AINativeCoreContribution {
|
|
@@ -332,6 +343,11 @@ export interface AINativeCoreContribution {
|
|
|
332
343
|
* @param provider
|
|
333
344
|
*/
|
|
334
345
|
registerChatAgentPromptProvider?(): void;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 注册图片上传的能力
|
|
349
|
+
*/
|
|
350
|
+
registerImageUploadProvider?(registry: IImageUploadProviderRegistry): void;
|
|
335
351
|
}
|
|
336
352
|
|
|
337
353
|
// MCP Server 的 贡献点
|
package/src/common/index.ts
CHANGED
|
@@ -52,6 +52,10 @@ export interface IChatMessageStructure {
|
|
|
52
52
|
* 用于 chat 面板展示
|
|
53
53
|
*/
|
|
54
54
|
message: string;
|
|
55
|
+
/**
|
|
56
|
+
* 图片
|
|
57
|
+
*/
|
|
58
|
+
images?: string[];
|
|
55
59
|
/**
|
|
56
60
|
* 实际调用的 prompt
|
|
57
61
|
*/
|
|
@@ -134,14 +138,7 @@ export interface ISumiMCPServerBackend {
|
|
|
134
138
|
initBuiltinMCPServer(enabled: boolean): void;
|
|
135
139
|
initExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
136
140
|
getAllMCPTools(): Promise<MCPTool[]>;
|
|
137
|
-
getServers(): Promise<
|
|
138
|
-
Array<{
|
|
139
|
-
name: string;
|
|
140
|
-
isStarted: boolean;
|
|
141
|
-
type: string;
|
|
142
|
-
tools: MCPTool[];
|
|
143
|
-
}>
|
|
144
|
-
>;
|
|
141
|
+
getServers(): Promise<Array<{ name: string; isStarted: boolean; tools: MCPTool[] }>>;
|
|
145
142
|
startServer(serverName: string): Promise<void>;
|
|
146
143
|
stopServer(serverName: string): Promise<void>;
|
|
147
144
|
addOrUpdateServer(description: MCPServerDescription): void;
|
|
@@ -207,6 +204,7 @@ export interface IChatAgentRequest {
|
|
|
207
204
|
requestId: string;
|
|
208
205
|
command?: string;
|
|
209
206
|
message: string;
|
|
207
|
+
images?: string[];
|
|
210
208
|
regenerate?: boolean;
|
|
211
209
|
}
|
|
212
210
|
|
|
@@ -244,6 +242,7 @@ export type IChatFollowup = IChatReplyFollowup | IChatResponseCommandFollowup;
|
|
|
244
242
|
|
|
245
243
|
export interface IChatRequestMessage {
|
|
246
244
|
prompt: string;
|
|
245
|
+
images?: string[];
|
|
247
246
|
agentId: string;
|
|
248
247
|
command?: string;
|
|
249
248
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CoreMessage,
|
|
3
|
+
CoreUserMessage,
|
|
4
|
+
ImagePart,
|
|
5
|
+
TextPart,
|
|
6
|
+
ToolExecutionOptions,
|
|
7
|
+
jsonSchema,
|
|
8
|
+
streamText,
|
|
9
|
+
tool,
|
|
10
|
+
} from 'ai';
|
|
2
11
|
|
|
3
12
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
13
|
import { IAIBackServiceOption } from '@opensumi/ide-core-common';
|
|
@@ -48,6 +57,7 @@ export abstract class BaseLanguageModel {
|
|
|
48
57
|
options.trimTexts,
|
|
49
58
|
options.system,
|
|
50
59
|
options.maxTokens,
|
|
60
|
+
options.images,
|
|
51
61
|
cancellationToken,
|
|
52
62
|
);
|
|
53
63
|
}
|
|
@@ -77,6 +87,7 @@ export abstract class BaseLanguageModel {
|
|
|
77
87
|
trimTexts?: [string, string],
|
|
78
88
|
systemPrompt?: string,
|
|
79
89
|
maxTokens?: number,
|
|
90
|
+
images?: string[],
|
|
80
91
|
cancellationToken?: CancellationToken,
|
|
81
92
|
): Promise<any> {
|
|
82
93
|
try {
|
|
@@ -89,7 +100,18 @@ export abstract class BaseLanguageModel {
|
|
|
89
100
|
});
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
const messages: CoreMessage[] = [
|
|
103
|
+
const messages: CoreMessage[] = [
|
|
104
|
+
...history,
|
|
105
|
+
{
|
|
106
|
+
role: 'user',
|
|
107
|
+
content: images?.length
|
|
108
|
+
? [
|
|
109
|
+
{ type: 'text', text: request } as TextPart,
|
|
110
|
+
...images.map((image) => ({ type: 'image', image: new URL(image) } as ImagePart)),
|
|
111
|
+
]
|
|
112
|
+
: request,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
93
115
|
const modelInfo = modelId ? this.getModelInfo(modelId) : undefined;
|
|
94
116
|
const stream = streamText({
|
|
95
117
|
model: this.getModelIdentifier(provider, modelId),
|
|
@@ -101,9 +123,9 @@ export abstract class BaseLanguageModel {
|
|
|
101
123
|
maxTokens,
|
|
102
124
|
temperature: modelInfo?.temperature || 0,
|
|
103
125
|
topP: modelInfo?.topP || 0.8,
|
|
104
|
-
topK: modelInfo?.topK || 1,
|
|
105
126
|
system: systemPrompt,
|
|
106
127
|
providerOptions,
|
|
128
|
+
...(!images?.length && { topK: modelInfo?.topK || 1 }),
|
|
107
129
|
});
|
|
108
130
|
|
|
109
131
|
// 状态跟踪变量
|