Skip to content

Commit

Permalink
fix #1025 (#1026)
Browse files Browse the repository at this point in the history
* fix #1025

* redirect verb should be able to redirect to a new websocket endpoint
  • Loading branch information
davehorton authored Jan 9, 2025
1 parent fcefa1f commit 6bad1a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/tasks/llm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
12 changes: 12 additions & 0 deletions lib/tasks/redirect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Task = require('./task');
const {TaskName} = require('../utils/constants');
const WsRequestor = require('../utils/ws-requestor');

/**
* Redirects to a new application
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 6bad1a2

Please sign in to comment.