mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-13 01:39:26 +00:00
support ultravox sends createCall response to app (#1091)
* support ultravox sends createCall response to app * update type issue Co-authored-by: Matt Hertogs <matthertogs@gmail.com> --------- Co-authored-by: Matt Hertogs <matthertogs@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ const {request} = require('undici');
|
|||||||
const {LlmEvents_Ultravox} = require('../../../utils/constants');
|
const {LlmEvents_Ultravox} = require('../../../utils/constants');
|
||||||
|
|
||||||
const ultravox_server_events = [
|
const ultravox_server_events = [
|
||||||
|
'createCall',
|
||||||
'pong',
|
'pong',
|
||||||
'state',
|
'state',
|
||||||
'transcript',
|
'transcript',
|
||||||
@@ -88,7 +89,7 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
throw new Error(`Ultravox Error registering call: ${data.message}`);
|
throw new Error(`Ultravox Error registering call: ${data.message}`);
|
||||||
}
|
}
|
||||||
this.logger.info({joinUrl: data.joinUrl}, 'Ultravox Call registered');
|
this.logger.info({joinUrl: data.joinUrl}, 'Ultravox Call registered');
|
||||||
return data.joinUrl;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unregisterHandlers() {
|
_unregisterHandlers() {
|
||||||
@@ -105,13 +106,19 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
async _startListening(cs, ep) {
|
async _startListening(cs, ep) {
|
||||||
this._registerHandlers(ep);
|
this._registerHandlers(ep);
|
||||||
|
|
||||||
const joinUrl = await this.createCall();
|
const data = await this.createCall();
|
||||||
|
const {joinUrl} = data;
|
||||||
// split the joinUrl into host and path
|
// split the joinUrl into host and path
|
||||||
const {host, pathname, search} = new URL(joinUrl);
|
const {host, pathname, search} = new URL(joinUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const args = [ep.uuid, 'session.create', host, pathname + search];
|
const args = [ep.uuid, 'session.create', host, pathname + search];
|
||||||
await this._api(ep, args);
|
await this._api(ep, args);
|
||||||
|
// Notify the application that the session has been created with detail information
|
||||||
|
this._sendLlmEvent('createCall', {
|
||||||
|
type: 'createCall',
|
||||||
|
...data
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error({err}, 'TaskLlmUltraVox_S2S:_startListening');
|
this.logger.error({err}, 'TaskLlmUltraVox_S2S:_startListening');
|
||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
@@ -190,11 +197,7 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check whether we should notify on this event */
|
this._sendLlmEvent(type, evt);
|
||||||
if (this.includeEvents.length > 0 ? this.includeEvents.includes(type) : !this.excludeEvents.includes(type)) {
|
|
||||||
this.parent.sendEventHook(evt)
|
|
||||||
.catch((err) => this.logger.info({err}, 'TaskLlmUltravox_S2S:_onServerEvent - error sending event hook'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endConversation) {
|
if (endConversation) {
|
||||||
this.logger.info({results: this.results},
|
this.logger.info({results: this.results},
|
||||||
@@ -203,6 +206,14 @@ class TaskLlmUltravox_S2S extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sendLlmEvent(type, evt) {
|
||||||
|
/* check whether we should notify on this event */
|
||||||
|
if (this.includeEvents.length > 0 ? this.includeEvents.includes(type) : !this.excludeEvents.includes(type)) {
|
||||||
|
this.parent.sendEventHook(evt)
|
||||||
|
.catch((err) => this.logger.info({err}, 'TaskLlmUltravox_S2S:_onServerEvent - error sending event hook'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async processToolOutput(ep, tool_call_id, data) {
|
async processToolOutput(ep, tool_call_id, data) {
|
||||||
try {
|
try {
|
||||||
this.logger.debug({tool_call_id, data}, 'TaskLlmUltravox_S2S:processToolOutput');
|
this.logger.debug({tool_call_id, data}, 'TaskLlmUltravox_S2S:processToolOutput');
|
||||||
|
|||||||
Reference in New Issue
Block a user