@botonic/plugin-ai-agents 0.56.0-alpha.0 → 0.57.0-rslib-esm.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/lib/esm/agents/base-agent.d.ts +4 -4
- package/lib/esm/agents/base-agent.js +47 -20
- package/lib/esm/agents/base-agent.js.map +1 -1
- package/lib/esm/agents/index.d.ts +2 -2
- package/lib/esm/agents/index.js +8 -7
- package/lib/esm/agents/index.js.map +1 -1
- package/lib/esm/agents/router-agent.d.ts +5 -5
- package/lib/esm/agents/router-agent.js +32 -15
- package/lib/esm/agents/router-agent.js.map +1 -1
- package/lib/esm/agents/specialist-agent.d.ts +5 -5
- package/lib/esm/agents/specialist-agent.js +65 -45
- package/lib/esm/agents/specialist-agent.js.map +1 -1
- package/lib/esm/bot-config-tools.d.ts +1 -1
- package/lib/esm/bot-config-tools.js +15 -13
- package/lib/esm/bot-config-tools.js.map +1 -1
- package/lib/esm/constants.js +18 -17
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/debug-logger.d.ts +1 -1
- package/lib/esm/debug-logger.js +14 -9
- package/lib/esm/debug-logger.js.map +1 -1
- package/lib/esm/guardrails/index.d.ts +1 -1
- package/lib/esm/guardrails/index.js +5 -4
- package/lib/esm/guardrails/index.js.map +1 -1
- package/lib/esm/guardrails/input.d.ts +2 -2
- package/lib/esm/guardrails/input.js +65 -42
- package/lib/esm/guardrails/input.js.map +1 -1
- package/lib/esm/index.d.ts +3 -3
- package/lib/esm/index.js +114 -74
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/llm-config.d.ts +1 -1
- package/lib/esm/llm-config.js +81 -52
- package/lib/esm/llm-config.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/runners/base-runner.d.ts +3 -3
- package/lib/esm/runners/base-runner.js +81 -69
- package/lib/esm/runners/base-runner.js.map +1 -1
- package/lib/esm/runners/index.d.ts +2 -2
- package/lib/esm/runners/index.js +8 -7
- package/lib/esm/runners/index.js.map +1 -1
- package/lib/esm/runners/router-runner.d.ts +2 -2
- package/lib/esm/runners/router-runner.js +19 -14
- package/lib/esm/runners/router-runner.js.map +1 -1
- package/lib/esm/runners/specialist-runner.d.ts +1 -1
- package/lib/esm/runners/specialist-runner.js +8 -6
- package/lib/esm/runners/specialist-runner.js.map +1 -1
- package/lib/esm/services/hubtype-api-client.d.ts +2 -2
- package/lib/esm/services/hubtype-api-client.js +110 -95
- package/lib/esm/services/hubtype-api-client.js.map +1 -1
- package/lib/esm/services/types.d.ts +1 -1
- package/lib/esm/services/types.js +9 -9
- package/lib/esm/services/types.js.map +1 -1
- package/lib/esm/structured-output/bot-executor.js +20 -17
- package/lib/esm/structured-output/bot-executor.js.map +1 -1
- package/lib/esm/structured-output/carousel.js +25 -22
- package/lib/esm/structured-output/carousel.js.map +1 -1
- package/lib/esm/structured-output/exit.js +13 -10
- package/lib/esm/structured-output/exit.js.map +1 -1
- package/lib/esm/structured-output/index.d.ts +0 -10
- package/lib/esm/structured-output/index.js +39 -29
- package/lib/esm/structured-output/index.js.map +1 -1
- package/lib/esm/structured-output/text-with-buttons.js +24 -23
- package/lib/esm/structured-output/text-with-buttons.js.map +1 -1
- package/lib/esm/structured-output/text.js +16 -13
- package/lib/esm/structured-output/text.js.map +1 -1
- package/lib/esm/tools/index.d.ts +2 -2
- package/lib/esm/tools/index.js +7 -7
- package/lib/esm/tools/index.js.map +1 -1
- package/lib/esm/tools/retrieve-knowledge.d.ts +2 -2
- package/lib/esm/tools/retrieve-knowledge.js +38 -32
- package/lib/esm/tools/retrieve-knowledge.js.map +1 -1
- package/lib/esm/types.d.ts +3 -3
- package/lib/esm/types.js +4 -2
- package/lib/esm/types.js.map +1 -1
- package/package.json +8 -7
- package/src/structured-output/index.ts +0 -2
- package/src/types.ts +4 -4
- package/lib/cjs/agents/base-agent.d.ts +0 -28
- package/lib/cjs/agents/base-agent.js +0 -39
- package/lib/cjs/agents/base-agent.js.map +0 -1
- package/lib/cjs/agents/index.d.ts +0 -2
- package/lib/cjs/agents/index.js +0 -8
- package/lib/cjs/agents/index.js.map +0 -1
- package/lib/cjs/agents/router-agent.d.ts +0 -25
- package/lib/cjs/agents/router-agent.js +0 -33
- package/lib/cjs/agents/router-agent.js.map +0 -1
- package/lib/cjs/agents/specialist-agent.d.ts +0 -39
- package/lib/cjs/agents/specialist-agent.js +0 -108
- package/lib/cjs/agents/specialist-agent.js.map +0 -1
- package/lib/cjs/bot-config-tools.d.ts +0 -7
- package/lib/cjs/bot-config-tools.js +0 -18
- package/lib/cjs/bot-config-tools.js.map +0 -1
- package/lib/cjs/constants.d.ts +0 -21
- package/lib/cjs/constants.js +0 -25
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/debug-logger.d.ts +0 -33
- package/lib/cjs/debug-logger.js +0 -116
- package/lib/cjs/debug-logger.js.map +0 -1
- package/lib/cjs/guardrails/index.d.ts +0 -1
- package/lib/cjs/guardrails/index.js +0 -5
- package/lib/cjs/guardrails/index.js.map +0 -1
- package/lib/cjs/guardrails/input.d.ts +0 -10
- package/lib/cjs/guardrails/input.js +0 -96
- package/lib/cjs/guardrails/input.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -22
- package/lib/cjs/index.js +0 -219
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/llm-config.d.ts +0 -30
- package/lib/cjs/llm-config.js +0 -121
- package/lib/cjs/llm-config.js.map +0 -1
- package/lib/cjs/runners/base-runner.d.ts +0 -31
- package/lib/cjs/runners/base-runner.js +0 -189
- package/lib/cjs/runners/base-runner.js.map +0 -1
- package/lib/cjs/runners/index.d.ts +0 -2
- package/lib/cjs/runners/index.js +0 -8
- package/lib/cjs/runners/index.js.map +0 -1
- package/lib/cjs/runners/router-runner.d.ts +0 -8
- package/lib/cjs/runners/router-runner.js +0 -44
- package/lib/cjs/runners/router-runner.js.map +0 -1
- package/lib/cjs/runners/specialist-runner.d.ts +0 -4
- package/lib/cjs/runners/specialist-runner.js +0 -8
- package/lib/cjs/runners/specialist-runner.js.map +0 -1
- package/lib/cjs/services/hubtype-api-client.d.ts +0 -13
- package/lib/cjs/services/hubtype-api-client.js +0 -176
- package/lib/cjs/services/hubtype-api-client.js.map +0 -1
- package/lib/cjs/services/types.d.ts +0 -72
- package/lib/cjs/services/types.js +0 -13
- package/lib/cjs/services/types.js.map +0 -1
- package/lib/cjs/structured-output/bot-executor.d.ts +0 -13
- package/lib/cjs/structured-output/bot-executor.js +0 -18
- package/lib/cjs/structured-output/bot-executor.js.map +0 -1
- package/lib/cjs/structured-output/carousel.d.ts +0 -18
- package/lib/cjs/structured-output/carousel.js +0 -23
- package/lib/cjs/structured-output/carousel.js.map +0 -1
- package/lib/cjs/structured-output/exit.d.ts +0 -6
- package/lib/cjs/structured-output/exit.js +0 -11
- package/lib/cjs/structured-output/exit.js.map +0 -1
- package/lib/cjs/structured-output/index.d.ts +0 -108
- package/lib/cjs/structured-output/index.js +0 -45
- package/lib/cjs/structured-output/index.js.map +0 -1
- package/lib/cjs/structured-output/request-contact-info.d.ts +0 -9
- package/lib/cjs/structured-output/request-contact-info.js +0 -14
- package/lib/cjs/structured-output/request-contact-info.js.map +0 -1
- package/lib/cjs/structured-output/text-with-buttons.d.ts +0 -17
- package/lib/cjs/structured-output/text-with-buttons.js +0 -24
- package/lib/cjs/structured-output/text-with-buttons.js.map +0 -1
- package/lib/cjs/structured-output/text.d.ts +0 -9
- package/lib/cjs/structured-output/text.js +0 -14
- package/lib/cjs/structured-output/text.js.map +0 -1
- package/lib/cjs/tools/index.d.ts +0 -3
- package/lib/cjs/tools/index.js +0 -8
- package/lib/cjs/tools/index.js.map +0 -1
- package/lib/cjs/tools/retrieve-knowledge.d.ts +0 -6
- package/lib/cjs/tools/retrieve-knowledge.js +0 -34
- package/lib/cjs/tools/retrieve-knowledge.js.map +0 -1
- package/lib/cjs/types.d.ts +0 -53
- package/lib/cjs/types.js +0 -3
- package/lib/cjs/types.js.map +0 -1
- package/lib/esm/structured-output/request-contact-info.d.ts +0 -9
- package/lib/esm/structured-output/request-contact-info.js +0 -14
- package/lib/esm/structured-output/request-contact-info.js.map +0 -1
- package/src/structured-output/request-contact-info.ts +0 -18
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouterRunner = void 0;
|
|
4
|
-
const agents_1 = require("@openai/agents");
|
|
5
|
-
const base_runner_1 = require("./base-runner");
|
|
6
|
-
class RouterRunner extends base_runner_1.BaseRunner {
|
|
7
|
-
buildRunResult(result, context, memoryLength) {
|
|
8
|
-
const base = super.buildRunResult(result, context, memoryLength);
|
|
9
|
-
const availableSpecialists = this.getAvailableSpecialists();
|
|
10
|
-
const startingAgentName = this.agent.name ?? '';
|
|
11
|
-
const lastAgentName = result.lastAgent?.name ?? '';
|
|
12
|
-
return {
|
|
13
|
-
...base,
|
|
14
|
-
startingAgentName,
|
|
15
|
-
lastAgentName,
|
|
16
|
-
availableSpecialists,
|
|
17
|
-
isTransferredToSpecialist: startingAgentName !== lastAgentName,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
handleInputGuardrailTripwireTriggered(error, startTime) {
|
|
21
|
-
const runResult = super.handleInputGuardrailTripwireTriggered(error, startTime);
|
|
22
|
-
if (runResult) {
|
|
23
|
-
// Override attributes to match router agent
|
|
24
|
-
runResult.startingAgentName = this.agent.name;
|
|
25
|
-
runResult.lastAgentName = this.agent.name;
|
|
26
|
-
runResult.availableSpecialists = this.getAvailableSpecialists();
|
|
27
|
-
runResult.isTransferredToSpecialist = false;
|
|
28
|
-
return runResult;
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
getAvailableSpecialists() {
|
|
33
|
-
return (this.agent.handoffs ?? []).map((entry) => {
|
|
34
|
-
const isHandoff = entry instanceof agents_1.Handoff;
|
|
35
|
-
const agent = isHandoff ? entry.agent : entry;
|
|
36
|
-
const description = isHandoff
|
|
37
|
-
? entry.toolDescription
|
|
38
|
-
: agent.handoffDescription;
|
|
39
|
-
return { name: agent.name, description };
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.RouterRunner = RouterRunner;
|
|
44
|
-
//# sourceMappingURL=router-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router-runner.js","sourceRoot":"","sources":["../../../src/runners/router-runner.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAIxC,+CAA6D;AAE7D,MAAa,YAGX,SAAQ,wBAAgC;IACrB,cAAc,CAC/B,MAAoB,EACpB,OAAsC,EACtC,YAAoB;QAEpB,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;QAEhE,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;QAC3D,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;QAC/C,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAA;QAElD,OAAO;YACL,GAAG,IAAI;YACP,iBAAiB;YACjB,aAAa;YACb,oBAAoB;YACpB,yBAAyB,EAAE,iBAAiB,KAAK,aAAa;SAC/D,CAAA;IACH,CAAC;IAEkB,qCAAqC,CACtD,KAAc,EACd,SAAiB;QAEjB,MAAM,SAAS,GAAG,KAAK,CAAC,qCAAqC,CAC3D,KAAK,EACL,SAAS,CACV,CAAA;QACD,IAAI,SAAS,EAAE,CAAC;YACd,4CAA4C;YAC5C,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;YAC7C,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;YACzC,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;YAC/D,SAAS,CAAC,yBAAyB,GAAG,KAAK,CAAA;YAE3C,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAEO,uBAAuB;QAC7B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CACpC,CAAC,KAA0C,EAAE,EAAE;YAC7C,MAAM,SAAS,GAAG,KAAK,YAAY,gBAAO,CAAA;YAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAE,KAAyB,CAAA;YAClE,MAAM,WAAW,GAAG,SAAS;gBAC3B,CAAC,CAAC,KAAK,CAAC,eAAe;gBACvB,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAA;YAC5B,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,CAAA;QAC1C,CAAC,CACF,CAAA;IACH,CAAC;CACF;AAxDD,oCAwDC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SpecialistRunner = void 0;
|
|
4
|
-
const base_runner_1 = require("./base-runner");
|
|
5
|
-
class SpecialistRunner extends base_runner_1.BaseRunner {
|
|
6
|
-
}
|
|
7
|
-
exports.SpecialistRunner = SpecialistRunner;
|
|
8
|
-
//# sourceMappingURL=specialist-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"specialist-runner.js","sourceRoot":"","sources":["../../../src/runners/specialist-runner.ts"],"names":[],"mappings":";;;AACA,+CAA0C;AAE1C,MAAa,gBAGX,SAAQ,wBAAgC;CAAG;AAH7C,4CAG6C"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BotContext, HubtypeAssistantMessage } from '@botonic/core';
|
|
2
|
-
import type { AgenticInputMessage, Chunk, MemoryOptions } from '../types';
|
|
3
|
-
import type { GetMessagesV2Result, TrackLlmRunsData } from './types';
|
|
4
|
-
export declare class HubtypeApiClient {
|
|
5
|
-
private readonly authToken;
|
|
6
|
-
constructor(authToken: string);
|
|
7
|
-
retrieveSimilarChunks(query: string, sourceIds: string[]): Promise<Chunk[]>;
|
|
8
|
-
getLocalMessages(maxMemoryLength: number, previousHubtypeMessages: HubtypeAssistantMessage[], localStorageKey: string): Promise<AgenticInputMessage[]>;
|
|
9
|
-
getMessagesV2(botContext: BotContext, options: MemoryOptions, previousHubtypeMessages: HubtypeAssistantMessage[]): Promise<GetMessagesV2Result>;
|
|
10
|
-
private formatMessageV2;
|
|
11
|
-
trackLlmRuns(botId: string, data: TrackLlmRunsData): Promise<void>;
|
|
12
|
-
private formatMessage;
|
|
13
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HubtypeApiClient = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
class HubtypeApiClient {
|
|
8
|
-
constructor(authToken) {
|
|
9
|
-
this.authToken = authToken;
|
|
10
|
-
}
|
|
11
|
-
async retrieveSimilarChunks(query, sourceIds) {
|
|
12
|
-
const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/knowledge_base/similar_chunks/`;
|
|
13
|
-
const headers = {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
Authorization: `Bearer ${this.authToken}`,
|
|
16
|
-
};
|
|
17
|
-
const params = {
|
|
18
|
-
query,
|
|
19
|
-
source_ids: sourceIds,
|
|
20
|
-
num_chunks: 5,
|
|
21
|
-
};
|
|
22
|
-
const response = await axios_1.default.post(url, params, { headers });
|
|
23
|
-
const chunks = response.data.chunks.map((chunk) => ({
|
|
24
|
-
id: chunk.id,
|
|
25
|
-
text: chunk.text,
|
|
26
|
-
}));
|
|
27
|
-
return chunks;
|
|
28
|
-
}
|
|
29
|
-
async getLocalMessages(maxMemoryLength, previousHubtypeMessages, localStorageKey) {
|
|
30
|
-
const localBotonicState = typeof globalThis !== 'undefined' && globalThis.localStorage
|
|
31
|
-
? globalThis.localStorage.getItem(localStorageKey)
|
|
32
|
-
: null;
|
|
33
|
-
const botonicState = JSON.parse(localBotonicState || '{}');
|
|
34
|
-
const messages = botonicState.messages;
|
|
35
|
-
const filteredMessages = messages
|
|
36
|
-
.filter(message => message.data.text)
|
|
37
|
-
.map(message => ({
|
|
38
|
-
role: message.sentBy === 'user' ? 'user' : 'assistant',
|
|
39
|
-
content: message.data.text,
|
|
40
|
-
}))
|
|
41
|
-
.map(message => this.formatMessage(message));
|
|
42
|
-
const resultMessages = [...filteredMessages, ...previousHubtypeMessages];
|
|
43
|
-
return resultMessages.slice(-maxMemoryLength);
|
|
44
|
-
}
|
|
45
|
-
async getMessagesV2(botContext, options, previousHubtypeMessages) {
|
|
46
|
-
const url = `${constants_1.HUBTYPE_API_URL}/external/v2/ai/agent/message_history/`;
|
|
47
|
-
const headers = {
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
Authorization: `Bearer ${this.authToken}`,
|
|
50
|
-
};
|
|
51
|
-
const params = {
|
|
52
|
-
last_message_id: botContext.input.message_id,
|
|
53
|
-
max_messages: options.maxMessages,
|
|
54
|
-
include_tool_calls: options.includeToolCalls,
|
|
55
|
-
max_full_tool_results: options.maxFullToolResults,
|
|
56
|
-
debug_mode: options.debugMode,
|
|
57
|
-
};
|
|
58
|
-
try {
|
|
59
|
-
const response = await axios_1.default.get(url, {
|
|
60
|
-
headers,
|
|
61
|
-
params,
|
|
62
|
-
});
|
|
63
|
-
const { messages, conversation_id, truncated } = response.data;
|
|
64
|
-
const formattedMessages = [...messages, ...previousHubtypeMessages]
|
|
65
|
-
.map(message => this.formatMessageV2(message))
|
|
66
|
-
.filter((message) => message !== null);
|
|
67
|
-
return {
|
|
68
|
-
messages: formattedMessages,
|
|
69
|
-
conversationId: conversation_id,
|
|
70
|
-
truncated,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
console.error(error);
|
|
75
|
-
throw new Error('Failed to get messages from Hubtype V2 API');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
formatMessageV2(message) {
|
|
79
|
-
switch (message.role) {
|
|
80
|
-
case 'user':
|
|
81
|
-
return {
|
|
82
|
-
role: 'user',
|
|
83
|
-
content: message.content ?? '',
|
|
84
|
-
};
|
|
85
|
-
case 'assistant': {
|
|
86
|
-
const assistantMessage = message;
|
|
87
|
-
// If assistant message has tool_calls, include them for context
|
|
88
|
-
// Using double assertion as the OpenAI API supports this format,
|
|
89
|
-
// but the agents SDK types are more restrictive
|
|
90
|
-
if (assistantMessage.tool_calls &&
|
|
91
|
-
assistantMessage.tool_calls.length > 0) {
|
|
92
|
-
return {
|
|
93
|
-
role: 'assistant',
|
|
94
|
-
content: assistantMessage.content ?? '',
|
|
95
|
-
tool_calls: assistantMessage.tool_calls.map(tc => ({
|
|
96
|
-
id: tc.id,
|
|
97
|
-
type: tc.type,
|
|
98
|
-
function: {
|
|
99
|
-
name: tc.function.name,
|
|
100
|
-
arguments: tc.function.arguments,
|
|
101
|
-
},
|
|
102
|
-
})),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
// Regular assistant message without tool_calls
|
|
106
|
-
return {
|
|
107
|
-
role: 'assistant',
|
|
108
|
-
content: [
|
|
109
|
-
{
|
|
110
|
-
type: 'output_text',
|
|
111
|
-
text: assistantMessage.content ?? '',
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
status: 'completed',
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
case 'tool': {
|
|
118
|
-
// Tool messages provide context about previous tool executions
|
|
119
|
-
// Using double assertion as the OpenAI API supports this format,
|
|
120
|
-
// but the agents SDK types are more restrictive
|
|
121
|
-
const toolMessage = message;
|
|
122
|
-
return {
|
|
123
|
-
role: 'tool',
|
|
124
|
-
tool_call_id: toolMessage.tool_call_id,
|
|
125
|
-
content: toolMessage.content ?? '',
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
case 'system':
|
|
129
|
-
return {
|
|
130
|
-
role: 'system',
|
|
131
|
-
content: message.content ?? '',
|
|
132
|
-
};
|
|
133
|
-
default:
|
|
134
|
-
throw new Error(`Invalid message role: ${message.role}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
async trackLlmRuns(botId, data) {
|
|
138
|
-
// Not stop the bot execution if the tracking fails, just log the error
|
|
139
|
-
try {
|
|
140
|
-
const url = `${constants_1.HUBTYPE_API_URL}/external/v2/conversational_apps/${botId}/track_llm_runs/`;
|
|
141
|
-
const headers = {
|
|
142
|
-
'Content-Type': 'application/json',
|
|
143
|
-
Authorization: `Bearer ${this.authToken}`,
|
|
144
|
-
};
|
|
145
|
-
await axios_1.default.post(url, data, { headers });
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
console.error('Failed to track LLM runs:', error);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
formatMessage(message) {
|
|
152
|
-
if (message.role === 'user') {
|
|
153
|
-
return {
|
|
154
|
-
content: message.content,
|
|
155
|
-
role: 'user',
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
else if (message.role === 'assistant') {
|
|
159
|
-
return {
|
|
160
|
-
role: 'assistant',
|
|
161
|
-
content: [
|
|
162
|
-
{
|
|
163
|
-
type: 'output_text',
|
|
164
|
-
text: message.content,
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
status: 'completed',
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
throw new Error('Invalid message role');
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.HubtypeApiClient = HubtypeApiClient;
|
|
176
|
-
//# sourceMappingURL=hubtype-api-client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AK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,OAAuB;QAC3C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,MAAM;aACb,CAAA;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACxC,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE,OAAO,CAAC,OAAO;qBACtB;iBACF;gBACD,MAAM,EAAE,WAAW;aACpB,CAAA;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;CACF;AAhMD,4CAgMC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { HubtypeAssistantMessage, HubtypeUserMessage } from '@botonic/core';
|
|
2
|
-
import type { AgenticInputMessage } from '../types';
|
|
3
|
-
export declare enum TrackProductName {
|
|
4
|
-
AI_AGENT = "ai_agent"
|
|
5
|
-
}
|
|
6
|
-
export declare enum TrackFeature {
|
|
7
|
-
AI_AGENT_RUN = "ai_agent_run",
|
|
8
|
-
AI_AGENT_GUARDRAIL = "ai_agent_guardrail"
|
|
9
|
-
}
|
|
10
|
-
export interface LlmRunData {
|
|
11
|
-
inference_id: string;
|
|
12
|
-
is_test: boolean;
|
|
13
|
-
product_name: string;
|
|
14
|
-
deployment_name: string;
|
|
15
|
-
model_name: string;
|
|
16
|
-
feature: string;
|
|
17
|
-
api_version?: string;
|
|
18
|
-
num_prompt_tokens: number;
|
|
19
|
-
num_completion_tokens: number;
|
|
20
|
-
duration_in_milliseconds: number;
|
|
21
|
-
temperature: number;
|
|
22
|
-
error: string | null;
|
|
23
|
-
}
|
|
24
|
-
export interface TrackLlmRunsData {
|
|
25
|
-
llm_runs: LlmRunData[];
|
|
26
|
-
}
|
|
27
|
-
export type HubtypeMessage = HubtypeAssistantMessage | HubtypeUserMessage;
|
|
28
|
-
interface HubtypeToolCall {
|
|
29
|
-
id: string;
|
|
30
|
-
type: 'function';
|
|
31
|
-
function: {
|
|
32
|
-
name: string;
|
|
33
|
-
arguments: string;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
interface HubtypeUserMessageV2 {
|
|
37
|
-
role: 'user';
|
|
38
|
-
content: string | null;
|
|
39
|
-
}
|
|
40
|
-
export interface HubtypeAssistantMessageV2 {
|
|
41
|
-
role: 'assistant';
|
|
42
|
-
content: string | null;
|
|
43
|
-
tool_calls?: HubtypeToolCall[] | null;
|
|
44
|
-
}
|
|
45
|
-
export interface HubtypeToolMessageV2 {
|
|
46
|
-
role: 'tool';
|
|
47
|
-
content: string | null;
|
|
48
|
-
tool_call_id: string;
|
|
49
|
-
}
|
|
50
|
-
interface HubtypeSystemMessageV2 {
|
|
51
|
-
role: 'system';
|
|
52
|
-
content: string | null;
|
|
53
|
-
}
|
|
54
|
-
export type HubtypeMessageV2 = HubtypeUserMessageV2 | HubtypeAssistantMessageV2 | HubtypeToolMessageV2 | HubtypeSystemMessageV2;
|
|
55
|
-
export interface MessageHistoryResponseV2 {
|
|
56
|
-
messages: HubtypeMessageV2[];
|
|
57
|
-
conversation_id: string | null;
|
|
58
|
-
truncated: boolean;
|
|
59
|
-
}
|
|
60
|
-
export interface GetMessagesV2Result {
|
|
61
|
-
messages: AgenticInputMessage[];
|
|
62
|
-
conversationId: string | null;
|
|
63
|
-
truncated: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface MessageHistoryV2Params {
|
|
66
|
-
last_message_id: string;
|
|
67
|
-
max_messages?: number;
|
|
68
|
-
include_tool_calls?: boolean;
|
|
69
|
-
max_full_tool_results?: number;
|
|
70
|
-
debug_mode?: boolean;
|
|
71
|
-
}
|
|
72
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TrackFeature = exports.TrackProductName = void 0;
|
|
4
|
-
var TrackProductName;
|
|
5
|
-
(function (TrackProductName) {
|
|
6
|
-
TrackProductName["AI_AGENT"] = "ai_agent";
|
|
7
|
-
})(TrackProductName || (exports.TrackProductName = TrackProductName = {}));
|
|
8
|
-
var TrackFeature;
|
|
9
|
-
(function (TrackFeature) {
|
|
10
|
-
TrackFeature["AI_AGENT_RUN"] = "ai_agent_run";
|
|
11
|
-
TrackFeature["AI_AGENT_GUARDRAIL"] = "ai_agent_guardrail";
|
|
12
|
-
})(TrackFeature || (exports.TrackFeature = TrackFeature = {}));
|
|
13
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;AACvB,CAAC,EAFW,gBAAgB,gCAAhB,gBAAgB,QAE3B;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type BotExecutorMessage, OutputMessageType } from '@botonic/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export type { BotExecutorMessage };
|
|
4
|
-
export declare const BotExecutorSchema: z.ZodObject<{
|
|
5
|
-
type: z.ZodLiteral<OutputMessageType.BotExecutor>;
|
|
6
|
-
content: z.ZodObject<{
|
|
7
|
-
text: z.ZodString;
|
|
8
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
9
|
-
text: z.ZodString;
|
|
10
|
-
payload: z.ZodString;
|
|
11
|
-
}, z.core.$strip>>;
|
|
12
|
-
}, z.core.$strip>;
|
|
13
|
-
}, z.core.$strip>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BotExecutorSchema = void 0;
|
|
4
|
-
const core_1 = require("@botonic/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.BotExecutorSchema = zod_1.z
|
|
7
|
-
.object({
|
|
8
|
-
type: zod_1.z.literal(core_1.OutputMessageType.BotExecutor),
|
|
9
|
-
content: zod_1.z.object({
|
|
10
|
-
text: zod_1.z.string(),
|
|
11
|
-
buttons: zod_1.z.array(zod_1.z.object({
|
|
12
|
-
text: zod_1.z.string(),
|
|
13
|
-
payload: zod_1.z.string(),
|
|
14
|
-
})),
|
|
15
|
-
}),
|
|
16
|
-
})
|
|
17
|
-
.describe('A text message with buttons to allow the bot to execute a specific action. Use it only when asked explicitly in the prompt');
|
|
18
|
-
//# sourceMappingURL=bot-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bot-executor.js","sourceRoot":"","sources":["../../../src/structured-output/bot-executor.ts"],"names":[],"mappings":";;;AAAA,wCAA0E;AAC1E,6BAAuB;AAIV,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,WAAW,CAAC;IAC9C,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;SACpB,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CACP,4HAA4H,CAC7H,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type CarouselMessage, OutputMessageType } from '@botonic/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export type { CarouselMessage };
|
|
4
|
-
export declare const CarouselSchema: z.ZodObject<{
|
|
5
|
-
type: z.ZodLiteral<OutputMessageType.Carousel>;
|
|
6
|
-
content: z.ZodObject<{
|
|
7
|
-
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
-
elements: z.ZodArray<z.ZodObject<{
|
|
9
|
-
title: z.ZodString;
|
|
10
|
-
subtitle: z.ZodString;
|
|
11
|
-
image: z.ZodString;
|
|
12
|
-
button: z.ZodObject<{
|
|
13
|
-
text: z.ZodString;
|
|
14
|
-
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
}, z.core.$strip>>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
}, z.core.$strip>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CarouselSchema = void 0;
|
|
4
|
-
const core_1 = require("@botonic/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.CarouselSchema = zod_1.z
|
|
7
|
-
.object({
|
|
8
|
-
type: zod_1.z.literal(core_1.OutputMessageType.Carousel),
|
|
9
|
-
content: zod_1.z.object({
|
|
10
|
-
text: zod_1.z.string().nullable().optional(),
|
|
11
|
-
elements: zod_1.z.array(zod_1.z.object({
|
|
12
|
-
title: zod_1.z.string(),
|
|
13
|
-
subtitle: zod_1.z.string(),
|
|
14
|
-
image: zod_1.z.string(),
|
|
15
|
-
button: zod_1.z.object({
|
|
16
|
-
text: zod_1.z.string(),
|
|
17
|
-
url: zod_1.z.string().nullable().optional(),
|
|
18
|
-
}),
|
|
19
|
-
})),
|
|
20
|
-
}),
|
|
21
|
-
})
|
|
22
|
-
.describe('A carousel message containing a list of elements');
|
|
23
|
-
//# sourceMappingURL=carousel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":";;;AAAA,wCAAuE;AACvE,6BAAuB;AAIV,QAAA,cAAc,GAAG,OAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,QAAQ,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACtC,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,MAAM,CAAC;YACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;YACpB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACtC,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExitSchema = void 0;
|
|
4
|
-
const core_1 = require("@botonic/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.ExitSchema = zod_1.z
|
|
7
|
-
.object({
|
|
8
|
-
type: zod_1.z.literal(core_1.OutputMessageType.Exit),
|
|
9
|
-
})
|
|
10
|
-
.describe('An exit message. This message should only be used to exit the agent due to out of context or the user asking to exit the conversation');
|
|
11
|
-
//# sourceMappingURL=exit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../../../src/structured-output/exit.ts"],"names":[],"mappings":";;;AAAA,wCAAmE;AACnE,6BAAuB;AAIV,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,IAAI,CAAC;CACxC,CAAC;KACD,QAAQ,CACP,uIAAuI,CACxI,CAAA"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { OutputMessage } from '@botonic/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export interface Output {
|
|
4
|
-
messages: OutputMessage[];
|
|
5
|
-
}
|
|
6
|
-
export declare const OutputSchema: z.ZodObject<{
|
|
7
|
-
messages: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
8
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Text>;
|
|
9
|
-
content: z.ZodObject<{
|
|
10
|
-
text: z.ZodString;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
13
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.TextWithButtons>;
|
|
14
|
-
content: z.ZodObject<{
|
|
15
|
-
text: z.ZodString;
|
|
16
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
17
|
-
text: z.ZodString;
|
|
18
|
-
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
-
target: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
|
|
20
|
-
_blank: "_blank";
|
|
21
|
-
_self: "_self";
|
|
22
|
-
}>>>>;
|
|
23
|
-
}, z.core.$strip>>;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
26
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Carousel>;
|
|
27
|
-
content: z.ZodObject<{
|
|
28
|
-
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
-
elements: z.ZodArray<z.ZodObject<{
|
|
30
|
-
title: z.ZodString;
|
|
31
|
-
subtitle: z.ZodString;
|
|
32
|
-
image: z.ZodString;
|
|
33
|
-
button: z.ZodObject<{
|
|
34
|
-
text: z.ZodString;
|
|
35
|
-
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
}, z.core.$strip>>;
|
|
38
|
-
}, z.core.$strip>;
|
|
39
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Exit>;
|
|
41
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.BotExecutor>;
|
|
43
|
-
content: z.ZodObject<{
|
|
44
|
-
text: z.ZodString;
|
|
45
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
46
|
-
text: z.ZodString;
|
|
47
|
-
payload: z.ZodString;
|
|
48
|
-
}, z.core.$strip>>;
|
|
49
|
-
}, z.core.$strip>;
|
|
50
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
51
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.RequestContactInfo>;
|
|
52
|
-
content: z.ZodObject<{
|
|
53
|
-
text: z.ZodString;
|
|
54
|
-
}, z.core.$strip>;
|
|
55
|
-
}, z.core.$strip>]>>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
export declare function getOutputSchema(externalOutputMessagesSchemas: z.ZodObject<any>[]): z.ZodObject<{
|
|
58
|
-
messages: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
59
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Text>;
|
|
60
|
-
content: z.ZodObject<{
|
|
61
|
-
text: z.ZodString;
|
|
62
|
-
}, z.core.$strip>;
|
|
63
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.TextWithButtons>;
|
|
65
|
-
content: z.ZodObject<{
|
|
66
|
-
text: z.ZodString;
|
|
67
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
68
|
-
text: z.ZodString;
|
|
69
|
-
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
-
target: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
|
|
71
|
-
_blank: "_blank";
|
|
72
|
-
_self: "_self";
|
|
73
|
-
}>>>>;
|
|
74
|
-
}, z.core.$strip>>;
|
|
75
|
-
}, z.core.$strip>;
|
|
76
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Carousel>;
|
|
78
|
-
content: z.ZodObject<{
|
|
79
|
-
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
-
elements: z.ZodArray<z.ZodObject<{
|
|
81
|
-
title: z.ZodString;
|
|
82
|
-
subtitle: z.ZodString;
|
|
83
|
-
image: z.ZodString;
|
|
84
|
-
button: z.ZodObject<{
|
|
85
|
-
text: z.ZodString;
|
|
86
|
-
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
87
|
-
}, z.core.$strip>;
|
|
88
|
-
}, z.core.$strip>>;
|
|
89
|
-
}, z.core.$strip>;
|
|
90
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
91
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Exit>;
|
|
92
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.BotExecutor>;
|
|
94
|
-
content: z.ZodObject<{
|
|
95
|
-
text: z.ZodString;
|
|
96
|
-
buttons: z.ZodArray<z.ZodObject<{
|
|
97
|
-
text: z.ZodString;
|
|
98
|
-
payload: z.ZodString;
|
|
99
|
-
}, z.core.$strip>>;
|
|
100
|
-
}, z.core.$strip>;
|
|
101
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
102
|
-
type: z.ZodLiteral<import("@botonic/core").OutputMessageType.RequestContactInfo>;
|
|
103
|
-
content: z.ZodObject<{
|
|
104
|
-
text: z.ZodString;
|
|
105
|
-
}, z.core.$strip>;
|
|
106
|
-
}, z.core.$strip>, ...z.ZodObject<any, z.core.$strip>[]]>>;
|
|
107
|
-
}, z.core.$strip>;
|
|
108
|
-
export declare function getOutputInstructions(): string;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutputSchema = void 0;
|
|
4
|
-
exports.getOutputSchema = getOutputSchema;
|
|
5
|
-
exports.getOutputInstructions = getOutputInstructions;
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const bot_executor_1 = require("./bot-executor");
|
|
8
|
-
const carousel_1 = require("./carousel");
|
|
9
|
-
const exit_1 = require("./exit");
|
|
10
|
-
const request_contact_info_1 = require("./request-contact-info");
|
|
11
|
-
const text_1 = require("./text");
|
|
12
|
-
const text_with_buttons_1 = require("./text-with-buttons");
|
|
13
|
-
const baseMessageSchemas = [
|
|
14
|
-
text_1.TextSchema,
|
|
15
|
-
text_with_buttons_1.TextWithButtonsSchema,
|
|
16
|
-
carousel_1.CarouselSchema,
|
|
17
|
-
exit_1.ExitSchema,
|
|
18
|
-
bot_executor_1.BotExecutorSchema,
|
|
19
|
-
request_contact_info_1.RequestContactInfoSchema,
|
|
20
|
-
];
|
|
21
|
-
exports.OutputSchema = zod_1.z
|
|
22
|
-
.object({
|
|
23
|
-
messages: zod_1.z.array(zod_1.z.union(baseMessageSchemas)),
|
|
24
|
-
})
|
|
25
|
-
.describe('The messages to be sent to the user');
|
|
26
|
-
function getOutputSchema(externalOutputMessagesSchemas) {
|
|
27
|
-
return zod_1.z.object({
|
|
28
|
-
messages: zod_1.z.array(zod_1.z.union([...baseMessageSchemas, ...externalOutputMessagesSchemas])),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function getOutputInstructions() {
|
|
32
|
-
const example = {
|
|
33
|
-
messages: [
|
|
34
|
-
{
|
|
35
|
-
type: 'text',
|
|
36
|
-
content: {
|
|
37
|
-
text: 'Hello, how can I help you today?',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
const output = `Return a JSON that follows the output schema provided. Never return multiple output schemas concatenated by a line break.\n<example>\n${JSON.stringify(example)}\n</example>`;
|
|
43
|
-
return `<output>\n${output}\n</output>`;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structured-output/index.ts"],"names":[],"mappings":";;;AA2BA,0CAQC;AAED,sDAaC;AAjDD,6BAAuB;AACvB,iDAAkD;AAClD,yCAA2C;AAC3C,iCAAmC;AACnC,iEAAiE;AACjE,iCAAmC;AACnC,2DAA2D;AAM3D,MAAM,kBAAkB,GAAG;IACzB,iBAAU;IACV,yCAAqB;IACrB,yBAAc;IACd,iBAAU;IACV,gCAAiB;IACjB,+CAAwB;CAChB,CAAA;AACG,QAAA,YAAY,GAAG,OAAC;KAC1B,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;KACD,QAAQ,CAAC,qCAAqC,CAAC,CAAA;AAElD,SAAgB,eAAe,CAC7B,6BAAiD;IAEjD,OAAO,OAAC,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,KAAK,CAAC,CAAC,GAAG,kBAAkB,EAAE,GAAG,6BAA6B,CAAC,CAAC,CACnE;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,qBAAqB;IACnC,MAAM,OAAO,GAAG;QACd,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,kCAAkC;iBACzC;aACF;SACF;KACF,CAAA;IACD,MAAM,MAAM,GAAG,yIAAyI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAAA;IAC7L,OAAO,aAAa,MAAM,aAAa,CAAA;AACzC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType, type RequestContactInfoMessage } from '@botonic/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export type { RequestContactInfoMessage };
|
|
4
|
-
export declare const RequestContactInfoSchema: z.ZodObject<{
|
|
5
|
-
type: z.ZodLiteral<OutputMessageType.RequestContactInfo>;
|
|
6
|
-
content: z.ZodObject<{
|
|
7
|
-
text: z.ZodString;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
}, z.core.$strip>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestContactInfoSchema = void 0;
|
|
4
|
-
const core_1 = require("@botonic/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
exports.RequestContactInfoSchema = zod_1.z
|
|
7
|
-
.object({
|
|
8
|
-
type: zod_1.z.literal(core_1.OutputMessageType.RequestContactInfo),
|
|
9
|
-
content: zod_1.z.object({
|
|
10
|
-
text: zod_1.z.string().describe('The text of the message'),
|
|
11
|
-
}),
|
|
12
|
-
})
|
|
13
|
-
.describe('A message to request phone number from the user. Use it only when asked explicitly in the prompt.');
|
|
14
|
-
//# sourceMappingURL=request-contact-info.js.map
|