@fonoster/autopilot 0.9.37 → 0.9.39
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/dist/handleVoiceRequest.js +28 -23
- package/dist/machine/actors/doProcessUserRequest.js +1 -1
- package/dist/models/AbstractLanguageModel.js +3 -1
- package/dist/sendConversationEndedEvent.js +1 -1
- package/dist/vadv5/SileroVadModel.js +5 -1
- package/dist/vadv5/createVad.js +7 -1
- package/dist/vadv5/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -110,28 +110,33 @@ async function handleVoiceRequest(req, res) {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
const { conversationSettings } = assistantConfig;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
113
|
+
try {
|
|
114
|
+
const autopilot = new _1.default({
|
|
115
|
+
conversationSettings: conversationSettings,
|
|
116
|
+
voice: voice,
|
|
117
|
+
languageModel: languageModel
|
|
118
|
+
});
|
|
119
|
+
autopilot.start();
|
|
120
|
+
res.on(common_1.StreamEvent.END, async () => {
|
|
121
|
+
autopilot.stop();
|
|
122
|
+
const rawChatHistory = await languageModel.getChatHistoryMessages();
|
|
123
|
+
const chatHistory = rawChatHistory
|
|
124
|
+
.map((msg) => {
|
|
125
|
+
if (msg.constructor.name === "HumanMessage") {
|
|
126
|
+
return { human: msg.content };
|
|
127
|
+
}
|
|
128
|
+
else if (msg.constructor.name === "AIMessage") {
|
|
129
|
+
return { ai: msg.content };
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
})
|
|
133
|
+
.filter(Boolean);
|
|
134
|
+
if (assistantConfig.eventsHook?.url) {
|
|
135
|
+
await (0, sendConversationEndedEvent_1.sendConversationEndedEvent)(assistantConfig.eventsHook, chatHistory);
|
|
129
136
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
logger.error("error handling voice request", { error });
|
|
141
|
+
}
|
|
137
142
|
}
|
|
@@ -34,7 +34,7 @@ exports.doProcessUserRequest = (0, xstate_1.fromPromise)(async ({ input }) => {
|
|
|
34
34
|
const response = await languageModel.invoke(speech);
|
|
35
35
|
try {
|
|
36
36
|
if (response.type === "say" && !response.content) {
|
|
37
|
-
logger.
|
|
37
|
+
logger.warn("ignoring say response with no content");
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
else if (response.type === "hangup") {
|
|
@@ -82,7 +82,9 @@ class AbstractLanguageModel {
|
|
|
82
82
|
default:
|
|
83
83
|
if (isFirstTool) {
|
|
84
84
|
const tool = toolsCatalog.getTool(toolName);
|
|
85
|
-
|
|
85
|
+
if (tool?.requestStartMessage) {
|
|
86
|
+
await this.voice.say(tool?.requestStartMessage);
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
await (0, toolInvocation_1.toolInvocation)({
|
|
88
90
|
args,
|
|
@@ -42,7 +42,7 @@ async function sendConversationEndedEvent(eventsHook, chatHistory) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
logger.
|
|
45
|
+
logger.warn("sending event", {
|
|
46
46
|
url: parsedEventsHook.url,
|
|
47
47
|
method: common_1.AllowedHttpMethod.POST,
|
|
48
48
|
waitForResponse: false,
|
|
@@ -36,7 +36,11 @@ class SileroVadModel {
|
|
|
36
36
|
}
|
|
37
37
|
async init() {
|
|
38
38
|
const modelArrayBuffer = (0, fs_1.readFileSync)(this.pathToModel).buffer;
|
|
39
|
-
const sessionOption = {
|
|
39
|
+
const sessionOption = {
|
|
40
|
+
interOpNumThreads: 1,
|
|
41
|
+
intraOpNumThreads: 1,
|
|
42
|
+
enableCpuMemArena: false
|
|
43
|
+
};
|
|
40
44
|
this._session = await this.ort.InferenceSession.create(modelArrayBuffer, sessionOption);
|
|
41
45
|
// Validate model inputs/outputs
|
|
42
46
|
const requiredInputs = ["input", "state", "sr"];
|
package/dist/vadv5/createVad.js
CHANGED
|
@@ -63,7 +63,13 @@ const BUFFER_SIZE = 512; // 32ms @ 16kHz
|
|
|
63
63
|
async function createVad(params) {
|
|
64
64
|
const { pathToModel, activationThreshold, deactivationThreshold, debounceFrames } = params;
|
|
65
65
|
const effectivePath = pathToModel || (0, path_1.join)(__dirname, "..", "..", "silero_vad_v5.onnx");
|
|
66
|
-
const
|
|
66
|
+
const ortAdapter = {
|
|
67
|
+
InferenceSession: {
|
|
68
|
+
create: ort.InferenceSession.create.bind(ort.InferenceSession)
|
|
69
|
+
},
|
|
70
|
+
Tensor: ort.Tensor
|
|
71
|
+
};
|
|
72
|
+
const silero = await SileroVadModel_1.SileroVadModel.new(ortAdapter, effectivePath);
|
|
67
73
|
let sampleBuffer = [];
|
|
68
74
|
let isSpeechActive = false;
|
|
69
75
|
let framesSinceStateChange = 0;
|
package/dist/vadv5/types.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface ONNXRuntimeAPI {
|
|
|
29
29
|
create: (modelPath: ArrayBuffer | string, options?: {
|
|
30
30
|
interOpNumThreads: number;
|
|
31
31
|
intraOpNumThreads: number;
|
|
32
|
+
enableCpuMemArena: boolean;
|
|
32
33
|
}) => Promise<ONNXSession>;
|
|
33
34
|
};
|
|
34
35
|
Tensor: new (type: string, data: Float32Array | bigint[], dims: number[]) => ONNXTensor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.39",
|
|
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",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"js-yaml": "^4.1.0",
|
|
51
51
|
"langchain": "^0.3.6",
|
|
52
52
|
"moment": "^2.30.1",
|
|
53
|
-
"onnxruntime-node": "^1.
|
|
53
|
+
"onnxruntime-node": "^1.21.0",
|
|
54
54
|
"pdf-parse": "^1.1.1",
|
|
55
55
|
"uuid": "^11.0.3",
|
|
56
56
|
"xstate": "^5.17.3",
|
|
57
57
|
"zod": "^3.23.8"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "ff9bc63efb101ceb4c6c4e08b7b11f720336454c"
|
|
60
60
|
}
|