@fonoster/autopilot 0.9.52 → 0.9.54
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.
|
@@ -66,13 +66,13 @@ const sendConversationEndedEvent_1 = require("./sendConversationEndedEvent");
|
|
|
66
66
|
const _1 = __importStar(require("."));
|
|
67
67
|
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
68
68
|
async function handleVoiceRequest(req, res) {
|
|
69
|
-
const { accessKeyId, callerNumber, ingressNumber, sessionRef, appRef, callDirection } = req;
|
|
69
|
+
const { accessKeyId, callerNumber, ingressNumber, sessionRef, appRef, callDirection, metadata } = req;
|
|
70
70
|
logger.verbose("voice request", {
|
|
71
71
|
accessKeyId,
|
|
72
72
|
ingressNumber,
|
|
73
73
|
sessionRef,
|
|
74
74
|
appRef,
|
|
75
|
-
metadata
|
|
75
|
+
metadata
|
|
76
76
|
});
|
|
77
77
|
const assistantConfig = envs_1.CONVERSATION_PROVIDER === _1.ConversationProvider.FILE
|
|
78
78
|
? (0, loadAssistantConfigFromFile_1.loadAssistantConfigFromFile)(envs_1.CONVERSATION_PROVIDER_FILE)
|
|
@@ -106,7 +106,8 @@ async function handleVoiceRequest(req, res) {
|
|
|
106
106
|
telephonyContext: {
|
|
107
107
|
callDirection,
|
|
108
108
|
ingressNumber,
|
|
109
|
-
callerNumber
|
|
109
|
+
callerNumber,
|
|
110
|
+
metadata
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
113
|
const { conversationSettings } = assistantConfig;
|
|
@@ -20,23 +20,15 @@ exports.createPromptTemplate = createPromptTemplate;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
const prompts_1 = require("@langchain/core/prompts");
|
|
23
|
+
const createSystemPrompt_1 = require("./createSystemPrompt");
|
|
23
24
|
function createPromptTemplate(params) {
|
|
24
25
|
const { firstMessage, systemPrompt, telephonyContext } = params;
|
|
25
26
|
return prompts_1.ChatPromptTemplate.fromMessages([
|
|
26
|
-
prompts_1.SystemMessagePromptTemplate.fromTemplate(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[Context]
|
|
32
|
-
{context}
|
|
33
|
-
|
|
34
|
-
[Call Information]
|
|
35
|
-
callReceivedAt: ${new Date().toISOString()}
|
|
36
|
-
ingressNumber: ${telephonyContext.ingressNumber}
|
|
37
|
-
callerNumber: ${telephonyContext.callerNumber}
|
|
38
|
-
callDirection: ${telephonyContext.callDirection}
|
|
39
|
-
`),
|
|
27
|
+
prompts_1.SystemMessagePromptTemplate.fromTemplate((0, createSystemPrompt_1.createSystemPrompt)({
|
|
28
|
+
firstMessage,
|
|
29
|
+
systemPrompt,
|
|
30
|
+
telephonyContext
|
|
31
|
+
})),
|
|
40
32
|
new prompts_1.MessagesPlaceholder("history"),
|
|
41
33
|
prompts_1.HumanMessagePromptTemplate.fromTemplate("{input}")
|
|
42
34
|
]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { TelephonyContext } from ".";
|
|
20
|
+
declare function createSystemPrompt(params: {
|
|
21
|
+
firstMessage?: string;
|
|
22
|
+
systemPrompt: string;
|
|
23
|
+
telephonyContext: TelephonyContext;
|
|
24
|
+
}): string;
|
|
25
|
+
export { createSystemPrompt };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSystemPrompt = createSystemPrompt;
|
|
4
|
+
function createSystemPrompt(params) {
|
|
5
|
+
const { firstMessage: firstMessageFromSystem, systemPrompt } = params;
|
|
6
|
+
const { ingressNumber, callerNumber, callDirection, metadata } = params.telephonyContext;
|
|
7
|
+
const additionalParameters = Object.entries(metadata ?? {})
|
|
8
|
+
.map(([key, value]) => `- ${key}: ${value}`)
|
|
9
|
+
.join("\n");
|
|
10
|
+
return `
|
|
11
|
+
${systemPrompt}
|
|
12
|
+
|
|
13
|
+
[Context Information]
|
|
14
|
+
{context}
|
|
15
|
+
|
|
16
|
+
[Call Details]
|
|
17
|
+
- System's First Message: ${firstMessageFromSystem}
|
|
18
|
+
- Current Time: ${new Date().toISOString()}
|
|
19
|
+
- Service Number: ${ingressNumber}
|
|
20
|
+
- Caller Number: ${callerNumber}
|
|
21
|
+
- Call Direction: ${callDirection}
|
|
22
|
+
|
|
23
|
+
${additionalParameters
|
|
24
|
+
? `[Additional Parameters (metadata)]
|
|
25
|
+
${additionalParameters}`
|
|
26
|
+
: ""}
|
|
27
|
+
`;
|
|
28
|
+
}
|
package/dist/models/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.54",
|
|
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",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@aws-sdk/client-s3": "^3.712.0",
|
|
36
36
|
"@dmitryrechkin/json-schema-to-zod": "^1.0.1",
|
|
37
|
-
"@fonoster/common": "^0.9.
|
|
38
|
-
"@fonoster/logger": "^0.9.
|
|
39
|
-
"@fonoster/sdk": "^0.9.
|
|
40
|
-
"@fonoster/types": "^0.9.
|
|
41
|
-
"@fonoster/voice": "^0.9.
|
|
37
|
+
"@fonoster/common": "^0.9.54",
|
|
38
|
+
"@fonoster/logger": "^0.9.54",
|
|
39
|
+
"@fonoster/sdk": "^0.9.54",
|
|
40
|
+
"@fonoster/types": "^0.9.54",
|
|
41
|
+
"@fonoster/voice": "^0.9.54",
|
|
42
42
|
"@langchain/anthropic": "^0.3.15",
|
|
43
43
|
"@langchain/community": "^0.3.32",
|
|
44
44
|
"@langchain/core": "^0.3.40",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"xstate": "^5.17.3",
|
|
60
60
|
"zod": "^3.23.8"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "5272372951df997cb17d49f9cda6fc9816e304c9"
|
|
63
63
|
}
|