qwen-audio-agent 2.1.0 → 2.2.0
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/README.md +6 -3
- package/README_ZH.md +6 -3
- package/cli/package.json +1 -1
- package/cli/src/config-command.mjs +33 -2
- package/cli/src/gateway-service.mjs +7 -1
- package/config/frontend-agent/LIVE_PROMPT.md +64 -0
- package/desktop/src/i18n.mjs +1 -1
- package/desktop/src/settings-config.mjs +10 -24
- package/docs/configuration/frontend.md +29 -12
- package/docs/configuration/frontend.zh.md +28 -12
- package/docs/contract.md +2 -0
- package/docs/contract.zh.md +2 -0
- package/docs/extensions.md +14 -0
- package/docs/extensions.zh.md +11 -0
- package/docs/getting-started/install.md +3 -0
- package/docs/getting-started/install.zh.md +3 -0
- package/docs/getting-started/mobile.md +8 -2
- package/docs/getting-started/mobile.zh.md +5 -0
- package/docs/guides/web-search.md +17 -1
- package/docs/guides/web-search.zh.md +15 -1
- package/docs/operations/troubleshooting.md +30 -0
- package/docs/operations/troubleshooting.zh.md +26 -0
- package/docs/voice-frontends/custom-provider.md +18 -3
- package/docs/voice-frontends/custom-provider.zh.md +18 -3
- package/docs/voice-frontends/google-live.md +7 -3
- package/docs/voice-frontends/google-live.zh.md +6 -3
- package/docs/voice-frontends/gpt-live-1.md +149 -0
- package/docs/voice-frontends/gpt-live-1.zh.md +114 -0
- package/docs/voice-frontends/{gpt-live.md → openai-realtime.md} +12 -5
- package/docs/voice-frontends/{gpt-live.zh.md → openai-realtime.zh.md} +11 -5
- package/docs/voice-frontends/qwen-audio-live.md +164 -0
- package/docs/voice-frontends/qwen-audio-live.zh.md +122 -0
- package/docs/voice-frontends/qwen-audio-realtime.md +2 -1
- package/docs/voice-frontends/qwen-audio-realtime.zh.md +2 -1
- package/docs/voice-frontends/qwen-omni-realtime.md +1 -1
- package/docs/voice-frontends/qwen-omni-realtime.zh.md +1 -1
- package/package.json +13 -4
- package/scripts/patch-build-node-gyp.mjs +63 -0
- package/scripts/prepare-build.mjs +2 -0
- package/scripts/verify-package.mjs +3 -0
- package/server/package.json +2 -2
- package/server/src/conversation/frontend-agent-context.mjs +18 -5
- package/server/src/core/citation.mjs +8 -2
- package/server/src/core/config.mjs +16 -5
- package/server/src/core/request-security.mjs +7 -1
- package/server/src/frontend/frontend-tools.mjs +14 -1
- package/server/src/frontend/retrieval/providers/bing.mjs +23 -12
- package/server/src/frontend/retrieval/providers/factory.mjs +9 -1
- package/server/src/frontend/retrieval/providers/mcp.mjs +17 -9
- package/server/src/frontend/retrieval/providers/so360.mjs +23 -12
- package/server/src/frontend/tools/agent-task-runtime.mjs +22 -4
- package/server/src/frontend/tools/tool-call-handler.mjs +56 -20
- package/server/src/memory/providers/markdown/context-store.mjs +3 -1
- package/server/src/orchestration/session-task-coordinator.mjs +4 -1
- package/server/src/orchestration/task-operations.mjs +5 -3
- package/server/src/orchestration/task-updates.mjs +2 -1
- package/server/src/transport/gateway-client-transport.mjs +19 -0
- package/server/src/transport/webrtc/protocol.mjs +1 -1
- package/server/src/voice/audio-stream-diagnostics.mjs +139 -0
- package/server/src/voice/native-delegation-runtime.mjs +360 -0
- package/server/src/voice/providers/dashscope-live.mjs +93 -0
- package/server/src/voice/providers/dashscope.mjs +12 -4
- package/server/src/voice/providers/doubao-seeduplex-protocol.mjs +54 -0
- package/server/src/voice/providers/doubao-seeduplex.mjs +6 -5
- package/server/src/voice/providers/ga-protocol.mjs +7 -2
- package/server/src/voice/providers/google-live-protocol.mjs +124 -34
- package/server/src/voice/providers/google-live.mjs +6 -5
- package/server/src/voice/providers/gpt-live-1-protocol.mjs +597 -0
- package/server/src/voice/providers/gpt-live-1.mjs +3 -0
- package/server/src/voice/providers/gpt-live-client-context.mjs +182 -0
- package/server/src/voice/providers/openai-live.mjs +150 -0
- package/server/src/voice/providers/{gpt-live.mjs → openai-realtime.mjs} +15 -14
- package/server/src/voice/providers/provider-registry.mjs +11 -1
- package/server/src/voice/providers/qwen-live-protocol.mjs +399 -0
- package/server/src/voice/providers/registry.mjs +45 -10
- package/server/src/voice/providers/runtime-configuration.mjs +17 -6
- package/server/src/voice/providers/stepfun.mjs +1 -1
- package/server/src/voice/realtime-input-runtime.mjs +56 -20
- package/server/src/voice/realtime-presentation-runtime.mjs +21 -4
- package/server/src/voice/realtime-provider-session.mjs +59 -14
- package/server/src/voice/realtime-provider.mjs +332 -36
- package/server/src/voice/realtime-session-runtime.mjs +207 -16
- package/server/src/voice/realtime-task-presentation.mjs +6 -2
- package/server/src/voice/realtime-turn-state.mjs +33 -2
- package/shared/gateway/client-sdk.mjs +15 -5
- package/shared/gateway/websocket-auth.mjs +2 -1
- package/shared/protocol/gateway-events.mjs +31 -0
- package/shared/realtime-legacy-environment.mjs +37 -8
- package/shared/realtime-model-catalog.mjs +12 -10
- package/shared/realtime-models/README.md +10 -2
- package/shared/realtime-models/dashscope.mjs +11 -0
- package/shared/realtime-models/{google-live.mjs → google.mjs} +1 -1
- package/shared/realtime-models/openai.mjs +24 -0
- package/shared/realtime-models/profile.mjs +6 -3
- package/shared/realtime-models/{doubao-seeduplex.mjs → volcengine.mjs} +1 -1
- package/shared/realtime-provider-catalog.mjs +7 -6
- package/shared/realtime-provider-definitions.mjs +87 -22
- package/shared/runtime-environment.mjs +2 -2
- package/shared/web-search-configuration.mjs +14 -2
- package/tui/package.json +2 -2
- package/tui/src/index.mjs +14 -9
- package/tui/src/runtime-configuration.mjs +2 -0
- package/tui/src/terminal-commands.mjs +40 -0
- package/tui/src/text-cli.mjs +10 -1
- package/web/dist/assets/index-Bc2Q04J9.css +1 -0
- package/web/dist/assets/index-bY4DFXKT.js +96 -0
- package/web/dist/index.html +2 -2
- package/shared/realtime-models/gpt-live.mjs +0 -10
- package/web/dist/assets/index-8erKDCr2.css +0 -1
- package/web/dist/assets/index-Cs4hYWbS.js +0 -96
|
@@ -77,6 +77,8 @@ function conversationItem(item) {
|
|
|
77
77
|
export function createDoubaoSeeduplexProtocol() {
|
|
78
78
|
let activeResponseId = ''
|
|
79
79
|
let pendingUserText = ''
|
|
80
|
+
let activeAsrItemId = ''
|
|
81
|
+
let endedAsrItemId = ''
|
|
80
82
|
|
|
81
83
|
const responseId = event => (
|
|
82
84
|
event.response_id
|
|
@@ -187,6 +189,58 @@ export function createDoubaoSeeduplexProtocol() {
|
|
|
187
189
|
response: { ...event.response, status: 'cancelled' },
|
|
188
190
|
})
|
|
189
191
|
}
|
|
192
|
+
// Doubao ASR events arrive with item_id but the Gateway input pipeline
|
|
193
|
+
// expects realtime-protocol field names and a paired speech boundary. The
|
|
194
|
+
// live endpoint never emits input_audio_buffer.speech_started,
|
|
195
|
+
// speech_stopped or committed, so both ends of one utterance are
|
|
196
|
+
// synthesized from the transcription events of a single item_id.
|
|
197
|
+
if (event?.type === 'conversation.item.input_audio_transcription.started') {
|
|
198
|
+
const itemId = event.item_id || id('item')
|
|
199
|
+
activeAsrItemId = itemId
|
|
200
|
+
endedAsrItemId = ''
|
|
201
|
+
return [{
|
|
202
|
+
type: 'input_audio_buffer.speech_started',
|
|
203
|
+
item_id: itemId,
|
|
204
|
+
event_id: event.event_id,
|
|
205
|
+
}]
|
|
206
|
+
}
|
|
207
|
+
if (event?.type === 'conversation.item.input_audio_transcription.delta') {
|
|
208
|
+
return [{
|
|
209
|
+
...event,
|
|
210
|
+
item_id: event.item_id || activeAsrItemId,
|
|
211
|
+
text: '',
|
|
212
|
+
stash: String(event.delta || ''),
|
|
213
|
+
}]
|
|
214
|
+
}
|
|
215
|
+
if (event?.type === 'conversation.item.input_audio_transcription.completed') {
|
|
216
|
+
const itemId = event.item_id || activeAsrItemId
|
|
217
|
+
const events = []
|
|
218
|
+
// The close of an utterance is the only end boundary this provider
|
|
219
|
+
// sends, so it is synthesized here from the final transcript of the
|
|
220
|
+
// same item_id that opened the utterance above. Emitting it only for
|
|
221
|
+
// the item that is still open keeps the pair 1:1: a final that belongs
|
|
222
|
+
// to another (older) item stays transcript-only, so a late event can
|
|
223
|
+
// never close the turn that is speaking now.
|
|
224
|
+
// `input_audio_buffer.committed` rather than `speech_stopped` on
|
|
225
|
+
// purpose: the input pipeline ends the turn for both, but only
|
|
226
|
+
// `speech_stopped` arms the response-start watchdog, which would
|
|
227
|
+
// report a missing reply and reconnect the session whenever a duplex
|
|
228
|
+
// model answers late or stays silent.
|
|
229
|
+
if (itemId && itemId === activeAsrItemId && itemId !== endedAsrItemId) {
|
|
230
|
+
endedAsrItemId = itemId
|
|
231
|
+
events.push({
|
|
232
|
+
type: 'input_audio_buffer.committed',
|
|
233
|
+
item_id: itemId,
|
|
234
|
+
event_id: event.event_id,
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
events.push({
|
|
238
|
+
...event,
|
|
239
|
+
item_id: itemId,
|
|
240
|
+
transcript: String(event.text || event.transcript || ''),
|
|
241
|
+
})
|
|
242
|
+
return events
|
|
243
|
+
}
|
|
190
244
|
return normalizeResponseEvent(event)
|
|
191
245
|
},
|
|
192
246
|
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
import { isRecoverableRealtimeInactivityError } from '../realtime-errors.mjs'
|
|
14
14
|
import { createDoubaoSeeduplexProtocol } from './doubao-seeduplex-protocol.mjs'
|
|
15
15
|
|
|
16
|
-
const connection = providerRuntimeConfiguration('doubao-seeduplex')
|
|
16
|
+
const connection = providerRuntimeConfiguration('doubao-seeduplex', { provider: 'volcengine' })
|
|
17
17
|
|
|
18
18
|
function modelProfile() {
|
|
19
19
|
return resolveRealtimeModelProfile(
|
|
20
20
|
connection.model,
|
|
21
|
-
'
|
|
21
|
+
'volcengine',
|
|
22
22
|
config.realtimeModelCatalogs,
|
|
23
23
|
)
|
|
24
24
|
}
|
|
@@ -29,7 +29,8 @@ function cleanText(value) {
|
|
|
29
29
|
|
|
30
30
|
export const doubaoSeeduplexProvider = {
|
|
31
31
|
key: 'doubao-seeduplex',
|
|
32
|
-
|
|
32
|
+
provider: 'volcengine',
|
|
33
|
+
label: 'Volcengine',
|
|
33
34
|
aliases: ['doubao', 'seeduplex', 'volcengine'],
|
|
34
35
|
inputSampleRate: 16000,
|
|
35
36
|
outputSampleRate: 24000,
|
|
@@ -46,10 +47,10 @@ export const doubaoSeeduplexProvider = {
|
|
|
46
47
|
},
|
|
47
48
|
model: () => connection.model,
|
|
48
49
|
modelProfile,
|
|
49
|
-
modelCatalog: () => realtimeModelCatalog('
|
|
50
|
+
modelCatalog: () => realtimeModelCatalog('volcengine', config.realtimeModelCatalogs).profiles,
|
|
50
51
|
voice: () => cleanText(connection.voice) || modelProfile().sessionDefaults.voice,
|
|
51
52
|
isConfigured: () => connection.configured,
|
|
52
|
-
missingConfigurationMessage: '请先选择
|
|
53
|
+
missingConfigurationMessage: '请先选择 volcengine 并配置 QWEN_AUDIO_REALTIME_API_KEY',
|
|
53
54
|
connectTimeoutMessage: '连接 Doubao Seeduplex Realtime 超时',
|
|
54
55
|
url: () => connection.endpoint,
|
|
55
56
|
headers: () => ({ 'X-Api-Key': connection.credential }),
|
|
@@ -31,7 +31,8 @@ const RESPONSE_CORRELATION_KEY = 'qwen_audio_request_id'
|
|
|
31
31
|
*
|
|
32
32
|
* - response payloads use output_modalities instead of modalities;
|
|
33
33
|
* - text deltas arrive as response.output_text.* instead of response.text.*;
|
|
34
|
-
* - conversation item ids are namespaced per item type
|
|
34
|
+
* - conversation item ids are namespaced per item type and at most 32 characters;
|
|
35
|
+
* - conversation.item.added acknowledges an item, not a completed response.
|
|
35
36
|
*/
|
|
36
37
|
export const gaRealtimeProtocol = Object.freeze({
|
|
37
38
|
encodeOutgoing: payload => ({
|
|
@@ -45,6 +46,8 @@ export const gaRealtimeProtocol = Object.freeze({
|
|
|
45
46
|
return { ...event, type: 'response.text.delta' }
|
|
46
47
|
case 'response.output_text.done':
|
|
47
48
|
return { ...event, type: 'response.text.done' }
|
|
49
|
+
case 'conversation.item.added':
|
|
50
|
+
return { ...event, type: 'conversation.item.created' }
|
|
48
51
|
default:
|
|
49
52
|
return event
|
|
50
53
|
}
|
|
@@ -66,7 +69,9 @@ export const gaRealtimeProtocol = Object.freeze({
|
|
|
66
69
|
|
|
67
70
|
conversationItemId: item => {
|
|
68
71
|
const prefix = ID_PREFIXES[item?.type] || 'item'
|
|
69
|
-
|
|
72
|
+
// OpenAI limits the entire item id, including its type namespace, to 32 characters.
|
|
73
|
+
const suffix = randomUUID().replaceAll('-', '').slice(0, 32 - prefix.length - 1)
|
|
74
|
+
return `${prefix}_${suffix}`
|
|
70
75
|
},
|
|
71
76
|
|
|
72
77
|
conversationItemCreate: item => ({
|
|
@@ -39,16 +39,19 @@ function googleTools(tools = []) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function createGoogleLiveProtocol() {
|
|
42
|
-
const responseIds = new Set()
|
|
43
42
|
const callNames = new Map()
|
|
44
43
|
let activeResponseId = ''
|
|
45
44
|
let interrupted = false
|
|
46
45
|
let automaticResponsePending = false
|
|
46
|
+
let input = null
|
|
47
|
+
let responseInput = null
|
|
48
|
+
let outputTranscript = ''
|
|
49
|
+
let outputTranscriptFinished = false
|
|
47
50
|
|
|
48
51
|
const ensureResponse = events => {
|
|
49
|
-
if (!activeResponseId)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (!activeResponseId) {
|
|
53
|
+
activeResponseId = id('response')
|
|
54
|
+
responseInput = input
|
|
52
55
|
events.push({
|
|
53
56
|
type: 'response.created',
|
|
54
57
|
response: { id: activeResponseId },
|
|
@@ -59,16 +62,92 @@ export function createGoogleLiveProtocol() {
|
|
|
59
62
|
|
|
60
63
|
const finishResponse = events => {
|
|
61
64
|
if (!activeResponseId) return
|
|
65
|
+
if (!interrupted && outputTranscript.trim()) {
|
|
66
|
+
events.push({
|
|
67
|
+
type: 'response.audio_transcript.done',
|
|
68
|
+
response_id: activeResponseId,
|
|
69
|
+
transcript: outputTranscript,
|
|
70
|
+
})
|
|
71
|
+
}
|
|
62
72
|
events.push({
|
|
63
73
|
type: 'response.done',
|
|
64
74
|
response: { id: activeResponseId, status: interrupted ? 'cancelled' : 'completed' },
|
|
65
75
|
})
|
|
66
|
-
responseIds.delete(activeResponseId)
|
|
67
76
|
activeResponseId = ''
|
|
68
|
-
|
|
77
|
+
responseInput = null
|
|
78
|
+
outputTranscript = ''
|
|
79
|
+
outputTranscriptFinished = false
|
|
69
80
|
automaticResponsePending = false
|
|
70
81
|
}
|
|
71
82
|
|
|
83
|
+
const newInput = () => ({ id: id('input'), text: '' })
|
|
84
|
+
|
|
85
|
+
const finishInput = events => {
|
|
86
|
+
if (!input?.text.trim() || input.finalized) return
|
|
87
|
+
input.finalized = true
|
|
88
|
+
events.push({
|
|
89
|
+
type: 'conversation.item.input_audio_transcription.completed',
|
|
90
|
+
item_id: input.id,
|
|
91
|
+
transcript: input.text,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const handleActivity = (type, events) => {
|
|
96
|
+
if (type === 'ACTIVITY_START') {
|
|
97
|
+
if (input?.activity === 'speaking') return
|
|
98
|
+
if (input?.activity === 'ended' || input?.finalized) {
|
|
99
|
+
finishInput(events)
|
|
100
|
+
input = null
|
|
101
|
+
}
|
|
102
|
+
if (!input) {
|
|
103
|
+
input = newInput()
|
|
104
|
+
events.push({
|
|
105
|
+
type: 'input_audio_buffer.speech_started',
|
|
106
|
+
item_id: input.id,
|
|
107
|
+
providerHandlesInterruption: true,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
input.activity = 'speaking'
|
|
111
|
+
} else if (type === 'ACTIVITY_END' && input?.activity === 'speaking') {
|
|
112
|
+
input.activity = 'ended'
|
|
113
|
+
events.push({ type: 'input_audio_buffer.speech_stopped', item_id: input.id })
|
|
114
|
+
if (input.finished) finishInput(events)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const handleInputTranscript = (transcription, events) => {
|
|
119
|
+
if (!transcription) return
|
|
120
|
+
const text = transcription.text
|
|
121
|
+
if (input?.finalized) {
|
|
122
|
+
if (input.activity || !input.modelTurnEnded) return
|
|
123
|
+
// An id-less explicit final that arrived after the model turn can be
|
|
124
|
+
// repeated. A new fragment or voice activity opens the next input.
|
|
125
|
+
if (transcription.finished === true && text === input.finalFragment) return
|
|
126
|
+
input = null
|
|
127
|
+
}
|
|
128
|
+
if (!input && typeof text === 'string' && text) {
|
|
129
|
+
input = newInput()
|
|
130
|
+
events.push({
|
|
131
|
+
type: 'conversation.item.input_audio_transcription.started',
|
|
132
|
+
item_id: input.id,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
if (!input || input.finished) return
|
|
136
|
+
if (typeof text === 'string' && text) {
|
|
137
|
+
input.text += text
|
|
138
|
+
events.push({
|
|
139
|
+
type: 'conversation.item.input_audio_transcription.delta',
|
|
140
|
+
item_id: input.id,
|
|
141
|
+
text: input.text,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
if (typeof transcription.finished === 'boolean') input.finished = transcription.finished
|
|
145
|
+
if (input.finished) input.finalFragment = text
|
|
146
|
+
if (input.activity !== 'speaking' && (input.finished || (input.modelTurnEnded && input.finished !== false))) {
|
|
147
|
+
finishInput(events)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
72
151
|
return Object.freeze({
|
|
73
152
|
encodeOutgoing: payload => payload,
|
|
74
153
|
|
|
@@ -82,51 +161,60 @@ export function createGoogleLiveProtocol() {
|
|
|
82
161
|
}
|
|
83
162
|
|
|
84
163
|
const events = []
|
|
164
|
+
handleActivity(event?.voiceActivity?.type, events)
|
|
85
165
|
const serverContent = event?.serverContent
|
|
86
166
|
if (serverContent) {
|
|
87
|
-
if (serverContent.interrupted
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
167
|
+
if (serverContent.interrupted && !interrupted) {
|
|
168
|
+
interrupted = true
|
|
169
|
+
events.push({ type: 'response.interrupted', response_id: activeResponseId })
|
|
170
|
+
}
|
|
171
|
+
handleInputTranscript(serverContent.inputTranscription, events)
|
|
172
|
+
if (
|
|
173
|
+
serverContent.turnComplete && !interrupted
|
|
174
|
+
&& input && input.activity !== 'speaking'
|
|
175
|
+
&& (!responseInput || responseInput === input)
|
|
176
|
+
) {
|
|
177
|
+
// A previous response can close while the next voice input is open.
|
|
178
|
+
// Keep an ended activity available for independently delivered ASR.
|
|
179
|
+
input.modelTurnEnded = true
|
|
180
|
+
if (input.finished !== false) finishInput(events)
|
|
181
|
+
if (!input.activity && input.finalized) input = null
|
|
182
|
+
}
|
|
92
183
|
|
|
93
|
-
|
|
184
|
+
const modelTurn = interrupted ? null : serverContent.modelTurn
|
|
185
|
+
const modelResponseId = modelTurn ? ensureResponse(events) : activeResponseId
|
|
186
|
+
for (const part of modelTurn?.parts || []) {
|
|
94
187
|
if (typeof part.text === 'string' && part.text) {
|
|
95
188
|
events.push({
|
|
96
189
|
type: 'response.text.delta',
|
|
97
|
-
response_id:
|
|
190
|
+
response_id: modelResponseId,
|
|
98
191
|
delta: part.text,
|
|
99
192
|
})
|
|
100
193
|
}
|
|
101
194
|
if (part.inlineData?.data) {
|
|
102
195
|
events.push({
|
|
103
196
|
type: 'response.audio.delta',
|
|
104
|
-
response_id:
|
|
197
|
+
response_id: modelResponseId,
|
|
105
198
|
delta: part.inlineData.data,
|
|
106
199
|
sampleRate: audioRate(part.inlineData.mimeType),
|
|
107
200
|
})
|
|
108
201
|
}
|
|
109
202
|
}
|
|
110
203
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
: 'response.audio_transcript.delta',
|
|
126
|
-
response_id: responseId || ensureResponse(events),
|
|
127
|
-
transcript: serverContent.outputTranscription.text,
|
|
128
|
-
delta: serverContent.outputTranscription.text,
|
|
129
|
-
})
|
|
204
|
+
const output = serverContent.outputTranscription
|
|
205
|
+
if (!interrupted && output && !outputTranscriptFinished) {
|
|
206
|
+
if (typeof output.text === 'string' && output.text) {
|
|
207
|
+
const responseId = ensureResponse(events)
|
|
208
|
+
outputTranscript += output.text
|
|
209
|
+
if (!serverContent.turnComplete) {
|
|
210
|
+
events.push({
|
|
211
|
+
type: 'response.audio_transcript.delta',
|
|
212
|
+
response_id: responseId,
|
|
213
|
+
delta: output.text,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
outputTranscriptFinished = output.finished === true
|
|
130
218
|
}
|
|
131
219
|
// generationComplete can precede playback/turn completion. Keep the
|
|
132
220
|
// response slot occupied until the service actually closes the turn.
|
|
@@ -136,7 +224,8 @@ export function createGoogleLiveProtocol() {
|
|
|
136
224
|
}
|
|
137
225
|
|
|
138
226
|
const calls = event?.toolCall?.functionCalls || []
|
|
139
|
-
if (calls.length) {
|
|
227
|
+
if (calls.length && !interrupted) {
|
|
228
|
+
if (input?.activity !== 'speaking' && input?.finished !== false) finishInput(events)
|
|
140
229
|
const responseId = ensureResponse(events)
|
|
141
230
|
for (const call of calls) {
|
|
142
231
|
const callId = String(call.id || id('call'))
|
|
@@ -162,6 +251,7 @@ export function createGoogleLiveProtocol() {
|
|
|
162
251
|
})
|
|
163
252
|
}
|
|
164
253
|
|
|
254
|
+
if (serverContent?.turnComplete) interrupted = false
|
|
165
255
|
return events.length ? events : event
|
|
166
256
|
},
|
|
167
257
|
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
} from '../../frontend/frontend-tools.mjs'
|
|
15
15
|
import { createGoogleLiveProtocol } from './google-live-protocol.mjs'
|
|
16
16
|
|
|
17
|
-
const connection = providerRuntimeConfiguration('google-live')
|
|
17
|
+
const connection = providerRuntimeConfiguration('google-live', { provider: 'google' })
|
|
18
18
|
|
|
19
19
|
function modelProfile() {
|
|
20
|
-
return resolveRealtimeModelProfile(connection.model, 'google
|
|
20
|
+
return resolveRealtimeModelProfile(connection.model, 'google', config.realtimeModelCatalogs)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function googleLiveUrl() {
|
|
@@ -59,7 +59,8 @@ function userTextItem(text) {
|
|
|
59
59
|
|
|
60
60
|
export const googleLiveProvider = {
|
|
61
61
|
key: 'google-live',
|
|
62
|
-
|
|
62
|
+
provider: 'google',
|
|
63
|
+
label: 'Google',
|
|
63
64
|
aliases: ['google', 'gemini-live', 'googlelive'],
|
|
64
65
|
inputSampleRate: 16000,
|
|
65
66
|
outputSampleRate: 24000,
|
|
@@ -76,10 +77,10 @@ export const googleLiveProvider = {
|
|
|
76
77
|
|
|
77
78
|
model: () => connection.model,
|
|
78
79
|
modelProfile,
|
|
79
|
-
modelCatalog: () => realtimeModelCatalog('google
|
|
80
|
+
modelCatalog: () => realtimeModelCatalog('google', config.realtimeModelCatalogs).profiles,
|
|
80
81
|
voice: () => String(connection.voice || '').trim() || modelProfile().sessionDefaults.voice,
|
|
81
82
|
isConfigured: () => connection.configured,
|
|
82
|
-
missingConfigurationMessage: '请先选择 google
|
|
83
|
+
missingConfigurationMessage: '请先选择 google 并配置 QWEN_AUDIO_REALTIME_API_KEY',
|
|
83
84
|
connectTimeoutMessage: '连接 Google Live 超时',
|
|
84
85
|
url: googleLiveUrl,
|
|
85
86
|
headers: () => ({}),
|