@huyooo/ai-chat-frontend-react 0.1.2
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/dist/index.d.ts +401 -0
- package/dist/index.js +1421 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +1036 -0
- package/package.json +55 -0
- package/src/adapter.ts +162 -0
- package/src/components/ChatInput.tsx +368 -0
- package/src/components/ChatPanel.tsx +235 -0
- package/src/components/chat/messages/ExecutionSteps.tsx +234 -0
- package/src/components/chat/messages/MessageBubble.tsx +130 -0
- package/src/components/chat/ui/ChatHeader.tsx +301 -0
- package/src/components/chat/ui/WelcomeMessage.tsx +107 -0
- package/src/hooks/useChat.ts +464 -0
- package/src/index.ts +81 -0
- package/src/styles.css +1036 -0
- package/src/types/index.ts +165 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Chat 前端类型定义
|
|
3
|
+
* 与 Vue 版本保持一致
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** 搜索结果 */
|
|
7
|
+
export interface SearchResult {
|
|
8
|
+
title: string
|
|
9
|
+
url: string
|
|
10
|
+
snippet: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** 工具调用 */
|
|
14
|
+
export interface ToolCall {
|
|
15
|
+
name: string
|
|
16
|
+
args?: Record<string, unknown>
|
|
17
|
+
result?: string
|
|
18
|
+
status: 'running' | 'success' | 'error'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 模型提供商 */
|
|
22
|
+
export type ModelProvider = 'openrouter' | 'doubao' | 'deepseek' | 'qwen' | 'gemini' | 'ark'
|
|
23
|
+
|
|
24
|
+
/** 模型配置 */
|
|
25
|
+
export interface ModelConfig {
|
|
26
|
+
provider: ModelProvider
|
|
27
|
+
model: string
|
|
28
|
+
displayName: string
|
|
29
|
+
supportsTools: boolean
|
|
30
|
+
supportsWebSearch: boolean
|
|
31
|
+
supportedThinkingModes: ThinkingMode[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 思考模式 */
|
|
35
|
+
export type ThinkingMode = 'enabled' | 'disabled'
|
|
36
|
+
|
|
37
|
+
/** 聊天模式 */
|
|
38
|
+
export type ChatMode = 'agent' | 'ask'
|
|
39
|
+
|
|
40
|
+
/** 聊天消息 */
|
|
41
|
+
export interface ChatMessage {
|
|
42
|
+
id: string
|
|
43
|
+
role: 'user' | 'assistant'
|
|
44
|
+
content: string
|
|
45
|
+
images?: string[]
|
|
46
|
+
thinking?: string
|
|
47
|
+
thinkingComplete?: boolean
|
|
48
|
+
searchResults?: SearchResult[]
|
|
49
|
+
searching?: boolean
|
|
50
|
+
toolCalls?: ToolCall[]
|
|
51
|
+
copied?: boolean
|
|
52
|
+
loading?: boolean
|
|
53
|
+
timestamp?: Date
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 会话记录 */
|
|
57
|
+
export interface SessionRecord {
|
|
58
|
+
id: string
|
|
59
|
+
title: string
|
|
60
|
+
model: string
|
|
61
|
+
mode: ChatMode
|
|
62
|
+
createdAt: Date
|
|
63
|
+
updatedAt: Date
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 消息记录 */
|
|
67
|
+
export interface MessageRecord {
|
|
68
|
+
id: string
|
|
69
|
+
sessionId: string
|
|
70
|
+
role: 'user' | 'assistant'
|
|
71
|
+
content: string
|
|
72
|
+
thinking?: string
|
|
73
|
+
toolCalls?: string
|
|
74
|
+
searchResults?: string
|
|
75
|
+
timestamp: Date
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 默认模型列表 */
|
|
79
|
+
export const DEFAULT_MODELS: ModelConfig[] = [
|
|
80
|
+
{
|
|
81
|
+
provider: 'openrouter',
|
|
82
|
+
model: 'anthropic/claude-opus-4.5',
|
|
83
|
+
displayName: 'Claude Opus 4.5',
|
|
84
|
+
supportsTools: true,
|
|
85
|
+
supportsWebSearch: true,
|
|
86
|
+
supportedThinkingModes: ['enabled', 'disabled'],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
provider: 'doubao',
|
|
90
|
+
model: 'doubao-seed-1-6-251015',
|
|
91
|
+
displayName: 'Doubao Seed',
|
|
92
|
+
supportsTools: true,
|
|
93
|
+
supportsWebSearch: true,
|
|
94
|
+
supportedThinkingModes: ['enabled', 'disabled'],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
provider: 'deepseek',
|
|
98
|
+
model: 'deepseek-v3-1-terminus',
|
|
99
|
+
displayName: 'DeepSeek V3',
|
|
100
|
+
supportsTools: true,
|
|
101
|
+
supportsWebSearch: true,
|
|
102
|
+
supportedThinkingModes: ['enabled', 'disabled'],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
provider: 'qwen',
|
|
106
|
+
model: 'qwen3-max-preview',
|
|
107
|
+
displayName: 'Qwen Max',
|
|
108
|
+
supportsTools: true,
|
|
109
|
+
supportsWebSearch: true,
|
|
110
|
+
supportedThinkingModes: ['enabled', 'disabled'],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
provider: 'gemini',
|
|
114
|
+
model: 'gemini-3-pro-preview',
|
|
115
|
+
displayName: 'Gemini 3 Pro',
|
|
116
|
+
supportsTools: true,
|
|
117
|
+
supportsWebSearch: true,
|
|
118
|
+
supportedThinkingModes: ['enabled', 'disabled'],
|
|
119
|
+
},
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
// ================ 以下为向后兼容的类型 ================
|
|
123
|
+
|
|
124
|
+
/** @deprecated 使用 SessionRecord */
|
|
125
|
+
export interface ChatSession {
|
|
126
|
+
id: string
|
|
127
|
+
title: string
|
|
128
|
+
messages: ChatMessage[]
|
|
129
|
+
createdAt: Date
|
|
130
|
+
updatedAt: Date
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** 音视频操作类型 */
|
|
134
|
+
export interface MediaOperation {
|
|
135
|
+
id: string
|
|
136
|
+
type: 'clip' | 'transcode' | 'merge' | 'extract_audio' | 'add_subtitle' | 'analyze'
|
|
137
|
+
description: string
|
|
138
|
+
sourceFiles: string[]
|
|
139
|
+
targetFile?: string
|
|
140
|
+
parameters?: Record<string, unknown>
|
|
141
|
+
status?: 'pending' | 'applied' | 'rejected'
|
|
142
|
+
preview?: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** @deprecated 使用字符串枚举 */
|
|
146
|
+
export type AiModel = 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview'
|
|
147
|
+
|
|
148
|
+
export enum FileType {
|
|
149
|
+
FOLDER = 'folder',
|
|
150
|
+
IMAGE = 'image',
|
|
151
|
+
VIDEO = 'video',
|
|
152
|
+
AUDIO = 'audio',
|
|
153
|
+
TEXT = 'text',
|
|
154
|
+
PDF = 'pdf',
|
|
155
|
+
CODE = 'code',
|
|
156
|
+
ARCHIVE = 'archive',
|
|
157
|
+
OTHER = 'other'
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface DiffStat {
|
|
161
|
+
file: string
|
|
162
|
+
additions: number
|
|
163
|
+
deletions: number
|
|
164
|
+
type: 'modified' | 'added' | 'deleted'
|
|
165
|
+
}
|