From 6bad1a22f3c379ded64298862ed6e03cdae0aec3 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 9 Jan 2025 15:45:20 -0500 Subject: [PATCH] fix #1025 (#1026) * fix #1025 * redirect verb should be able to redirect to a new websocket endpoint --- lib/tasks/llm/index.js | 4 +--- lib/tasks/redirect.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/tasks/llm/index.js b/lib/tasks/llm/index.js index 97146a46..c0d6f316 100644 --- a/lib/tasks/llm/index.js +++ b/lib/tasks/llm/index.js @@ -41,9 +41,7 @@ class TaskLlm extends Task { switch (this.vendor) { case 'openai': case 'microsoft': - if (this.model.startsWith('gpt-4o-realtime')) { - llm = new TaskLlmOpenAI_S2S(this.logger, this.data, this); - } + llm = new TaskLlmOpenAI_S2S(this.logger, this.data, this); break; case 'voiceagent': diff --git a/lib/tasks/redirect.js b/lib/tasks/redirect.js index 55d5d9dd..4a5f5b10 100644 --- a/lib/tasks/redirect.js +++ b/lib/tasks/redirect.js @@ -1,5 +1,6 @@ const Task = require('./task'); const {TaskName} = require('../utils/constants'); +const WsRequestor = require('../utils/ws-requestor'); /** * Redirects to a new application @@ -13,6 +14,17 @@ class TaskRedirect extends Task { async exec(cs) { await super.exec(cs); + + if (cs.requestor instanceof WsRequestor && cs.application.requestor._isAbsoluteUrl(this.actionHook)) { + this.logger.info(`Task:performAction redirecting to ${this.actionHook}, requires new ws connection`); + try { + this.cs.requestor.close(); + const requestor = new WsRequestor(this.logger, cs.accountSid, {url: this.actionHook}, this.webhook_secret) ; + this.cs.application.requestor = requestor; + } catch (err) { + this.logger.info(err, `Task:performAction error redirecting to ${this.actionHook}`); + } + } await this.performAction(); } }