@fonoster/autopilot 0.7.10 → 0.7.12
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 +0 -2
- package/dist/Autopilot.d.ts +1 -0
- package/dist/Autopilot.js +4 -0
- package/dist/handleVoiceRequest.js +4 -0
- package/dist/machine/machine.js +29 -18
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -39,12 +39,10 @@ The configuration file has two major sections: `conversationSettings` and `langu
|
|
|
39
39
|
"systemErrorMessage": "I'm sorry, but I seem to be having trouble. Please try again later.",
|
|
40
40
|
"initialDtmf": "6589",
|
|
41
41
|
"transferOptions": {
|
|
42
|
-
"enabled": true,
|
|
43
42
|
"phoneNumber": "+15555555555",
|
|
44
43
|
"message": "Please hold while I transfer you to a live agent."
|
|
45
44
|
},
|
|
46
45
|
"idleOptions": {
|
|
47
|
-
"enabled": true,
|
|
48
46
|
"message": "Are you still there?",
|
|
49
47
|
"timeout": 10000,
|
|
50
48
|
"maxTimeoutCount": 3
|
package/dist/Autopilot.d.ts
CHANGED
package/dist/Autopilot.js
CHANGED
|
@@ -43,6 +43,10 @@ class Autopilot {
|
|
|
43
43
|
this.setupVoiceStream();
|
|
44
44
|
this.setupSpeechGathering();
|
|
45
45
|
}
|
|
46
|
+
stop() {
|
|
47
|
+
logger.verbose("stopping autopilot");
|
|
48
|
+
this.actor.stop();
|
|
49
|
+
}
|
|
46
50
|
async setupVoiceStream() {
|
|
47
51
|
const { voice, vad } = this.params;
|
|
48
52
|
const stream = await voice.stream();
|
|
@@ -42,6 +42,7 @@ exports.handleVoiceRequest = handleVoiceRequest;
|
|
|
42
42
|
* See the License for the specific language governing permissions and
|
|
43
43
|
* limitations under the License.
|
|
44
44
|
*/
|
|
45
|
+
const common_1 = require("@fonoster/common");
|
|
45
46
|
const logger_1 = require("@fonoster/logger");
|
|
46
47
|
const createLanguageModel_1 = require("./createLanguageModel");
|
|
47
48
|
const loadAssistantConfig_1 = require("./loadAssistantConfig");
|
|
@@ -63,4 +64,7 @@ async function handleVoiceRequest(req, res) {
|
|
|
63
64
|
languageModel
|
|
64
65
|
});
|
|
65
66
|
autopilot.start();
|
|
67
|
+
res.on(common_1.StreamEvent.END, () => {
|
|
68
|
+
autopilot.stop();
|
|
69
|
+
});
|
|
66
70
|
}
|
package/dist/machine/machine.js
CHANGED
|
@@ -68,27 +68,38 @@ const machine = (0, xstate_1.setup)({
|
|
|
68
68
|
const speechResponseTime = Date.now() - context.speechResponseStartTime;
|
|
69
69
|
context.speechResponseTime = speechResponseTime;
|
|
70
70
|
context.speechResponseStartTime = 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
logger.verbose("response from language model", {
|
|
72
|
+
speechResponseTime
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
if (response.type === "say" && !response.content) {
|
|
76
|
+
logger.verbose("call might already be hung up");
|
|
77
|
+
(0, xstate_1.raise)({ type: "USER_REQUEST_PROCESSED" });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
else if (response.type === "hangup") {
|
|
81
|
+
const message = context.goodbyeMessage;
|
|
82
|
+
await context.voice.say(message);
|
|
83
|
+
await context.voice.hangup();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
else if (response.type === "transfer") {
|
|
87
|
+
const message = context.transferMessage;
|
|
88
|
+
await context.voice.say(message);
|
|
89
|
+
await context.voice.transfer(context.transferPhoneNumber, {
|
|
90
|
+
record: true,
|
|
91
|
+
timeout: 30
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
await context.voice.say(response.content);
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await context.voice.transfer(context.transferPhoneNumber, {
|
|
86
|
-
record: true,
|
|
87
|
-
timeout: 30
|
|
97
|
+
catch (error) {
|
|
98
|
+
logger.error("error processing user request", {
|
|
99
|
+
error
|
|
88
100
|
});
|
|
89
|
-
|
|
101
|
+
await context.voice.say(context.systemErrorMessage);
|
|
90
102
|
}
|
|
91
|
-
await context.voice.say(response.content);
|
|
92
103
|
(0, xstate_1.raise)({ type: "USER_REQUEST_PROCESSED" });
|
|
93
104
|
},
|
|
94
105
|
announceIdleTimeout: async ({ context }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"description": "Voice AI for the Fonoster platform",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fonoster/common": "^0.7.
|
|
38
|
+
"@fonoster/common": "^0.7.11",
|
|
39
39
|
"@fonoster/logger": "^0.7.10",
|
|
40
|
-
"@fonoster/voice": "^0.7.
|
|
40
|
+
"@fonoster/voice": "^0.7.12",
|
|
41
41
|
"@langchain/community": "^0.2.31",
|
|
42
|
-
"@langchain/core": "^0.2.
|
|
42
|
+
"@langchain/core": "^0.2.32",
|
|
43
43
|
"@langchain/groq": "^0.0.17",
|
|
44
|
-
"@langchain/openai": "^0.2.
|
|
44
|
+
"@langchain/openai": "^0.2.10",
|
|
45
45
|
"cheerio": "^1.0.0",
|
|
46
46
|
"dotenv": "^16.4.5",
|
|
47
47
|
"langchain": "^0.2.17",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"typescript": "^5.5.4"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "264fb6d971bad1d823554e93ed7c088318307184"
|
|
58
58
|
}
|