feat: 重构对话功能
This commit is contained in:
62
electron/gateway/types.ts
Normal file
62
electron/gateway/types.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { RawMessage } from '@src/pages/home/model/ChatModel';
|
||||
|
||||
/// Gateway 向 Renderer 推送的事件类型
|
||||
export type GatewayEvent =
|
||||
| {
|
||||
type: 'chat:delta';
|
||||
sessionKey: string;
|
||||
runId: string;
|
||||
delta: string;
|
||||
}
|
||||
| {
|
||||
type: 'chat:final';
|
||||
sessionKey: string;
|
||||
runId: string;
|
||||
message: RawMessage;
|
||||
}
|
||||
| {
|
||||
type: 'chat:error';
|
||||
sessionKey: string;
|
||||
runId: string;
|
||||
error: string;
|
||||
}
|
||||
| {
|
||||
type: 'chat:aborted';
|
||||
sessionKey: string;
|
||||
runId: string;
|
||||
}
|
||||
| {
|
||||
type: 'gateway:status';
|
||||
status: 'connected' | 'disconnected' | 'reconnecting';
|
||||
};
|
||||
|
||||
/// Gateway RPC 方法参数映射
|
||||
export interface GatewayRpcParams {
|
||||
'chat.send': {
|
||||
sessionKey: string;
|
||||
message: RawMessage;
|
||||
options?: {
|
||||
providerAccountId?: string;
|
||||
};
|
||||
};
|
||||
'chat.history': {
|
||||
sessionKey: string;
|
||||
limit?: number;
|
||||
};
|
||||
'chat.abort': {
|
||||
sessionKey: string;
|
||||
};
|
||||
'session.list': Record<string, never>;
|
||||
'provider.list': Record<string, never>;
|
||||
'provider.getDefault': Record<string, never>;
|
||||
}
|
||||
|
||||
/// Gateway RPC 方法返回值映射
|
||||
export interface GatewayRpcReturns {
|
||||
'chat.send': { runId: string };
|
||||
'chat.history': RawMessage[];
|
||||
'chat.abort': void;
|
||||
'session.list': string[];
|
||||
'provider.list': { accounts: any[]; defaultAccountId: string | null };
|
||||
'provider.getDefault': { accountId: string | null };
|
||||
}
|
||||
Reference in New Issue
Block a user