@fonoster/autopilot 0.5.4 → 0.7.0
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/LICENSE +2 -2
- package/README.md +3 -0
- package/dist/Autopilot.d.ts +7 -0
- package/dist/Autopilot.js +58 -0
- package/dist/assistants/assistants.d.ts +4 -0
- package/dist/assistants/assistants.js +39 -0
- package/dist/assistants/examples.d.ts +10 -0
- package/dist/assistants/examples.js +96 -0
- package/dist/assistants/index.d.ts +2 -0
- package/dist/{file-retention → assistants}/index.js +7 -4
- package/dist/assistants/types.d.ts +13 -0
- package/dist/{events → assistants}/types.js +10 -12
- package/dist/demo.d.ts +1 -0
- package/dist/demo.js +57 -0
- package/dist/envs.d.ts +1 -4
- package/dist/envs.js +11 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -11
- package/dist/machine/index.d.ts +1 -0
- package/dist/machine/index.js +23 -0
- package/dist/machine/machine.d.ts +108 -0
- package/dist/machine/machine.js +111 -0
- package/dist/machine/types.d.ts +21 -0
- package/dist/machine/types.js +9 -0
- package/dist/types.d.ts +14 -41
- package/dist/types.js +0 -7
- package/package.json +29 -27
- package/dist/cerebro/cerebro.d.ts +0 -42
- package/dist/cerebro/cerebro.js +0 -266
- package/dist/cerebro/effects.d.ts +0 -11
- package/dist/cerebro/effects.js +0 -113
- package/dist/cerebro/helper.d.ts +0 -5
- package/dist/cerebro/helper.js +0 -43
- package/dist/cerebro/index.d.ts +0 -2
- package/dist/cerebro/index.js +0 -36
- package/dist/cerebro/types.d.ts +0 -40
- package/dist/cerebro/types.js +0 -9
- package/dist/events/emitter.d.ts +0 -7
- package/dist/events/emitter.js +0 -13
- package/dist/events/server.d.ts +0 -12
- package/dist/events/server.js +0 -67
- package/dist/events/types.d.ts +0 -20
- package/dist/file-retention/cron.d.ts +0 -2
- package/dist/file-retention/cron.js +0 -23
- package/dist/file-retention/index.d.ts +0 -1
- package/dist/file-retention/task.d.ts +0 -6
- package/dist/file-retention/task.js +0 -56
- package/dist/intents/df_utils.d.ts +0 -3
- package/dist/intents/df_utils.js +0 -39
- package/dist/intents/dialogflow_cx.d.ts +0 -43
- package/dist/intents/dialogflow_cx.js +0 -102
- package/dist/intents/dialogflow_es.d.ts +0 -15
- package/dist/intents/dialogflow_es.js +0 -166
- package/dist/intents/engines.d.ts +0 -3
- package/dist/intents/engines.js +0 -32
- package/dist/intents/types.d.ts +0 -25
- package/dist/intents/types.js +0 -2
- package/dist/pilot.d.ts +0 -3
- package/dist/pilot.js +0 -150
- package/dist/util.d.ts +0 -44
- package/dist/util.js +0 -105
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Fonoster Inc
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<a href="https://gitpod.io/#https://github.com/fonoster/fonoster"> <img src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod" alt="Contribute with Gitpod" />
|
|
2
|
+
|
|
3
|
+
This module is part of the [Fonoster](https://fonoster.com) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit [https://github.com/fonoster/fonoster](https://github.com/fonoster/fonoster)(../apiserver/README.md)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Autopilot = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const common_1 = require("@fonoster/common");
|
|
23
|
+
const logger_1 = require("@fonoster/logger");
|
|
24
|
+
const xstate_1 = require("xstate");
|
|
25
|
+
const assistants_1 = require("./assistants");
|
|
26
|
+
const machine_1 = require("./machine/machine");
|
|
27
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
28
|
+
class Autopilot {
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.config = config;
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
start() {
|
|
34
|
+
const { voice, assistantConfig, firstMessage } = this.config;
|
|
35
|
+
const assistant = (0, assistants_1.makeAssistant)(assistantConfig);
|
|
36
|
+
const actor = (0, xstate_1.createActor)(machine_1.machine, {
|
|
37
|
+
input: {
|
|
38
|
+
firstMessage,
|
|
39
|
+
voice,
|
|
40
|
+
assistant
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
actor.start();
|
|
44
|
+
actor.subscribe((state) => {
|
|
45
|
+
logger.verbose("actor's new state is", { state: state.value });
|
|
46
|
+
});
|
|
47
|
+
voice
|
|
48
|
+
.sgather({
|
|
49
|
+
source: common_1.StreamGatherSource.SPEECH
|
|
50
|
+
})
|
|
51
|
+
.then((stream) => {
|
|
52
|
+
stream.onPayload((payload) => {
|
|
53
|
+
actor.send({ type: "HUMAN_PROMPT", speech: payload.speech });
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Autopilot = Autopilot;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AssistantConfig } from "./types";
|
|
2
|
+
type Assistant = ReturnType<typeof makeAssistant>;
|
|
3
|
+
declare function makeAssistant(config: AssistantConfig): import("@langchain/core/runnables").Runnable<any, string, import("@langchain/core/runnables").RunnableConfig>;
|
|
4
|
+
export { makeAssistant, Assistant };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAssistant = makeAssistant;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
23
|
+
const prompts_1 = require("@langchain/core/prompts");
|
|
24
|
+
const openai_1 = require("@langchain/openai");
|
|
25
|
+
function makeAssistant(config) {
|
|
26
|
+
const model = new openai_1.ChatOpenAI({
|
|
27
|
+
model: config.model,
|
|
28
|
+
apiKey: config.apiKey,
|
|
29
|
+
maxTokens: config.maxTokens,
|
|
30
|
+
temperature: config.temperature
|
|
31
|
+
});
|
|
32
|
+
const { systemTemplate } = config;
|
|
33
|
+
const parser = new output_parsers_1.StringOutputParser();
|
|
34
|
+
const promptTemplate = prompts_1.ChatPromptTemplate.fromMessages([
|
|
35
|
+
["system", systemTemplate],
|
|
36
|
+
["user", "{text}"]
|
|
37
|
+
]);
|
|
38
|
+
return promptTemplate.pipe(model).pipe(parser);
|
|
39
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OLIVIA_AI_PHONE_ASSISTANT = exports.RESTAURANT_PHONE_ASSISTANT = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
exports.RESTAURANT_PHONE_ASSISTANT = {
|
|
23
|
+
name: "Restaurant Phone Assistant",
|
|
24
|
+
firstMessage: "Hello, I'm Martha the AI assistant from Restaurant La Casa. How can I help you today?",
|
|
25
|
+
template: `
|
|
26
|
+
## La casa AI Phone Assistant (Martha)
|
|
27
|
+
|
|
28
|
+
### Mission Statement
|
|
29
|
+
|
|
30
|
+
To assist users in navigating our restaurant's offerings. This includes providing information on the menu,
|
|
31
|
+
handling reservations, and updating on special events.
|
|
32
|
+
|
|
33
|
+
### Interaction Modes
|
|
34
|
+
|
|
35
|
+
- **Age Restriction:** None; suitable for all ages.
|
|
36
|
+
- **Meal Options:** Brunch, Lunch, Dinner.
|
|
37
|
+
- **Special Notes:** Users should specify any dietary restrictions or preferences.
|
|
38
|
+
|
|
39
|
+
### Available Links
|
|
40
|
+
|
|
41
|
+
Since you are a AI Phone assistant, you can't browse the web. However, you can send links to the user's phone via SMS.
|
|
42
|
+
Here are some useful links for Restaurant La Casa:
|
|
43
|
+
|
|
44
|
+
- [Menu Information](https://www.lacasarestaurant.com/menu)
|
|
45
|
+
- [Make a Reservation](https://www.lacasarestaurant.com/reservations)
|
|
46
|
+
- [Special Events Details](https://www.lacasarestaurant.com/events)
|
|
47
|
+
|
|
48
|
+
### Hours of Operation
|
|
49
|
+
|
|
50
|
+
- **Brunch:** 9:00 AM - 12:00 PM
|
|
51
|
+
- **Lunch:** 12:00 PM - 3:00 PM
|
|
52
|
+
- **Dinner:** 5:00 PM - 10:00 PM
|
|
53
|
+
|
|
54
|
+
### Special Instructions
|
|
55
|
+
|
|
56
|
+
Provide accurate and timely responses to user inquiries. Stay on brand and maintain a friendly and professional tone.
|
|
57
|
+
Only provide information that is relevant to the user's request. If the user asks for something that is not within the scope of the system,
|
|
58
|
+
politely inform them that you are unable to assist with that request.
|
|
59
|
+
|
|
60
|
+
In case of any medical emergency instruct the user to call 911 immediately.
|
|
61
|
+
|
|
62
|
+
Make sure all response are readable by a TTS engine. For example, when reading the hours of operation, say "Brunch is served from 9:00 AM to 12:00 PM.".
|
|
63
|
+
Similarly, when providing links, say "I have sent you a link to the menu."
|
|
64
|
+
`
|
|
65
|
+
};
|
|
66
|
+
exports.OLIVIA_AI_PHONE_ASSISTANT = {
|
|
67
|
+
name: "Olivia AI Phone Assistant",
|
|
68
|
+
firstMessage: "Hello, I'm Olivia your friendly AI. What would you like to chat about today?",
|
|
69
|
+
template: `
|
|
70
|
+
## Olivia the friendly AI
|
|
71
|
+
|
|
72
|
+
### Mission Statement
|
|
73
|
+
|
|
74
|
+
Olivia is designed to help users by researching topics, bringing news updates, and telling engaging stories. Our goal is to provide accurate information and captivating narratives in a timely manner.
|
|
75
|
+
|
|
76
|
+
### Available Links
|
|
77
|
+
|
|
78
|
+
As an AI, Olivia can browse the web and retrieve information in real-time. Here are some resources that Olivia may use to enhance the user experience:
|
|
79
|
+
|
|
80
|
+
- [Latest News](https://www.news.com)
|
|
81
|
+
- [Popular Topics](https://www.populartopics.com)
|
|
82
|
+
- [Story Archive](https://www.storyarchive.com)
|
|
83
|
+
|
|
84
|
+
### Special Instructions
|
|
85
|
+
|
|
86
|
+
Provide accurate and up-to-date information on requested topics. Maintain a friendly, engaging, and creative tone. Ensure that all responses are clear and easy to understand. If a topic or request is beyond Olivia's capabilities, politely inform the user and suggest alternative sources if possible.
|
|
87
|
+
|
|
88
|
+
In case of urgent or critical news, inform users to consult trusted news sources immediately.
|
|
89
|
+
|
|
90
|
+
Make sure all responses are concise and engaging. For instance, when delivering news updates, say "Here’s the latest update on the topic." When telling stories, ensure the narrative is compelling and well-structured.
|
|
91
|
+
|
|
92
|
+
When telling story, begin with conversation starters like "Sure, I have a great story for you!" or "Let me tell you a fascinating tale!".
|
|
93
|
+
|
|
94
|
+
When you finish a story, or news summary, end with a conversation prompt like "What do you think?" or "Would you like to hear more?".
|
|
95
|
+
`
|
|
96
|
+
};
|
|
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.makeAssistant = void 0;
|
|
17
18
|
/*
|
|
18
|
-
* Copyright (C)
|
|
19
|
-
* http://github.com/fonoster
|
|
19
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
20
|
+
* http://github.com/fonoster/fonoster
|
|
20
21
|
*
|
|
21
|
-
* This file is part of
|
|
22
|
+
* This file is part of Fonoster
|
|
22
23
|
*
|
|
23
24
|
* Licensed under the MIT License (the "License");
|
|
24
25
|
* you may not use this file except in compliance with
|
|
@@ -32,4 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
33
|
* See the License for the specific language governing permissions and
|
|
33
34
|
* limitations under the License.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
var assistants_1 = require("./assistants");
|
|
37
|
+
Object.defineProperty(exports, "makeAssistant", { enumerable: true, get: function () { return assistants_1.makeAssistant; } });
|
|
38
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare enum Model {
|
|
2
|
+
GPT_3 = "gpt-3",
|
|
3
|
+
GPT_4 = "gpt-4",
|
|
4
|
+
GPT_4O_MINI = "gpt-4o-mini"
|
|
5
|
+
}
|
|
6
|
+
type AssistantConfig = {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
model: Model;
|
|
9
|
+
temperature: number;
|
|
10
|
+
maxTokens: number;
|
|
11
|
+
systemTemplate: string;
|
|
12
|
+
};
|
|
13
|
+
export { AssistantConfig, Model };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Model = void 0;
|
|
4
4
|
/*
|
|
5
|
-
* Copyright (C)
|
|
6
|
-
* http://github.com/fonoster/
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
7
|
*
|
|
8
|
-
* This file is part of
|
|
8
|
+
* This file is part of Fonoster
|
|
9
9
|
*
|
|
10
10
|
* Licensed under the MIT License (the "License");
|
|
11
11
|
* you may not use this file except in compliance with
|
|
@@ -19,11 +19,9 @@ exports.CLIENT_EVENTS = void 0;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
var
|
|
23
|
-
(function (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
CLIENT_EVENTS["HANGUP"] = "HANGUP";
|
|
29
|
-
})(CLIENT_EVENTS || (exports.CLIENT_EVENTS = CLIENT_EVENTS = {}));
|
|
22
|
+
var Model;
|
|
23
|
+
(function (Model) {
|
|
24
|
+
Model["GPT_3"] = "gpt-3";
|
|
25
|
+
Model["GPT_4"] = "gpt-4";
|
|
26
|
+
Model["GPT_4O_MINI"] = "gpt-4o-mini";
|
|
27
|
+
})(Model || (exports.Model = Model = {}));
|
package/dist/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/demo.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/*
|
|
16
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
17
|
+
* http://github.com/fonoster/fonoster
|
|
18
|
+
*
|
|
19
|
+
* This file is part of Fonoster
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the MIT License (the "License");
|
|
22
|
+
* you may not use this file except in compliance with
|
|
23
|
+
* the License. You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* https://opensource.org/licenses/MIT
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
const logger_1 = require("@fonoster/logger");
|
|
34
|
+
const voice_1 = __importDefault(require("@fonoster/voice"));
|
|
35
|
+
const examples_1 = require("./assistants/examples");
|
|
36
|
+
const types_1 = require("./assistants/types");
|
|
37
|
+
const Autopilot_1 = require("./Autopilot");
|
|
38
|
+
const envs_1 = require("./envs");
|
|
39
|
+
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
40
|
+
// Only skip identity for local development
|
|
41
|
+
new voice_1.default({ skipIdentity: true }).listen((req, voice) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const { ingressNumber, sessionRef, appRef } = req;
|
|
43
|
+
logger.verbose("voice request", { ingressNumber, sessionRef, appRef });
|
|
44
|
+
const { firstMessage, template: systemTemplate } = examples_1.OLIVIA_AI_PHONE_ASSISTANT;
|
|
45
|
+
const autopilot = new Autopilot_1.Autopilot({
|
|
46
|
+
voice,
|
|
47
|
+
firstMessage,
|
|
48
|
+
assistantConfig: {
|
|
49
|
+
apiKey: envs_1.OPENAI_API_KEY,
|
|
50
|
+
model: types_1.Model.GPT_4O_MINI,
|
|
51
|
+
temperature: 0.9,
|
|
52
|
+
maxTokens: 100,
|
|
53
|
+
systemTemplate
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
autopilot.start();
|
|
57
|
+
}));
|
package/dist/envs.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const APISERVER_AUTOPILOT_DEFAULT_LANGUAGE_CODE: string;
|
|
3
|
-
export declare const APISERVER_AUTOPILOT_MEDIA_BUSY_MESSAGE: string;
|
|
4
|
-
export declare const APISERVER_AUTOPILOT_MEDIA_NOANSWER_MESSAGE: string;
|
|
1
|
+
export declare const OPENAI_API_KEY: string | undefined;
|
package/dist/envs.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.OPENAI_API_KEY = void 0;
|
|
4
7
|
/*
|
|
5
|
-
* Copyright (C)
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
9
|
* http://github.com/fonoster/fonoster
|
|
7
10
|
*
|
|
8
11
|
* This file is part of Fonoster
|
|
@@ -19,9 +22,9 @@ exports.APISERVER_AUTOPILOT_MEDIA_NOANSWER_MESSAGE = exports.APISERVER_AUTOPILOT
|
|
|
19
22
|
* See the License for the specific language governing permissions and
|
|
20
23
|
* limitations under the License.
|
|
21
24
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.
|
|
25
|
+
const path_1 = require("path");
|
|
26
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
27
|
+
if (process.env.NODE_ENV === "dev") {
|
|
28
|
+
dotenv_1.default.config({ path: (0, path_1.join)(process.cwd(), ".env") });
|
|
29
|
+
}
|
|
30
|
+
exports.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { machine } from "./machine";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.machine = void 0;
|
|
6
4
|
/*
|
|
7
|
-
* Copyright (C)
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
8
6
|
* http://github.com/fonoster/fonoster
|
|
9
7
|
*
|
|
10
8
|
* This file is part of Fonoster
|
|
@@ -21,10 +19,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
19
|
* See the License for the specific language governing permissions and
|
|
22
20
|
* limitations under the License.
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, pilot_1.default)({
|
|
27
|
-
defaultLanguageCode: envs_1.APISERVER_AUTOPILOT_DEFAULT_LANGUAGE_CODE,
|
|
28
|
-
port: envs_1.APISERVER_AUTOPILOT_PORT,
|
|
29
|
-
eventsServerEnabled: false
|
|
30
|
-
});
|
|
22
|
+
var machine_1 = require("./machine");
|
|
23
|
+
Object.defineProperty(exports, "machine", { enumerable: true, get: function () { return machine_1.machine; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { machine } from "./machine";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.machine = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var machine_1 = require("./machine");
|
|
23
|
+
Object.defineProperty(exports, "machine", { enumerable: true, get: function () { return machine_1.machine; } });
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export declare const machine: import("xstate").StateMachine<{
|
|
2
|
+
firstMessage: string;
|
|
3
|
+
voice: import("@fonoster/voice").VoiceResponse;
|
|
4
|
+
assistant: import("../assistants/assistants").Assistant;
|
|
5
|
+
}, {
|
|
6
|
+
type: "VOICE_DETECTED";
|
|
7
|
+
} | {
|
|
8
|
+
type: "HUMAN_PROMPT";
|
|
9
|
+
speech: string;
|
|
10
|
+
}, {}, never, import("xstate").Values<{
|
|
11
|
+
sendGreeting: {
|
|
12
|
+
type: "sendGreeting";
|
|
13
|
+
params: unknown;
|
|
14
|
+
};
|
|
15
|
+
interruptAISpeaking: {
|
|
16
|
+
type: "interruptAISpeaking";
|
|
17
|
+
params: unknown;
|
|
18
|
+
};
|
|
19
|
+
processHumanRequest: {
|
|
20
|
+
type: "processHumanRequest";
|
|
21
|
+
params: unknown;
|
|
22
|
+
};
|
|
23
|
+
hangup: {
|
|
24
|
+
type: "hangup";
|
|
25
|
+
params: unknown;
|
|
26
|
+
};
|
|
27
|
+
}>, never, never, "hangup" | "active" | "welcome" | "humanSpeaking", string, {
|
|
28
|
+
firstMessage: string;
|
|
29
|
+
voice: import("@fonoster/voice").VoiceResponse;
|
|
30
|
+
assistant: import("../assistants/assistants").Assistant;
|
|
31
|
+
}, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
|
|
32
|
+
readonly context: ({ input }: {
|
|
33
|
+
spawn: {
|
|
34
|
+
<TSrc extends never>(logic: TSrc, ...[options]: never): import("xstate").ActorRefFromLogic<never>;
|
|
35
|
+
<TLogic extends import("xstate").AnyActorLogic>(src: TLogic, options?: {
|
|
36
|
+
id?: never;
|
|
37
|
+
systemId?: string;
|
|
38
|
+
input?: import("xstate").InputFrom<TLogic> | undefined;
|
|
39
|
+
syncSnapshot?: boolean;
|
|
40
|
+
} | undefined): import("xstate").ActorRefFromLogic<TLogic>;
|
|
41
|
+
};
|
|
42
|
+
input: {
|
|
43
|
+
firstMessage: string;
|
|
44
|
+
voice: import("@fonoster/voice").VoiceResponse;
|
|
45
|
+
assistant: import("../assistants/assistants").Assistant;
|
|
46
|
+
};
|
|
47
|
+
self: import("xstate").ActorRef<import("xstate").MachineSnapshot<{
|
|
48
|
+
firstMessage: string;
|
|
49
|
+
voice: import("@fonoster/voice").VoiceResponse;
|
|
50
|
+
assistant: import("../assistants/assistants").Assistant;
|
|
51
|
+
}, {
|
|
52
|
+
type: "VOICE_DETECTED";
|
|
53
|
+
} | {
|
|
54
|
+
type: "HUMAN_PROMPT";
|
|
55
|
+
speech: string;
|
|
56
|
+
}, Record<string, import("xstate").AnyActorRef | undefined>, import("xstate").StateValue, string, unknown, any, any>, {
|
|
57
|
+
type: "VOICE_DETECTED";
|
|
58
|
+
} | {
|
|
59
|
+
type: "HUMAN_PROMPT";
|
|
60
|
+
speech: string;
|
|
61
|
+
}, import("xstate").AnyEventObject>;
|
|
62
|
+
}) => {
|
|
63
|
+
firstMessage: string;
|
|
64
|
+
voice: import("@fonoster/voice").VoiceResponse;
|
|
65
|
+
assistant: import("@langchain/core/runnables").Runnable<any, string, import("@langchain/core/runnables").RunnableConfig>;
|
|
66
|
+
};
|
|
67
|
+
readonly id: "fnAI";
|
|
68
|
+
readonly initial: "welcome";
|
|
69
|
+
readonly states: {
|
|
70
|
+
readonly welcome: {
|
|
71
|
+
readonly always: {
|
|
72
|
+
readonly target: "active";
|
|
73
|
+
};
|
|
74
|
+
readonly entry: {
|
|
75
|
+
readonly type: "sendGreeting";
|
|
76
|
+
};
|
|
77
|
+
readonly description: "The initial state where the AI greets the Human.";
|
|
78
|
+
};
|
|
79
|
+
readonly active: {
|
|
80
|
+
readonly on: {
|
|
81
|
+
readonly HUMAN_PROMPT: {
|
|
82
|
+
readonly target: "active";
|
|
83
|
+
readonly actions: {
|
|
84
|
+
readonly type: "processHumanRequest";
|
|
85
|
+
};
|
|
86
|
+
readonly description: "This must be triggered when speech to text ends.";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly description: "The state where the AI is actively engaged in conversation.";
|
|
90
|
+
};
|
|
91
|
+
readonly humanSpeaking: {
|
|
92
|
+
readonly always: {
|
|
93
|
+
readonly target: "active";
|
|
94
|
+
};
|
|
95
|
+
readonly entry: {
|
|
96
|
+
readonly type: "interruptAISpeaking";
|
|
97
|
+
};
|
|
98
|
+
readonly description: "The state where the AI detects Human speech while it is speaking.";
|
|
99
|
+
};
|
|
100
|
+
readonly hangup: {
|
|
101
|
+
readonly type: "final";
|
|
102
|
+
readonly description: "The final state where the AI terminates the conversation due to inactivity.";
|
|
103
|
+
readonly entry: {
|
|
104
|
+
readonly type: "hangup";
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}>;
|