support ultravox agent id (#1254)

* support ultravox agent id

* wip
This commit is contained in:
Hoan Luu Huu
2025-06-23 20:37:10 +07:00
committed by GitHub
parent f98bf2a1f8
commit f18b62e165

View File

@@ -32,12 +32,14 @@ class TaskLlmUltravox_S2S extends Task {
this.auth = this.parent.auth;
this.connectionOptions = this.parent.connectOptions;
const {apiKey} = this.auth || {};
const {apiKey, agent_id} = this.auth || {};
if (!apiKey) throw new Error('auth.apiKey is required for Vendor: Ultravox');
this.apiKey = apiKey;
this.agentId = agent_id;
this.actionHook = this.data.actionHook;
this.eventHook = this.data.eventHook;
this.toolHook = this.data.toolHook;
this.llmOptions = this.data.llmOptions || {};
this.results = {
completionReason: 'normal conversation end'
@@ -105,24 +107,29 @@ class TaskLlmUltravox_S2S extends Task {
}
);
// merge with any existing tools
this.data.llmOptions.selectedTools = [
this.llmOptions.selectedTools = [
...convertedTools,
...(this.data.llmOptions.selectedTools || [])
...(this.llmOptions.selectedTools || [])
];
}
const payload = {
...this.data.llmOptions,
model: this.model,
...this.llmOptions,
...(!this.agentId && {
model: this.model,
}),
medium: {
...(this.data.llmOptions.medium || {}),
...(this.llmOptions.medium || {}),
serverWebSocket: {
inputSampleRate: 8000,
outputSampleRate: 8000,
}
}
};
const {statusCode, body} = await request('https://api.ultravox.ai/api/calls', {
const baseUrl = 'https://api.ultravox.ai';
const url = this.agentId ?
`${baseUrl}/api/agents/${this.agentId}/calls` : `${baseUrl}/api/calls`;
const {statusCode, body} = await request(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',