feie9456 47e6da63e9 feat: 优化侧边栏,加入深度搜索
Co-authored-by: Copilot <copilot@github.com>
2026-04-26 22:05:23 +08:00

211 lines
3.9 KiB
TypeScript

export type ViewKey =
| "chat"
| "settings"
| "models"
| "prompts"
| "data"
| "about"
export type MessageRole = "user" | "assistant" | "tool"
export type RequestState =
| "idle"
| "requesting"
| "generating"
| "failed"
| "stopped"
export type ThemeMode = "light" | "dark" | "system"
export type ReasoningEffort = "default" | "minimal" | "low" | "medium" | "high"
export type ToolChoiceMode = "auto" | "none" | "required"
export type ToolExecutionState = "pending" | "completed" | "failed"
export type TokenUsage = {
promptTokens?: number
completionTokens?: number
totalTokens?: number
}
export type ModelParameters = {
temperature: number
maxContextLength: number
maxOutputTokens: number
stream: boolean
timeoutSeconds: number
reasoningEffort: ReasoningEffort
}
export type ChatToolCall = {
id: string
name: string
arguments: string
status?: ToolExecutionState
result?: string
error?: string
}
export type AskQuestionOption = {
label: string
value: string
description?: string
}
export type AskQuestion = {
id: string
label: string
type: "single" | "multiple" | "text"
required?: boolean
placeholder?: string
options?: AskQuestionOption[]
}
export type AskQuestionsPayload = {
title?: string
description?: string
questions: AskQuestion[]
}
export type AskQuestionsAnswer = {
questionId: string
label: string
value: string | string[]
}
export type ChatToolDefinition = {
type: "function"
function: {
name: string
description?: string
parameters?: Record<string, unknown>
}
}
export type ToolSettings = {
functionCallingEnabled: boolean
toolChoice: ToolChoiceMode
enabledToolIds: string[]
}
export type RuntimeConfig = {
service?: ServiceConfig
model?: ModelConfig
prompt?: PromptTemplate
modelName: string
parameters: ModelParameters
systemPrompt: string
tools: ChatToolDefinition[]
toolChoice: ToolChoiceMode
errors: string[]
}
export type ChatMessage = {
id: string
role: MessageRole
content: string
createdAt: string
updatedAt?: string
status?: RequestState | "done"
model?: string
elapsedMs?: number
usage?: TokenUsage
error?: string
reasoningContent?: string
toolCallId?: string
toolName?: string
toolCalls?: ChatToolCall[]
}
export type DeepSearchSnippet = {
messageId: string
role: MessageRole
excerpt: string
}
export type DeepSearchResult = {
sessionId: string
title: string
updatedAt: string
matchCount: number
snippets: DeepSearchSnippet[]
}
export type DeepSearchState = {
open: boolean
query: string
status: "idle" | "searching" | "done"
scanned: number
total: number
results: DeepSearchResult[]
}
export type ServiceConfig = {
id: string
name: string
baseUrl: string
apiKey: string
defaultModel: string
}
export type ModelConfig = {
id: string
name: string
displayName: string
serviceId?: string
isDefault?: boolean
parameters: ModelParameters
updatedAt: string
}
export type PromptTemplate = {
id: string
title: string
content: string
isDefault?: boolean
createdAt: string
updatedAt: string
}
export type ChatSession = {
id: string
title: string
createdAt: string
updatedAt: string
messages: ChatMessage[]
status: RequestState
error?: string
serviceId?: string
modelId?: string
modelName?: string
promptId?: string
systemPrompt?: string
temporary?: boolean
}
export type AppSettings = ModelParameters & {
activeServiceId: string
activeModelId: string
systemPrompt: string
chatQuickConfigOpen: boolean
theme: ThemeMode
compactMode: boolean
fontScale: number
showAdvanced: boolean
proxyEnabled: boolean
proxyUrl: string
proxyHeaders: string
tools: ToolSettings
services: ServiceConfig[]
}
export type AppData = {
version: 1
currentSessionId: string
sessions: ChatSession[]
settings: AppSettings
models: ModelConfig[]
prompts: PromptTemplate[]
}