Add first turn option
This commit is contained in:
@@ -117,6 +117,7 @@ export const AssistantsPage: React.FC = () => {
|
||||
const handleCreate = async () => {
|
||||
const newAssistantPayload: Partial<Assistant> = {
|
||||
name: 'New Assistant',
|
||||
firstTurnMode: 'bot_first',
|
||||
opener: '',
|
||||
generatedOpenerEnabled: false,
|
||||
prompt: '',
|
||||
@@ -247,6 +248,7 @@ export const AssistantsPage: React.FC = () => {
|
||||
const isExternalConfig = selectedAssistant?.configMode === 'dify' || selectedAssistant?.configMode === 'fastgpt';
|
||||
const isNoneConfig = selectedAssistant?.configMode === 'none' || !selectedAssistant?.configMode;
|
||||
const canAdjustInterruptionSensitivity = selectedAssistant?.botCannotBeInterrupted !== true;
|
||||
const isBotFirstTurn = selectedAssistant?.firstTurnMode !== 'user_first';
|
||||
|
||||
return (
|
||||
<div className="flex h-full min-h-0 gap-6 animate-in fade-in">
|
||||
@@ -522,28 +524,63 @@ export const AssistantsPage: React.FC = () => {
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<label className="text-sm font-medium text-white flex items-center">
|
||||
<PhoneCall className="w-4 h-4 mr-2 text-primary"/> 首轮发言方
|
||||
</label>
|
||||
<div className="inline-flex rounded-lg border border-white/10 bg-white/5 p-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => updateAssistant('firstTurnMode', 'bot_first')}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
isBotFirstTurn
|
||||
? 'bg-primary text-primary-foreground shadow-sm'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
机器人先说
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => updateAssistant('firstTurnMode', 'user_first')}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
isBotFirstTurn
|
||||
? 'text-muted-foreground hover:text-foreground'
|
||||
: 'bg-primary text-primary-foreground shadow-sm'
|
||||
}`}
|
||||
>
|
||||
用户先说
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">决定通话接通后由谁先开始第一句对话。</p>
|
||||
</div>
|
||||
|
||||
<div className={`space-y-2 transition-opacity ${isBotFirstTurn ? 'opacity-100' : 'opacity-60'}`}>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<label className={`text-sm font-medium flex items-center ${isBotFirstTurn ? 'text-white' : 'text-muted-foreground'}`}>
|
||||
<MessageSquare className="w-4 h-4 mr-2 text-primary"/> 开场白
|
||||
</label>
|
||||
<div className="inline-flex rounded-lg border border-white/10 bg-white/5 p-1">
|
||||
<button
|
||||
type="button"
|
||||
disabled={!isBotFirstTurn}
|
||||
onClick={() => updateAssistant('generatedOpenerEnabled', false)}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
selectedAssistant.generatedOpenerEnabled === true
|
||||
? 'text-muted-foreground hover:text-foreground'
|
||||
: 'bg-primary text-primary-foreground shadow-sm'
|
||||
}`}
|
||||
} disabled:opacity-50 disabled:cursor-not-allowed`}
|
||||
>
|
||||
手动输入
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!isBotFirstTurn}
|
||||
onClick={() => updateAssistant('generatedOpenerEnabled', true)}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
selectedAssistant.generatedOpenerEnabled === true
|
||||
? 'bg-primary text-primary-foreground shadow-sm'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
} disabled:opacity-50 disabled:cursor-not-allowed`}
|
||||
>
|
||||
自动生成
|
||||
</button>
|
||||
@@ -552,14 +589,22 @@ export const AssistantsPage: React.FC = () => {
|
||||
<Input
|
||||
value={selectedAssistant.opener}
|
||||
onChange={(e) => updateAssistant('opener', e.target.value)}
|
||||
placeholder={selectedAssistant.generatedOpenerEnabled === true ? '将基于提示词自动生成开场白' : '例如:您好,我是您的专属AI助手...'}
|
||||
disabled={selectedAssistant.generatedOpenerEnabled === true}
|
||||
placeholder={
|
||||
!isBotFirstTurn
|
||||
? '当前为用户先说,开场白不会在首轮触发'
|
||||
: selectedAssistant.generatedOpenerEnabled === true
|
||||
? '将基于提示词自动生成开场白'
|
||||
: '例如:您好,我是您的专属AI助手...'
|
||||
}
|
||||
disabled={!isBotFirstTurn || selectedAssistant.generatedOpenerEnabled === true}
|
||||
className="bg-white/5 border-white/10 focus:border-primary/50 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{selectedAssistant.generatedOpenerEnabled === true
|
||||
? '通话接通后将根据提示词自动生成开场白。'
|
||||
: '接通通话后的第一句话。'}
|
||||
{!isBotFirstTurn
|
||||
? '已切换为“用户先说”,首轮不会发送开场白。'
|
||||
: selectedAssistant.generatedOpenerEnabled === true
|
||||
? '通话接通后将根据提示词自动生成开场白。'
|
||||
: '接通通话后的第一句话。'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1836,6 +1881,7 @@ export const DebugDrawer: React.FC<{
|
||||
mode: ttsEnabled ? 'audio' : 'text',
|
||||
},
|
||||
systemPrompt: assistant.prompt || '',
|
||||
firstTurnMode: assistant.firstTurnMode || 'bot_first',
|
||||
greeting: assistant.opener || '',
|
||||
generatedOpenerEnabled: assistant.generatedOpenerEnabled === true,
|
||||
bargeIn: {
|
||||
|
||||
Reference in New Issue
Block a user