@fonoster/autopilot 0.9.46 → 0.9.48
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/machine/actions/greetUser.js +3 -0
- package/dist/machine/context.d.ts +1 -0
- package/dist/machine/context.js +2 -1
- package/dist/machine/machine.d.ts +1 -0
- package/dist/machine/types.d.ts +1 -0
- package/dist/models/LanguageModelFactory.d.ts +23 -1
- package/dist/models/LanguageModelFactory.js +5 -1
- package/dist/models/anthropic/Anthropic.d.ts +9 -0
- package/dist/models/anthropic/Anthropic.js +40 -0
- package/dist/models/anthropic/index.d.ts +20 -0
- package/dist/models/anthropic/index.js +36 -0
- package/dist/models/anthropic/types.d.ts +30 -0
- package/dist/models/anthropic/types.js +8 -0
- package/dist/models/createPromptTemplate.js +14 -7
- package/dist/models/google/Google.d.ts +9 -0
- package/dist/models/google/Google.js +20 -0
- package/dist/models/google/index.d.ts +20 -0
- package/dist/models/google/index.js +36 -0
- package/dist/models/google/types.d.ts +31 -0
- package/dist/models/google/types.js +9 -0
- package/dist/models/groq/types.d.ts +2 -2
- package/dist/models/groq/types.js +1 -1
- package/dist/tools/builtin/hangupToolDefinition.js +7 -2
- package/dist/tools/builtin/transferToolDefinition.js +7 -2
- package/dist/tools/convertToolToLangchainTool.d.ts +4 -0
- package/dist/tools/convertToolToLangchainTool.js +32 -0
- package/dist/types.d.ts +1 -6
- package/dist/types.js +1 -7
- package/dist/voice/Voice.d.ts +1 -0
- package/dist/voice/Voice.js +3 -0
- package/dist/voice/types.d.ts +1 -0
- package/package.json +8 -5
|
@@ -26,6 +26,9 @@ const greetUser = async ({ context }) => {
|
|
|
26
26
|
firstMessage: context.firstMessage
|
|
27
27
|
});
|
|
28
28
|
await context.voice.answer();
|
|
29
|
+
if (context.initialDtmf) {
|
|
30
|
+
await context.voice.playDtmf(context.initialDtmf);
|
|
31
|
+
}
|
|
29
32
|
if (context.firstMessage) {
|
|
30
33
|
await context.voice.say(context.firstMessage);
|
|
31
34
|
}
|
package/dist/machine/context.js
CHANGED
|
@@ -19,6 +19,7 @@ const context = ({ input }) => ({
|
|
|
19
19
|
maxSpeechWaitTimeout: input.conversationSettings.maxSpeechWaitTimeout,
|
|
20
20
|
isSpeaking: false,
|
|
21
21
|
sessionStartTime: Date.now(),
|
|
22
|
-
maxSessionDuration: input.conversationSettings.maxSessionDuration
|
|
22
|
+
maxSessionDuration: input.conversationSettings.maxSessionDuration,
|
|
23
|
+
initialDtmf: input.conversationSettings.initialDtmf
|
|
23
24
|
});
|
|
24
25
|
exports.context = context;
|
|
@@ -101,6 +101,7 @@ declare const machine: import("xstate").StateMachine<any, import("./types").Auto
|
|
|
101
101
|
isSpeaking: boolean;
|
|
102
102
|
sessionStartTime: number;
|
|
103
103
|
maxSessionDuration: number;
|
|
104
|
+
initialDtmf: string;
|
|
104
105
|
};
|
|
105
106
|
readonly id: "fnAI";
|
|
106
107
|
readonly initial: "greeting";
|
package/dist/machine/types.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
|
|
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 { LanguageModelProvider } from "@fonoster/common";
|
|
2
20
|
import { Voice } from "../voice";
|
|
3
21
|
import { AbstractLanguageModel } from "./AbstractLanguageModel";
|
|
22
|
+
import { AnthropicParams } from "./anthropic";
|
|
23
|
+
import { GoogleParams } from "./google";
|
|
4
24
|
import { GroqParams } from "./groq";
|
|
5
25
|
import { OllamaParams } from "./ollama";
|
|
6
26
|
import { OpenAIParams } from "./openai";
|
|
@@ -10,6 +30,8 @@ type LanguageModelConfigMap = {
|
|
|
10
30
|
[LanguageModelProvider.OPENAI]: OpenAIParams;
|
|
11
31
|
[LanguageModelProvider.GROQ]: GroqParams;
|
|
12
32
|
[LanguageModelProvider.OLLAMA]: OllamaParams;
|
|
33
|
+
[LanguageModelProvider.GOOGLE]: GoogleParams;
|
|
34
|
+
[LanguageModelProvider.ANTHROPIC]: AnthropicParams;
|
|
13
35
|
};
|
|
14
36
|
declare class LanguageModelFactory {
|
|
15
37
|
private static readonly languageModels;
|
|
@@ -19,8 +19,10 @@ exports.LanguageModelFactory = void 0;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
+
const common_1 = require("@fonoster/common");
|
|
22
23
|
const logger_1 = require("@fonoster/logger");
|
|
23
|
-
const
|
|
24
|
+
const anthropic_1 = require("./anthropic");
|
|
25
|
+
const google_1 = require("./google");
|
|
24
26
|
const groq_1 = require("./groq");
|
|
25
27
|
const ollama_1 = require("./ollama");
|
|
26
28
|
const openai_1 = require("./openai");
|
|
@@ -44,3 +46,5 @@ LanguageModelFactory.languageModels = new Map();
|
|
|
44
46
|
LanguageModelFactory.registerLanguageModel(openai_1.LANGUAGE_MODEL_NAME, openai_1.OpenAI);
|
|
45
47
|
LanguageModelFactory.registerLanguageModel(groq_1.LANGUAGE_MODEL_NAME, groq_1.Groq);
|
|
46
48
|
LanguageModelFactory.registerLanguageModel(ollama_1.LANGUAGE_MODEL_NAME, ollama_1.Ollama);
|
|
49
|
+
LanguageModelFactory.registerLanguageModel(google_1.LANGUAGE_MODEL_NAME, google_1.Google);
|
|
50
|
+
LanguageModelFactory.registerLanguageModel(anthropic_1.LANGUAGE_MODEL_NAME, anthropic_1.Anthropic);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Voice } from "../../voice";
|
|
2
|
+
import { AbstractLanguageModel } from "../AbstractLanguageModel";
|
|
3
|
+
import { TelephonyContext } from "../types";
|
|
4
|
+
import { AnthropicParams } from "./types";
|
|
5
|
+
declare const LANGUAGE_MODEL_NAME = "llm.anthropic";
|
|
6
|
+
declare class Anthropic extends AbstractLanguageModel {
|
|
7
|
+
constructor(params: AnthropicParams, voice: Voice, telephonyContext: TelephonyContext);
|
|
8
|
+
}
|
|
9
|
+
export { Anthropic, LANGUAGE_MODEL_NAME };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LANGUAGE_MODEL_NAME = exports.Anthropic = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 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 anthropic_1 = require("@langchain/anthropic");
|
|
23
|
+
const tools_1 = require("../../tools");
|
|
24
|
+
const AbstractLanguageModel_1 = require("../AbstractLanguageModel");
|
|
25
|
+
const LANGUAGE_MODEL_NAME = "llm.anthropic";
|
|
26
|
+
exports.LANGUAGE_MODEL_NAME = LANGUAGE_MODEL_NAME;
|
|
27
|
+
class Anthropic extends AbstractLanguageModel_1.AbstractLanguageModel {
|
|
28
|
+
constructor(params, voice, telephonyContext) {
|
|
29
|
+
const model = new anthropic_1.ChatAnthropic({
|
|
30
|
+
...params
|
|
31
|
+
}).bind({
|
|
32
|
+
tools: params.tools.map(tools_1.convertToolToOpenAITool)
|
|
33
|
+
});
|
|
34
|
+
super({
|
|
35
|
+
...params,
|
|
36
|
+
model
|
|
37
|
+
}, voice, telephonyContext);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Anthropic = Anthropic;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export * from "./Anthropic";
|
|
20
|
+
export * from "./types";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./Anthropic"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { BaseModelParams } from "../types";
|
|
20
|
+
declare enum AnthropicModel {
|
|
21
|
+
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-latest",
|
|
22
|
+
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-latest"
|
|
23
|
+
}
|
|
24
|
+
type AnthropicParams = BaseModelParams & {
|
|
25
|
+
model: AnthropicModel;
|
|
26
|
+
apiKey: string;
|
|
27
|
+
maxTokens: number;
|
|
28
|
+
temperature: number;
|
|
29
|
+
};
|
|
30
|
+
export { AnthropicModel, AnthropicParams };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnthropicModel = void 0;
|
|
4
|
+
var AnthropicModel;
|
|
5
|
+
(function (AnthropicModel) {
|
|
6
|
+
AnthropicModel["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-latest";
|
|
7
|
+
AnthropicModel["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-latest";
|
|
8
|
+
})(AnthropicModel || (exports.AnthropicModel = AnthropicModel = {}));
|
|
@@ -23,14 +23,21 @@ const prompts_1 = require("@langchain/core/prompts");
|
|
|
23
23
|
function createPromptTemplate(params) {
|
|
24
24
|
const { firstMessage, systemPrompt, telephonyContext } = params;
|
|
25
25
|
return prompts_1.ChatPromptTemplate.fromMessages([
|
|
26
|
+
prompts_1.SystemMessagePromptTemplate.fromTemplate(`${systemPrompt}
|
|
27
|
+
|
|
28
|
+
[First Message from System]
|
|
29
|
+
${firstMessage}
|
|
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
|
+
`),
|
|
26
40
|
new prompts_1.MessagesPlaceholder("history"),
|
|
27
|
-
prompts_1.SystemMessagePromptTemplate.fromTemplate(`firstMessage: ${firstMessage}`),
|
|
28
|
-
prompts_1.SystemMessagePromptTemplate.fromTemplate(systemPrompt),
|
|
29
|
-
prompts_1.SystemMessagePromptTemplate.fromTemplate("{context}"),
|
|
30
|
-
prompts_1.SystemMessagePromptTemplate.fromTemplate(`callReceivedAt:${new Date().toISOString()}
|
|
31
|
-
ingressNumber:${telephonyContext.ingressNumber}
|
|
32
|
-
callerNumber:${telephonyContext.callerNumber}
|
|
33
|
-
callDirection:${telephonyContext.callDirection}`),
|
|
34
41
|
prompts_1.HumanMessagePromptTemplate.fromTemplate("{input}")
|
|
35
42
|
]);
|
|
36
43
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Voice } from "../../voice";
|
|
2
|
+
import { AbstractLanguageModel } from "../AbstractLanguageModel";
|
|
3
|
+
import { TelephonyContext } from "../types";
|
|
4
|
+
import { GoogleParams } from "./types";
|
|
5
|
+
declare const LANGUAGE_MODEL_NAME = "llm.google";
|
|
6
|
+
declare class Google extends AbstractLanguageModel {
|
|
7
|
+
constructor(params: GoogleParams, voice: Voice, telephonyContext: TelephonyContext);
|
|
8
|
+
}
|
|
9
|
+
export { Google, LANGUAGE_MODEL_NAME };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LANGUAGE_MODEL_NAME = exports.Google = void 0;
|
|
4
|
+
const google_genai_1 = require("@langchain/google-genai");
|
|
5
|
+
const convertToolToLangchainTool_1 = require("../../tools/convertToolToLangchainTool");
|
|
6
|
+
const AbstractLanguageModel_1 = require("../AbstractLanguageModel");
|
|
7
|
+
const LANGUAGE_MODEL_NAME = "llm.google";
|
|
8
|
+
exports.LANGUAGE_MODEL_NAME = LANGUAGE_MODEL_NAME;
|
|
9
|
+
class Google extends AbstractLanguageModel_1.AbstractLanguageModel {
|
|
10
|
+
constructor(params, voice, telephonyContext) {
|
|
11
|
+
const model = new google_genai_1.ChatGoogleGenerativeAI({
|
|
12
|
+
...params
|
|
13
|
+
}).bindTools(params.tools.map(convertToolToLangchainTool_1.convertToolToLangchainTool));
|
|
14
|
+
super({
|
|
15
|
+
...params,
|
|
16
|
+
model
|
|
17
|
+
}, voice, telephonyContext);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Google = Google;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export * from "./Google";
|
|
20
|
+
export * from "./types";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./Google"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { BaseModelParams } from "../types";
|
|
20
|
+
declare enum GoogleModel {
|
|
21
|
+
GEMINI_2_0_FLASH = "gemini-2.0-flash",
|
|
22
|
+
GEMINI_2_0_FLASH_LITE = "gemini-2.0-flash-lite",
|
|
23
|
+
GEMINI_2_0_PRO_EXP_02_05 = "gemini-2.0-pro-exp-02-05"
|
|
24
|
+
}
|
|
25
|
+
type GoogleParams = BaseModelParams & {
|
|
26
|
+
model: GoogleModel;
|
|
27
|
+
apiKey: string;
|
|
28
|
+
maxTokens: number;
|
|
29
|
+
temperature: number;
|
|
30
|
+
};
|
|
31
|
+
export { GoogleModel, GoogleParams };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleModel = void 0;
|
|
4
|
+
var GoogleModel;
|
|
5
|
+
(function (GoogleModel) {
|
|
6
|
+
GoogleModel["GEMINI_2_0_FLASH"] = "gemini-2.0-flash";
|
|
7
|
+
GoogleModel["GEMINI_2_0_FLASH_LITE"] = "gemini-2.0-flash-lite";
|
|
8
|
+
GoogleModel["GEMINI_2_0_PRO_EXP_02_05"] = "gemini-2.0-pro-exp-02-05";
|
|
9
|
+
})(GoogleModel || (exports.GoogleModel = GoogleModel = {}));
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { BaseModelParams } from "../types";
|
|
20
20
|
declare enum GroqModel {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
LLAMA3_3_3_70B_SPECDEC = "llama-3.3-70b-specdec",
|
|
22
|
+
LLAMA3_3_3_70B_VERSATILE = "llama-3.3-70b-versatile"
|
|
23
23
|
}
|
|
24
24
|
type GroqParams = BaseModelParams & {
|
|
25
25
|
model: GroqModel;
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GroqModel = void 0;
|
|
4
4
|
var GroqModel;
|
|
5
5
|
(function (GroqModel) {
|
|
6
|
-
GroqModel["LLAMA3_1_8B_INSTANT"] = "llama-3.1-8b-instant";
|
|
7
6
|
GroqModel["LLAMA3_3_3_70B_SPECDEC"] = "llama-3.3-70b-specdec";
|
|
7
|
+
GroqModel["LLAMA3_3_3_70B_VERSATILE"] = "llama-3.3-70b-versatile";
|
|
8
8
|
})(GroqModel || (exports.GroqModel = GroqModel = {}));
|
|
@@ -6,8 +6,13 @@ const hangupToolDefinition = {
|
|
|
6
6
|
description: "Hangup the call and end the conversation",
|
|
7
7
|
parameters: {
|
|
8
8
|
type: "object",
|
|
9
|
-
properties: {
|
|
10
|
-
|
|
9
|
+
properties: {
|
|
10
|
+
// FIXME: Workaround for Google LLMs issue
|
|
11
|
+
// GenerateContentRequest.tools[0].function_declarations[1].parameters.properties: should be non-empty for OBJECT type
|
|
12
|
+
noop: {
|
|
13
|
+
type: "boolean"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
};
|
|
13
18
|
exports.hangupToolDefinition = hangupToolDefinition;
|
|
@@ -6,8 +6,13 @@ const transferToolDefinition = {
|
|
|
6
6
|
description: "Transfer the call to a live agent",
|
|
7
7
|
parameters: {
|
|
8
8
|
type: "object",
|
|
9
|
-
properties: {
|
|
10
|
-
|
|
9
|
+
properties: {
|
|
10
|
+
// FIXME: Workaround for Google LLMs issue
|
|
11
|
+
// GenerateContentRequest.tools[0].function_declarations[1].parameters.properties: should be non-empty for OBJECT type
|
|
12
|
+
noop: {
|
|
13
|
+
type: "boolean"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
};
|
|
13
18
|
exports.transferToolDefinition = transferToolDefinition;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToolToLangchainTool = convertToolToLangchainTool;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 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 json_schema_to_zod_1 = require("@dmitryrechkin/json-schema-to-zod");
|
|
23
|
+
const zod_1 = require("zod");
|
|
24
|
+
function convertToolToLangchainTool(customTool) {
|
|
25
|
+
return {
|
|
26
|
+
name: customTool.name,
|
|
27
|
+
description: customTool.description,
|
|
28
|
+
schema: customTool.parameters?.properties
|
|
29
|
+
? json_schema_to_zod_1.JSONSchemaToZod.convert(customTool.parameters)
|
|
30
|
+
: zod_1.z.object({})
|
|
31
|
+
};
|
|
32
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -20,11 +20,6 @@ import { Application } from "@fonoster/types";
|
|
|
20
20
|
import { AssistantConfig, ConversationSettings } from "./assistants";
|
|
21
21
|
import { LanguageModel } from "./models";
|
|
22
22
|
import { Voice } from "./voice";
|
|
23
|
-
declare enum LanguageModelProvider {
|
|
24
|
-
OPENAI = "openai",
|
|
25
|
-
GROQ = "groq",
|
|
26
|
-
OLLAMA = "ollama"
|
|
27
|
-
}
|
|
28
23
|
declare enum ConversationProvider {
|
|
29
24
|
FILE = "file",
|
|
30
25
|
API = "api"
|
|
@@ -40,4 +35,4 @@ type AutopilotApplication = Application & {
|
|
|
40
35
|
config: AssistantConfig;
|
|
41
36
|
};
|
|
42
37
|
};
|
|
43
|
-
export { AutopilotParams,
|
|
38
|
+
export { AutopilotParams, ConversationProvider, AutopilotApplication };
|
package/dist/types.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConversationProvider =
|
|
4
|
-
var LanguageModelProvider;
|
|
5
|
-
(function (LanguageModelProvider) {
|
|
6
|
-
LanguageModelProvider["OPENAI"] = "openai";
|
|
7
|
-
LanguageModelProvider["GROQ"] = "groq";
|
|
8
|
-
LanguageModelProvider["OLLAMA"] = "ollama";
|
|
9
|
-
})(LanguageModelProvider || (exports.LanguageModelProvider = LanguageModelProvider = {}));
|
|
3
|
+
exports.ConversationProvider = void 0;
|
|
10
4
|
var ConversationProvider;
|
|
11
5
|
(function (ConversationProvider) {
|
|
12
6
|
ConversationProvider["FILE"] = "file";
|
package/dist/voice/Voice.d.ts
CHANGED
package/dist/voice/Voice.js
CHANGED
|
@@ -36,6 +36,9 @@ class VoiceImpl {
|
|
|
36
36
|
async say(text) {
|
|
37
37
|
await this.voice.say(text, { playbackRef: this.playbackRef });
|
|
38
38
|
}
|
|
39
|
+
async playDtmf(dtmf) {
|
|
40
|
+
await this.voice.playDtmf(dtmf);
|
|
41
|
+
}
|
|
39
42
|
async sgather() {
|
|
40
43
|
const stream = await this.voice.sgather({
|
|
41
44
|
source: common_1.StreamGatherSource.SPEECH
|
package/dist/voice/types.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ type Voice = {
|
|
|
36
36
|
answer: () => Promise<void>;
|
|
37
37
|
hangup: () => Promise<void>;
|
|
38
38
|
say: (text: string) => Promise<void>;
|
|
39
|
+
playDtmf: (dtmf: string) => Promise<void>;
|
|
39
40
|
sgather: () => Promise<GatherStream>;
|
|
40
41
|
transfer: (destination: string, options?: TransferOptions) => Promise<void>;
|
|
41
42
|
stream: () => Promise<Stream>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.48",
|
|
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",
|
|
@@ -33,13 +33,16 @@
|
|
|
33
33
|
},
|
|
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.48",
|
|
37
38
|
"@fonoster/logger": "^0.9.46",
|
|
38
|
-
"@fonoster/sdk": "^0.9.
|
|
39
|
+
"@fonoster/sdk": "^0.9.48",
|
|
39
40
|
"@fonoster/types": "^0.9.46",
|
|
40
|
-
"@fonoster/voice": "^0.9.
|
|
41
|
+
"@fonoster/voice": "^0.9.48",
|
|
42
|
+
"@langchain/anthropic": "^0.3.15",
|
|
41
43
|
"@langchain/community": "^0.3.32",
|
|
42
44
|
"@langchain/core": "^0.3.40",
|
|
45
|
+
"@langchain/google-genai": "^0.1.11",
|
|
43
46
|
"@langchain/groq": "^0.1.3",
|
|
44
47
|
"@langchain/ollama": "^0.1.6",
|
|
45
48
|
"@langchain/openai": "^0.4.4",
|
|
@@ -56,5 +59,5 @@
|
|
|
56
59
|
"xstate": "^5.17.3",
|
|
57
60
|
"zod": "^3.23.8"
|
|
58
61
|
},
|
|
59
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "7c9666911ad017363ea4d99b06c2f6cc915d5c91"
|
|
60
63
|
}
|