Skip to content

Commit 977d541

Browse files
committed
feat: integrate auto-question functionality into the message queue system, removing the previous auto-question component and related hooks
1 parent af10083 commit 977d541

11 files changed

Lines changed: 282 additions & 754 deletions

File tree

src/renderer/src/components/pages/chat/ChatInput.tsx

Lines changed: 1 addition & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,18 @@ import {
1010
Input,
1111
Button,
1212
Alert,
13-
Switch,
1413
Tooltip,
1514
Space,
16-
Select,
17-
Dropdown,
1815
Flex,
1916
Badge,
20-
Upload,
2117
Image,
2218
Tag
2319
} from 'antd'
2420
import {
2521
SendOutlined,
2622
StopOutlined,
2723
SettingOutlined,
28-
QuestionCircleOutlined,
29-
BulbOutlined,
30-
DownOutlined,
31-
PlaySquareOutlined,
3224
HourglassOutlined,
33-
PlusOutlined,
3425
CaretRightOutlined,
3526
PaperClipOutlined,
3627
CloseOutlined,
@@ -151,141 +142,8 @@ const AttachmentPreview: React.FC<{
151142
}
152143

153144
const { TextArea } = Input
154-
const { Option } = Select
155-
156-
// 自动提问控件组件
157-
interface AutoQuestionControlsProps {
158-
enabled: boolean
159-
mode: 'ai' | 'preset'
160-
selectedListId?: string
161-
promptLists: any[]
162-
disabled: boolean
163-
onChange?: (enabled: boolean, mode: 'ai' | 'preset', listId?: string) => void
164-
}
165-
166-
function AutoQuestionControls({
167-
enabled,
168-
mode,
169-
selectedListId,
170-
promptLists,
171-
disabled,
172-
onChange
173-
}: AutoQuestionControlsProps) {
174-
const handleEnabledChange = (checked: boolean) => {
175-
let finalListId = selectedListId
176-
// 如果开启自动提问且是预设模式,但没有选择列表,使用第一个可用列表
177-
if (checked && mode === 'preset' && !selectedListId && promptLists.length > 0) {
178-
finalListId = promptLists[0].id
179-
}
180-
console.log('AutoQuestionControls handleEnabledChange:', {
181-
checked,
182-
mode,
183-
selectedListId,
184-
finalListId,
185-
promptListsLength: promptLists.length
186-
})
187-
onChange?.(checked, mode, finalListId)
188-
}
189-
190-
const handleModeChange = (newMode: 'ai' | 'preset') => {
191-
onChange?.(
192-
enabled,
193-
newMode,
194-
newMode === 'preset' ? selectedListId || promptLists[0]?.id : undefined
195-
)
196-
}
197-
198-
const handleListChange = (listId: string) => {
199-
onChange?.(enabled, mode, listId)
200-
}
201-
202-
const getCurrentPromptList = () => {
203-
return promptLists.find((list) => list.id === selectedListId)
204-
}
205-
206-
const modeOptions = [
207-
{
208-
key: 'ai',
209-
label: (
210-
<Space>
211-
<QuestionCircleOutlined />
212-
AI自动追问
213-
</Space>
214-
)
215-
},
216-
{
217-
key: 'preset',
218-
label: (
219-
<Space>
220-
<BulbOutlined />
221-
预设列表提问
222-
</Space>
223-
)
224-
}
225-
]
226-
227-
const dropdownMenu = {
228-
items: modeOptions.map((option) => ({
229-
key: option.key,
230-
label: option.label,
231-
onClick: () => handleModeChange(option.key as 'ai' | 'preset')
232-
}))
233-
}
234145

235-
return (
236-
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
237-
<Tooltip title="开启后,AI回答完成将自动继续提问">
238-
<Space align="center" size="small">
239-
<Switch
240-
size="small"
241-
checked={enabled}
242-
onChange={handleEnabledChange}
243-
disabled={disabled}
244-
/>
245-
<span style={{ fontSize: '12px' }}>自动提问</span>
246-
</Space>
247-
</Tooltip>
248-
249-
{enabled && (
250-
<>
251-
<Dropdown menu={dropdownMenu} trigger={['click']} disabled={disabled}>
252-
<Button size="small" style={{ fontSize: '11px' }}>
253-
{mode === 'ai' ? (
254-
<Space size={4}>
255-
<QuestionCircleOutlined />
256-
AI追问
257-
</Space>
258-
) : (
259-
<Space size={4}>
260-
<BulbOutlined />
261-
预设列表
262-
</Space>
263-
)}
264-
<DownOutlined />
265-
</Button>
266-
</Dropdown>
267-
268-
{mode === 'preset' && (
269-
<Select
270-
size="small"
271-
value={selectedListId}
272-
onChange={handleListChange}
273-
placeholder="选择列表"
274-
style={{ minWidth: 120, fontSize: '11px' }}
275-
disabled={disabled || promptLists.length === 0}
276-
>
277-
{promptLists.map((list) => (
278-
<Option key={list.id} value={list.id}>
279-
{list.name}
280-
</Option>
281-
))}
282-
</Select>
283-
)}
284-
</>
285-
)}
286-
</div>
287-
)
288-
}
146+
// 注意:自动提问功能已整合到消息队列中,可通过消息队列面板访问AI追问和导入提示词列表功能
289147

290148
interface ChatInputProps {
291149
value: string
@@ -299,12 +157,6 @@ interface ChatInputProps {
299157
defaultModelId?: string
300158
onModelChange: (modelId: string) => void
301159
onOpenSettings?: () => void
302-
// 自动提问相关
303-
autoQuestionEnabled?: boolean
304-
autoQuestionMode?: 'ai' | 'preset'
305-
autoQuestionListId?: string
306-
onAutoQuestionChange?: (enabled: boolean, mode: 'ai' | 'preset', listId?: string) => void
307-
onTriggerFollowUpQuestion?: () => Promise<void>
308160
// 消息队列相关
309161
queueEnabled?: boolean
310162
queuePendingCount?: number
@@ -337,11 +189,6 @@ const ChatInput = React.memo(
337189
defaultModelId,
338190
onModelChange,
339191
onOpenSettings,
340-
autoQuestionEnabled = false,
341-
autoQuestionMode = 'ai',
342-
autoQuestionListId,
343-
onAutoQuestionChange,
344-
onTriggerFollowUpQuestion,
345192
queueEnabled = false,
346193
queuePendingCount = 0,
347194
queuePaused = false,
@@ -699,42 +546,6 @@ const ChatInput = React.memo(
699546
size="small"
700547
/>
701548
</div>
702-
703-
{/* 自动提问控件 */}
704-
<div>
705-
<AutoQuestionControls
706-
enabled={autoQuestionEnabled}
707-
mode={autoQuestionMode}
708-
selectedListId={autoQuestionListId}
709-
promptLists={settings.promptLists || []}
710-
disabled={false}
711-
onChange={onAutoQuestionChange}
712-
/>
713-
</div>
714-
715-
{/* 立即追问按钮 */}
716-
{autoQuestionEnabled && (
717-
<Tooltip
718-
title={`立即触发一次${autoQuestionMode === 'ai' ? 'AI' : '预设列表'}追问`}
719-
>
720-
<Button
721-
type="text"
722-
size="small"
723-
icon={<PlaySquareOutlined />}
724-
onClick={async () => {
725-
try {
726-
await onTriggerFollowUpQuestion?.()
727-
} catch (error) {
728-
console.error('立即追问失败:', error)
729-
}
730-
}}
731-
disabled={disabled || loading}
732-
style={{ fontSize: '11px', color: '#1890ff' }}
733-
>
734-
立即追问
735-
</Button>
736-
</Tooltip>
737-
)}
738549
</Space>
739550

740551
{/* 发送/停止/队列按钮 */}

0 commit comments

Comments
 (0)