Add ASR interim results support in Assistant model and API
- Introduced `asr_interim_enabled` field in the Assistant model to control interim ASR results. - Updated AssistantBase and AssistantUpdate schemas to include the new field. - Modified the database schema to add the `asr_interim_enabled` column. - Enhanced runtime metadata to reflect interim ASR settings. - Updated API endpoints and tests to validate the new functionality. - Adjusted documentation to include details about interim ASR results configuration.
This commit is contained in:
@@ -259,6 +259,7 @@ export const AssistantsPage: React.FC = () => {
|
||||
speed: 1,
|
||||
hotwords: [],
|
||||
tools: [],
|
||||
asrInterimEnabled: false,
|
||||
botCannotBeInterrupted: false,
|
||||
interruptionSensitivity: 180,
|
||||
configMode: 'platform',
|
||||
@@ -1358,6 +1359,41 @@ export const AssistantsPage: React.FC = () => {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<label className="text-sm font-medium text-white flex items-center">
|
||||
<Mic className="w-4 h-4 mr-2 text-primary"/> 离线 ASR 中间结果
|
||||
</label>
|
||||
<div className="inline-flex rounded-lg border border-white/10 bg-white/5 p-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => updateAssistant('asrInterimEnabled', false)}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
selectedAssistant.asrInterimEnabled === true
|
||||
? 'text-muted-foreground hover:text-foreground'
|
||||
: 'bg-primary text-primary-foreground shadow-sm'
|
||||
}`}
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => updateAssistant('asrInterimEnabled', true)}
|
||||
className={`px-3 py-1 text-xs rounded-md transition-colors ${
|
||||
selectedAssistant.asrInterimEnabled === true
|
||||
? 'bg-primary text-primary-foreground shadow-sm'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
开启
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
仅影响离线 ASR 模式(OpenAI Compatible / buffered)。默认关闭。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<label className="text-sm font-medium text-white flex items-center">
|
||||
|
||||
@@ -87,6 +87,7 @@ const mapAssistant = (raw: AnyRecord): Assistant => ({
|
||||
speed: Number(readField(raw, ['speed'], 1)),
|
||||
hotwords: readField(raw, ['hotwords'], []),
|
||||
tools: normalizeToolIdList(readField(raw, ['tools'], [])),
|
||||
asrInterimEnabled: Boolean(readField(raw, ['asrInterimEnabled', 'asr_interim_enabled'], false)),
|
||||
botCannotBeInterrupted: Boolean(readField(raw, ['botCannotBeInterrupted', 'bot_cannot_be_interrupted'], false)),
|
||||
interruptionSensitivity: Number(readField(raw, ['interruptionSensitivity', 'interruption_sensitivity'], 500)),
|
||||
configMode: readField(raw, ['configMode', 'config_mode'], 'platform') as 'platform' | 'dify' | 'fastgpt' | 'none',
|
||||
@@ -284,6 +285,7 @@ export const createAssistant = async (data: Partial<Assistant>): Promise<Assista
|
||||
speed: data.speed ?? 1,
|
||||
hotwords: data.hotwords || [],
|
||||
tools: normalizeToolIdList(data.tools || []),
|
||||
asrInterimEnabled: data.asrInterimEnabled ?? false,
|
||||
botCannotBeInterrupted: data.botCannotBeInterrupted ?? false,
|
||||
interruptionSensitivity: data.interruptionSensitivity ?? 500,
|
||||
configMode: data.configMode || 'platform',
|
||||
@@ -316,6 +318,7 @@ export const updateAssistant = async (id: string, data: Partial<Assistant>): Pro
|
||||
speed: data.speed,
|
||||
hotwords: data.hotwords,
|
||||
tools: data.tools === undefined ? undefined : normalizeToolIdList(data.tools),
|
||||
asrInterimEnabled: data.asrInterimEnabled,
|
||||
botCannotBeInterrupted: data.botCannotBeInterrupted,
|
||||
interruptionSensitivity: data.interruptionSensitivity,
|
||||
configMode: data.configMode,
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface Assistant {
|
||||
speed: number;
|
||||
hotwords: string[];
|
||||
tools?: string[]; // IDs of enabled tools
|
||||
asrInterimEnabled?: boolean;
|
||||
botCannotBeInterrupted?: boolean;
|
||||
interruptionSensitivity?: number; // In ms
|
||||
configMode?: 'platform' | 'dify' | 'fastgpt' | 'none';
|
||||
|
||||
Reference in New Issue
Block a user