@onereach/step-voice 7.0.22-voiceagent.0 → 7.0.22-voiceagent.2
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.
|
@@ -11,15 +11,23 @@ class VoiceAgentFunctionResult extends voice_1.default {
|
|
|
11
11
|
throw new Error('Voice Agent Function Result: missing call context (must be placed on a Voice Agent function exit)');
|
|
12
12
|
}
|
|
13
13
|
this.log.error("Voice Agent Function Result Params", ctx);
|
|
14
|
+
const params = {
|
|
15
|
+
functionName: functionName,
|
|
16
|
+
functionId: functionId,
|
|
17
|
+
result: result,
|
|
18
|
+
options: {
|
|
19
|
+
stop: stopAgent
|
|
20
|
+
}
|
|
21
|
+
};
|
|
14
22
|
const event = {
|
|
15
23
|
target: this.helpers.providersAccountId,
|
|
16
|
-
name: 'out/voice/
|
|
24
|
+
name: 'out/voice/voicer',
|
|
17
25
|
params: {
|
|
18
26
|
id: callId,
|
|
19
|
-
commands: [{ name: 'agentFunctionResult', params
|
|
27
|
+
commands: [{ name: 'agentFunctionResult', params }]
|
|
20
28
|
}
|
|
21
29
|
};
|
|
22
|
-
this.log.
|
|
30
|
+
this.log.info("Voice Agent Function Result", event);
|
|
23
31
|
await this.thread.eventManager.emit(event, {
|
|
24
32
|
target: callCallback,
|
|
25
33
|
invocationType: 'async',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
5
|
-
class
|
|
5
|
+
class VoiceAgentStop extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const call = await this.fetchData();
|
|
8
8
|
this.triggers.otherwise(async () => {
|
|
@@ -11,4 +11,4 @@ class StopVoiceAgent extends voice_1.default {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
exports.default =
|
|
14
|
+
exports.default = VoiceAgentStop;
|
package/dst/Voice Agent.js
CHANGED
|
@@ -5,26 +5,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
|
5
5
|
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
6
6
|
class VoiceAgent extends voice_1.default {
|
|
7
7
|
async runStep() {
|
|
8
|
-
const { url = "", // optional, default value configured on a voicer side
|
|
9
|
-
handlers = [], system_instruction = '', developer_messages = [] } = this.data;
|
|
10
8
|
const call = await this.fetchData();
|
|
11
|
-
const tools = handlers.map(h => {
|
|
12
|
-
let parameters = h.parameters;
|
|
13
|
-
if (typeof parameters === 'string') {
|
|
14
|
-
try {
|
|
15
|
-
parameters = JSON.parse(parameters);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
parameters = {};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return { type: 'function', name: h.name, description: h.description, parameters: parameters || {} };
|
|
22
|
-
});
|
|
23
|
-
const config = {
|
|
24
|
-
system_instruction,
|
|
25
|
-
developer_messages,
|
|
26
|
-
tools
|
|
27
|
-
};
|
|
28
9
|
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
29
10
|
switch (event.params.type) {
|
|
30
11
|
case 'function_call': {
|
|
@@ -53,7 +34,29 @@ class VoiceAgent extends voice_1.default {
|
|
|
53
34
|
}
|
|
54
35
|
});
|
|
55
36
|
this.triggers.otherwise(async () => {
|
|
56
|
-
|
|
37
|
+
const { url = "", // optional, default value configured on a voicer side
|
|
38
|
+
handlers = [], system_instruction = '', developer_messages = [] } = this.data;
|
|
39
|
+
const tools = handlers.map(h => {
|
|
40
|
+
let parameters = h.parameters;
|
|
41
|
+
if (typeof parameters === 'string') {
|
|
42
|
+
try {
|
|
43
|
+
parameters = JSON.parse(parameters);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
parameters = {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { type: 'function', name: h.name, description: h.description, parameters: parameters || {} };
|
|
50
|
+
});
|
|
51
|
+
const params = {
|
|
52
|
+
url,
|
|
53
|
+
config: {
|
|
54
|
+
system_instruction,
|
|
55
|
+
developer_messages,
|
|
56
|
+
tools,
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
await this.sendCommands(call, [{ name: 'startAgent', params }]);
|
|
57
60
|
return this.exitFlow();
|
|
58
61
|
});
|
|
59
62
|
}
|