@fonoster/autopilot 0.7.15 → 0.7.17
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/README.md +6 -2
- package/dist/assistants/AssistantSchema.d.ts +16 -0
- package/dist/assistants/AssistantSchema.js +2 -0
- package/dist/createLanguageModel.js +2 -2
- package/dist/envs.d.ts +0 -2
- package/dist/envs.js +1 -3
- package/dist/models/LanguageModelFactory.d.ts +2 -0
- package/dist/models/LanguageModelFactory.js +2 -0
- package/dist/models/ollama/Ollama.d.ts +8 -0
- package/dist/models/ollama/Ollama.js +22 -0
- package/dist/models/ollama/index.d.ts +2 -0
- package/dist/models/ollama/index.js +36 -0
- package/dist/models/ollama/types.d.ts +11 -0
- package/dist/models/ollama/types.js +7 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.js +1 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -40,7 +40,8 @@ The configuration file has two major sections: `conversationSettings` and `langu
|
|
|
40
40
|
"initialDtmf": "6589",
|
|
41
41
|
"transferOptions": {
|
|
42
42
|
"phoneNumber": "+15555555555",
|
|
43
|
-
"message": "Please hold while I transfer you to a live agent."
|
|
43
|
+
"message": "Please hold while I transfer you to a live agent.",
|
|
44
|
+
"timeout": 30000
|
|
44
45
|
},
|
|
45
46
|
"idleOptions": {
|
|
46
47
|
"message": "Are you still there?",
|
|
@@ -127,7 +128,10 @@ You can configure a new tool by adding a new entry in the `tools` array in the c
|
|
|
127
128
|
},
|
|
128
129
|
"operation": {
|
|
129
130
|
"type": "get",
|
|
130
|
-
"url": "https://api.example.com/appointment-times"
|
|
131
|
+
"url": "https://api.example.com/appointment-times",
|
|
132
|
+
"headers": {
|
|
133
|
+
"x-api-key": "your-api-key"
|
|
134
|
+
}
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
]
|
|
@@ -67,9 +67,11 @@ declare const conversationSettingsSchema: z.ZodObject<{
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const languageModelConfigSchema: z.ZodObject<{
|
|
69
69
|
provider: z.ZodNativeEnum<typeof LANGUAGE_MODEL_PROVIDER>;
|
|
70
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
70
71
|
model: z.ZodString;
|
|
71
72
|
temperature: z.ZodNumber;
|
|
72
73
|
maxTokens: z.ZodNumber;
|
|
74
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
73
75
|
knowledgeBase: z.ZodArray<z.ZodObject<{
|
|
74
76
|
type: z.ZodEnum<["s3", "file"]>;
|
|
75
77
|
title: z.ZodString;
|
|
@@ -219,6 +221,8 @@ declare const languageModelConfigSchema: z.ZodObject<{
|
|
|
219
221
|
temperature: number;
|
|
220
222
|
maxTokens: number;
|
|
221
223
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
224
|
+
apiKey?: string | undefined;
|
|
225
|
+
baseUrl?: string | undefined;
|
|
222
226
|
}, {
|
|
223
227
|
model: string;
|
|
224
228
|
knowledgeBase: {
|
|
@@ -248,6 +252,8 @@ declare const languageModelConfigSchema: z.ZodObject<{
|
|
|
248
252
|
temperature: number;
|
|
249
253
|
maxTokens: number;
|
|
250
254
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
255
|
+
apiKey?: string | undefined;
|
|
256
|
+
baseUrl?: string | undefined;
|
|
251
257
|
}>;
|
|
252
258
|
declare const assistantSchema: z.ZodObject<{
|
|
253
259
|
conversationSettings: z.ZodObject<{
|
|
@@ -317,9 +323,11 @@ declare const assistantSchema: z.ZodObject<{
|
|
|
317
323
|
}>;
|
|
318
324
|
languageModel: z.ZodObject<{
|
|
319
325
|
provider: z.ZodNativeEnum<typeof LANGUAGE_MODEL_PROVIDER>;
|
|
326
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
320
327
|
model: z.ZodString;
|
|
321
328
|
temperature: z.ZodNumber;
|
|
322
329
|
maxTokens: z.ZodNumber;
|
|
330
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
323
331
|
knowledgeBase: z.ZodArray<z.ZodObject<{
|
|
324
332
|
type: z.ZodEnum<["s3", "file"]>;
|
|
325
333
|
title: z.ZodString;
|
|
@@ -469,6 +477,8 @@ declare const assistantSchema: z.ZodObject<{
|
|
|
469
477
|
temperature: number;
|
|
470
478
|
maxTokens: number;
|
|
471
479
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
480
|
+
apiKey?: string | undefined;
|
|
481
|
+
baseUrl?: string | undefined;
|
|
472
482
|
}, {
|
|
473
483
|
model: string;
|
|
474
484
|
knowledgeBase: {
|
|
@@ -498,6 +508,8 @@ declare const assistantSchema: z.ZodObject<{
|
|
|
498
508
|
temperature: number;
|
|
499
509
|
maxTokens: number;
|
|
500
510
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
511
|
+
apiKey?: string | undefined;
|
|
512
|
+
baseUrl?: string | undefined;
|
|
501
513
|
}>;
|
|
502
514
|
}, "strip", z.ZodTypeAny, {
|
|
503
515
|
conversationSettings: {
|
|
@@ -546,6 +558,8 @@ declare const assistantSchema: z.ZodObject<{
|
|
|
546
558
|
temperature: number;
|
|
547
559
|
maxTokens: number;
|
|
548
560
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
561
|
+
apiKey?: string | undefined;
|
|
562
|
+
baseUrl?: string | undefined;
|
|
549
563
|
};
|
|
550
564
|
}, {
|
|
551
565
|
conversationSettings: {
|
|
@@ -594,6 +608,8 @@ declare const assistantSchema: z.ZodObject<{
|
|
|
594
608
|
temperature: number;
|
|
595
609
|
maxTokens: number;
|
|
596
610
|
provider: LANGUAGE_MODEL_PROVIDER;
|
|
611
|
+
apiKey?: string | undefined;
|
|
612
|
+
baseUrl?: string | undefined;
|
|
597
613
|
};
|
|
598
614
|
}>;
|
|
599
615
|
export { assistantSchema, conversationSettingsSchema, languageModelConfigSchema };
|
|
@@ -48,9 +48,11 @@ const conversationSettingsSchema = zod_1.z.object({
|
|
|
48
48
|
exports.conversationSettingsSchema = conversationSettingsSchema;
|
|
49
49
|
const languageModelConfigSchema = zod_1.z.object({
|
|
50
50
|
provider: zod_1.z.nativeEnum(types_1.LANGUAGE_MODEL_PROVIDER),
|
|
51
|
+
apiKey: zod_1.z.string().optional(),
|
|
51
52
|
model: zod_1.z.string(),
|
|
52
53
|
temperature: zod_1.z.number(),
|
|
53
54
|
maxTokens: zod_1.z.number(),
|
|
55
|
+
baseUrl: zod_1.z.string().optional(),
|
|
54
56
|
knowledgeBase: zod_1.z.array(zod_1.z.object({
|
|
55
57
|
type: zod_1.z.enum(["s3", "file"]),
|
|
56
58
|
title: zod_1.z.string(),
|
|
@@ -19,17 +19,17 @@ exports.createLanguageModel = createLanguageModel;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
const envs_1 = require("./envs");
|
|
23
22
|
const _1 = require(".");
|
|
24
23
|
function createLanguageModel(assistantConfig, knowledgeBase, telephonyContext) {
|
|
25
24
|
const { languageModel: languageModelSettings, conversationSettings } = assistantConfig;
|
|
26
25
|
return _1.LanguageModelFactory.getLanguageModel(languageModelSettings.provider, {
|
|
27
|
-
apiKey:
|
|
26
|
+
apiKey: languageModelSettings.apiKey,
|
|
28
27
|
// @ts-expect-error don't know the model type here
|
|
29
28
|
model: languageModelSettings.model,
|
|
30
29
|
maxTokens: languageModelSettings.maxTokens,
|
|
31
30
|
temperature: languageModelSettings.temperature,
|
|
32
31
|
systemTemplate: conversationSettings.systemTemplate,
|
|
32
|
+
baseUrl: languageModelSettings.baseUrl,
|
|
33
33
|
knowledgeBase,
|
|
34
34
|
tools: [
|
|
35
35
|
...languageModelSettings.tools,
|
package/dist/envs.d.ts
CHANGED
package/dist/envs.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ASSISTANT = void 0;
|
|
7
7
|
/*
|
|
8
8
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
9
|
* http://github.com/fonoster/fonoster
|
|
@@ -31,5 +31,3 @@ if (process.env.NODE_ENV === "dev") {
|
|
|
31
31
|
(0, common_1.assertEnvsAreSet)(["ASSISTANT"]);
|
|
32
32
|
(0, common_1.assertFileExists)(process.env.ASSISTANT);
|
|
33
33
|
exports.ASSISTANT = process.env.ASSISTANT;
|
|
34
|
-
exports.GROQ_API_KEY = process.env.GROQ_API_KEY;
|
|
35
|
-
exports.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractLanguageModel } from "./AbstractLanguageModel";
|
|
2
2
|
import { GroqParams } from "./groq";
|
|
3
|
+
import { OllamaParams } from "./ollama";
|
|
3
4
|
import { OpenAIParams } from "./openai";
|
|
4
5
|
import { BaseModelParams, TelephonyContext } from "./types";
|
|
5
6
|
import { LANGUAGE_MODEL_PROVIDER } from "../types";
|
|
@@ -7,6 +8,7 @@ type LanguageModelConstructor<T extends BaseModelParams = BaseModelParams> = new
|
|
|
7
8
|
type LanguageModelConfigMap = {
|
|
8
9
|
[LANGUAGE_MODEL_PROVIDER.OPENAI]: OpenAIParams;
|
|
9
10
|
[LANGUAGE_MODEL_PROVIDER.GROQ]: GroqParams;
|
|
11
|
+
[LANGUAGE_MODEL_PROVIDER.OLLAMA]: OllamaParams;
|
|
10
12
|
};
|
|
11
13
|
declare class LanguageModelFactory {
|
|
12
14
|
private static languageModels;
|
|
@@ -21,6 +21,7 @@ exports.LanguageModelFactory = void 0;
|
|
|
21
21
|
*/
|
|
22
22
|
const logger_1 = require("@fonoster/logger");
|
|
23
23
|
const groq_1 = require("./groq");
|
|
24
|
+
const ollama_1 = require("./ollama");
|
|
24
25
|
const openai_1 = require("./openai");
|
|
25
26
|
const types_1 = require("../types");
|
|
26
27
|
const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
|
|
@@ -42,3 +43,4 @@ LanguageModelFactory.languageModels = new Map();
|
|
|
42
43
|
// Register language models
|
|
43
44
|
LanguageModelFactory.registerLanguageModel(openai_1.LANGUAGE_MODEL_NAME, openai_1.OpenAI);
|
|
44
45
|
LanguageModelFactory.registerLanguageModel(groq_1.LANGUAGE_MODEL_NAME, groq_1.Groq);
|
|
46
|
+
LanguageModelFactory.registerLanguageModel(ollama_1.LANGUAGE_MODEL_NAME, ollama_1.Ollama);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OllamaParams } from "./types";
|
|
2
|
+
import { AbstractLanguageModel } from "../AbstractLanguageModel";
|
|
3
|
+
import { TelephonyContext } from "../types";
|
|
4
|
+
declare const LANGUAGE_MODEL_NAME = "llm.ollama";
|
|
5
|
+
declare class Ollama extends AbstractLanguageModel {
|
|
6
|
+
constructor(params: OllamaParams, telephonyContext: TelephonyContext);
|
|
7
|
+
}
|
|
8
|
+
export { LANGUAGE_MODEL_NAME, Ollama };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ollama = exports.LANGUAGE_MODEL_NAME = void 0;
|
|
4
|
+
const ollama_1 = require("@langchain/ollama");
|
|
5
|
+
const tools_1 = require("../../tools");
|
|
6
|
+
const AbstractLanguageModel_1 = require("../AbstractLanguageModel");
|
|
7
|
+
const LANGUAGE_MODEL_NAME = "llm.ollama";
|
|
8
|
+
exports.LANGUAGE_MODEL_NAME = LANGUAGE_MODEL_NAME;
|
|
9
|
+
class Ollama extends AbstractLanguageModel_1.AbstractLanguageModel {
|
|
10
|
+
constructor(params, telephonyContext) {
|
|
11
|
+
const model = new ollama_1.ChatOllama({
|
|
12
|
+
...params
|
|
13
|
+
}).bind({
|
|
14
|
+
tools: params.tools.map(tools_1.convertToolToOpenAITool)
|
|
15
|
+
});
|
|
16
|
+
super({
|
|
17
|
+
...params,
|
|
18
|
+
model
|
|
19
|
+
}, telephonyContext);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Ollama = Ollama;
|
|
@@ -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) 2024 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("./Ollama"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseModelParams } from "../types";
|
|
2
|
+
declare enum OllamaModel {
|
|
3
|
+
LLAMA3_1 = "llama3.1"
|
|
4
|
+
}
|
|
5
|
+
type OllamaParams = BaseModelParams & {
|
|
6
|
+
model: OllamaModel;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
maxTokens: number;
|
|
9
|
+
temperature: number;
|
|
10
|
+
};
|
|
11
|
+
export { OllamaModel, OllamaParams };
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -5,4 +5,5 @@ var LANGUAGE_MODEL_PROVIDER;
|
|
|
5
5
|
(function (LANGUAGE_MODEL_PROVIDER) {
|
|
6
6
|
LANGUAGE_MODEL_PROVIDER["OPENAI"] = "openai";
|
|
7
7
|
LANGUAGE_MODEL_PROVIDER["GROQ"] = "groq";
|
|
8
|
+
LANGUAGE_MODEL_PROVIDER["OLLAMA"] = "ollama";
|
|
8
9
|
})(LANGUAGE_MODEL_PROVIDER || (exports.LANGUAGE_MODEL_PROVIDER = LANGUAGE_MODEL_PROVIDER = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
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",
|
|
@@ -35,13 +35,14 @@
|
|
|
35
35
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fonoster/common": "^0.7.
|
|
39
|
-
"@fonoster/logger": "^0.7.
|
|
40
|
-
"@fonoster/types": "^0.7.
|
|
41
|
-
"@fonoster/voice": "^0.7.
|
|
38
|
+
"@fonoster/common": "^0.7.16",
|
|
39
|
+
"@fonoster/logger": "^0.7.16",
|
|
40
|
+
"@fonoster/types": "^0.7.16",
|
|
41
|
+
"@fonoster/voice": "^0.7.16",
|
|
42
42
|
"@langchain/community": "^0.2.31",
|
|
43
43
|
"@langchain/core": "^0.2.32",
|
|
44
44
|
"@langchain/groq": "^0.0.17",
|
|
45
|
+
"@langchain/ollama": "^0.0.4",
|
|
45
46
|
"@langchain/openai": "^0.2.10",
|
|
46
47
|
"cheerio": "^1.0.0",
|
|
47
48
|
"dotenv": "^16.4.5",
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"typescript": "^5.5.4"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "4408dbb6ca8aafe086ac86ebd6b5daa255e8c99f"
|
|
59
60
|
}
|