@fonoster/autopilot 0.9.37 → 0.9.38
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.
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.38",
|
|
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",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"xstate": "^5.17.3",
|
|
57
57
|
"zod": "^3.23.8"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "a32db703d073809843cd2060bc4c6c88f939c083"
|
|
60
60
|
}
|