feat: 支持服务等级动态切换
- 添加 ServiceTier 类型定义 - 修改 dialogService 接收 serviceTier 参数 - 修改 messageHandler 传递 serviceTier 参数 - 修改 ICHelperPanel 传递 UI 选择的服务等级
This commit is contained in:
@ -10,6 +10,9 @@ type Environment = "dev" | "test" | "prod";
|
|||||||
/** 当前环境 - 修改这里切换环境 */
|
/** 当前环境 - 修改这里切换环境 */
|
||||||
const CURRENT_ENV: Environment = "dev";
|
const CURRENT_ENV: Environment = "dev";
|
||||||
|
|
||||||
|
/** 服务等级类型 */
|
||||||
|
export type ServiceTier = 'lite' | 'syntaxic' | 'max' | 'auto';
|
||||||
|
|
||||||
/** 配置项接口 */
|
/** 配置项接口 */
|
||||||
export interface IccoderConfig {
|
export interface IccoderConfig {
|
||||||
/** 后端服务地址 */
|
/** 后端服务地址 */
|
||||||
@ -18,6 +21,8 @@ export interface IccoderConfig {
|
|||||||
timeout: number;
|
timeout: number;
|
||||||
/** 用户ID(临时使用,后续对接认证) */
|
/** 用户ID(临时使用,后续对接认证) */
|
||||||
userId: string;
|
userId: string;
|
||||||
|
/** 服务等级 */
|
||||||
|
serviceTier: ServiceTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 环境配置 */
|
/** 环境配置 */
|
||||||
@ -25,20 +30,23 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
|
|||||||
/** 本地开发环境 */
|
/** 本地开发环境 */
|
||||||
dev: {
|
dev: {
|
||||||
backendUrl: "http://localhost:2233",
|
backendUrl: "http://localhost:2233",
|
||||||
timeout: 300000, // 5分钟,与子智能体超时一致
|
timeout: 300000,
|
||||||
userId: "default-user",
|
userId: "default-user",
|
||||||
|
serviceTier: "max", // 默认使用 max
|
||||||
},
|
},
|
||||||
/** 测试服务器环境 */
|
/** 测试服务器环境 */
|
||||||
test: {
|
test: {
|
||||||
backendUrl: "http://192.168.1.108:2233",
|
backendUrl: "http://192.168.1.108:2233",
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
userId: "default-user",
|
userId: "default-user",
|
||||||
|
serviceTier: "max",
|
||||||
},
|
},
|
||||||
/** 生产环境 */
|
/** 生产环境 */
|
||||||
prod: {
|
prod: {
|
||||||
backendUrl: "https://api.iccoder.com", // TODO: 替换为实际生产地址
|
backendUrl: "https://api.iccoder.com",
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
userId: "default-user",
|
userId: "default-user",
|
||||||
|
serviceTier: "auto",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,8 @@ export async function showICHelperPanel(
|
|||||||
panel,
|
panel,
|
||||||
message.text,
|
message.text,
|
||||||
context.extensionPath,
|
context.extensionPath,
|
||||||
message.mode
|
message.mode,
|
||||||
|
message.model // 传递服务等级
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "readFile":
|
case "readFile":
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { startStreamDialog, generateTaskId, SSEController, SSECallbacks } from '
|
|||||||
import { executeToolCall, createToolExecutorContext, ToolExecutorContext } from './toolExecutor';
|
import { executeToolCall, createToolExecutorContext, ToolExecutorContext } from './toolExecutor';
|
||||||
import { userInteractionManager } from './userInteraction';
|
import { userInteractionManager } from './userInteraction';
|
||||||
import { getConfig } from '../config/settings';
|
import { getConfig } from '../config/settings';
|
||||||
import type { DialogRequest, ToolCallRequest, AskUserEvent, RunMode, ToolConfirmEvent, PlanConfirmEvent } from '../types/api';
|
import type { DialogRequest, ToolCallRequest, AskUserEvent, RunMode, ServiceTier, ToolConfirmEvent, PlanConfirmEvent } from '../types/api';
|
||||||
import { submitToolConfirm, submitAnswer, stopDialog } from './apiClient';
|
import { submitToolConfirm, submitAnswer, stopDialog } from './apiClient';
|
||||||
import { ChatHistoryManager } from '../utils/chatHistoryManager';
|
import { ChatHistoryManager } from '../utils/chatHistoryManager';
|
||||||
|
|
||||||
@ -316,7 +316,8 @@ export class DialogSession {
|
|||||||
async sendMessage(
|
async sendMessage(
|
||||||
message: string,
|
message: string,
|
||||||
callbacks: DialogCallbacks,
|
callbacks: DialogCallbacks,
|
||||||
mode?: RunMode
|
mode?: RunMode,
|
||||||
|
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (this.isActive) {
|
if (this.isActive) {
|
||||||
callbacks.onError?.('当前有对话正在进行中');
|
callbacks.onError?.('当前有对话正在进行中');
|
||||||
@ -344,6 +345,7 @@ export class DialogSession {
|
|||||||
message,
|
message,
|
||||||
userId: config.userId,
|
userId: config.userId,
|
||||||
mode: mode || 'agent',
|
mode: mode || 'agent',
|
||||||
|
serviceTier: serviceTier || config.serviceTier, // 优先使用传入的参数
|
||||||
compactedData: compactedData || undefined,
|
compactedData: compactedData || undefined,
|
||||||
newMessages: newMessages.length > 0 ? newMessages : undefined,
|
newMessages: newMessages.length > 0 ? newMessages : undefined,
|
||||||
knowledgeData: knowledgeData || undefined
|
knowledgeData: knowledgeData || undefined
|
||||||
|
|||||||
@ -16,6 +16,15 @@ import { CompactedMemory, CompactedMessage } from './memory';
|
|||||||
*/
|
*/
|
||||||
export type RunMode = 'plan' | 'ask' | 'agent' | 'auto';
|
export type RunMode = 'plan' | 'ask' | 'agent' | 'auto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务等级类型
|
||||||
|
* - lite: 轻量级
|
||||||
|
* - syntaxic: 语法级
|
||||||
|
* - max: 最大性能
|
||||||
|
* - auto: 自动选择
|
||||||
|
*/
|
||||||
|
export type ServiceTier = 'lite' | 'syntaxic' | 'max' | 'auto';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话请求
|
* 对话请求
|
||||||
* POST /api/dialog/stream
|
* POST /api/dialog/stream
|
||||||
@ -29,6 +38,8 @@ export interface DialogRequest {
|
|||||||
userId: string;
|
userId: string;
|
||||||
/** 运行模式 */
|
/** 运行模式 */
|
||||||
mode: RunMode;
|
mode: RunMode;
|
||||||
|
/** 服务等级 */
|
||||||
|
serviceTier?: ServiceTier;
|
||||||
/** 压缩后的记忆数据(用于后端重启后恢复) */
|
/** 压缩后的记忆数据(用于后端重启后恢复) */
|
||||||
compactedData?: CompactedMemory;
|
compactedData?: CompactedMemory;
|
||||||
/** 压缩后产生的新消息 */
|
/** 压缩后产生的新消息 */
|
||||||
@ -59,7 +70,8 @@ export type SSEEventType =
|
|||||||
| 'error' // 错误
|
| 'error' // 错误
|
||||||
| 'warning' // 警告
|
| 'warning' // 警告
|
||||||
| 'notification' // 通知
|
| 'notification' // 通知
|
||||||
| 'depth_update'; // 深度更新
|
| 'depth_update' // 深度更新
|
||||||
|
| 'heartbeat'; // 心跳
|
||||||
|
|
||||||
/** text_delta 事件数据 */
|
/** text_delta 事件数据 */
|
||||||
export interface TextDeltaEvent {
|
export interface TextDeltaEvent {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { dialogManager, DialogSession } from "../services/dialogService";
|
|||||||
import { userInteractionManager } from "../services/userInteraction";
|
import { userInteractionManager } from "../services/userInteraction";
|
||||||
import { healthCheck } from "../services/apiClient";
|
import { healthCheck } from "../services/apiClient";
|
||||||
|
|
||||||
import type { RunMode } from "../types/api";
|
import type { RunMode, ServiceTier } from "../types/api";
|
||||||
|
|
||||||
/** 是否使用后端服务(可通过配置控制) */
|
/** 是否使用后端服务(可通过配置控制) */
|
||||||
let useBackendService = true;
|
let useBackendService = true;
|
||||||
@ -58,7 +58,8 @@ export async function handleUserMessage(
|
|||||||
panel: vscode.WebviewPanel,
|
panel: vscode.WebviewPanel,
|
||||||
text: string,
|
text: string,
|
||||||
extensionPath?: string,
|
extensionPath?: string,
|
||||||
mode?: RunMode
|
mode?: RunMode,
|
||||||
|
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||||
) {
|
) {
|
||||||
console.log("收到用户消息:", text);
|
console.log("收到用户消息:", text);
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ export async function handleUserMessage(
|
|||||||
// 尝试使用后端服务
|
// 尝试使用后端服务
|
||||||
if (useBackendService && extensionPath) {
|
if (useBackendService && extensionPath) {
|
||||||
try {
|
try {
|
||||||
await handleUserMessageWithBackend(panel, text, extensionPath, mode);
|
await handleUserMessageWithBackend(panel, text, extensionPath, mode, undefined, serviceTier);
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("后端服务不可用:", error);
|
console.error("后端服务不可用:", error);
|
||||||
@ -125,7 +126,8 @@ async function handleUserMessageWithBackend(
|
|||||||
text: string,
|
text: string,
|
||||||
extensionPath: string,
|
extensionPath: string,
|
||||||
mode?: RunMode,
|
mode?: RunMode,
|
||||||
reuseTaskId?: string // 可选,复用现有 taskId(用于 Plan 模式确认后继续执行)
|
reuseTaskId?: string, // 可选,复用现有 taskId(用于 Plan 模式确认后继续执行)
|
||||||
|
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const historyManager = ChatHistoryManager.getInstance();
|
const historyManager = ChatHistoryManager.getInstance();
|
||||||
|
|
||||||
@ -287,7 +289,8 @@ async function handleUserMessageWithBackend(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mode
|
mode,
|
||||||
|
serviceTier // 传递服务等级
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user