@wabot-dev/framework 0.1.0-beta.31 → 0.1.0-beta.33
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/src/addon/chat-bot/claude/ClaudeChatAdapter.js +14 -2
- package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +14 -2
- package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +14 -4
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiverByDevConnection.js +1 -1
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiverByWebHook.js +1 -1
- package/dist/src/core/env/Env.js +1 -1
- package/dist/src/feature/chat-bot/ChatAdapter.js +1 -1
- package/dist/src/feature/chat-bot/ChatBot.js +1 -1
- package/dist/src/feature/express/ExpressProvider.js +1 -1
- package/dist/src/feature/http/HttpServerProvider.js +1 -1
- package/dist/src/feature/socket/SocketServerProvider.js +1 -1
- package/dist/src/index.d.ts +15 -6
- package/package.json +1 -1
|
@@ -94,12 +94,13 @@ class ClaudeChatAdapter {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
mapResponse(response) {
|
|
97
|
+
let chatItem;
|
|
97
98
|
const content = response.content[0];
|
|
98
99
|
if (content.type === 'text') {
|
|
99
|
-
|
|
100
|
+
chatItem = { type: 'botMessage', botMessage: { text: content.text } };
|
|
100
101
|
}
|
|
101
102
|
else if (content.type === 'tool_use') {
|
|
102
|
-
|
|
103
|
+
chatItem = {
|
|
103
104
|
type: 'functionCall',
|
|
104
105
|
functionCall: {
|
|
105
106
|
id: content.id,
|
|
@@ -111,6 +112,17 @@ class ClaudeChatAdapter {
|
|
|
111
112
|
else {
|
|
112
113
|
throw new Error('Not supported Claude Response');
|
|
113
114
|
}
|
|
115
|
+
let usage;
|
|
116
|
+
if (response.usage) {
|
|
117
|
+
usage = {
|
|
118
|
+
inputTokens: response.usage.input_tokens,
|
|
119
|
+
outputTokens: response.usage.output_tokens,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error('Unable to found usage info');
|
|
124
|
+
}
|
|
125
|
+
return { chatItem, usage };
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
|
|
@@ -102,12 +102,13 @@ class DeepSeekChatAdapter {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
mapResponse(response) {
|
|
105
|
+
let chatItem;
|
|
105
106
|
const { tool_calls: responseFunctionCall, content: responseText } = response.choices?.[0]?.message ?? {};
|
|
106
107
|
if (responseText) {
|
|
107
|
-
|
|
108
|
+
chatItem = { type: 'botMessage', botMessage: { text: responseText } };
|
|
108
109
|
}
|
|
109
110
|
else if (responseFunctionCall && responseFunctionCall[0]?.type === 'function') {
|
|
110
|
-
|
|
111
|
+
chatItem = {
|
|
111
112
|
type: 'functionCall',
|
|
112
113
|
functionCall: {
|
|
113
114
|
id: responseFunctionCall[0].id,
|
|
@@ -119,6 +120,17 @@ class DeepSeekChatAdapter {
|
|
|
119
120
|
else {
|
|
120
121
|
throw new Error('Not supported DeepSeek Response');
|
|
121
122
|
}
|
|
123
|
+
let usage;
|
|
124
|
+
if (response.usage) {
|
|
125
|
+
usage = {
|
|
126
|
+
inputTokens: response.usage.prompt_tokens,
|
|
127
|
+
outputTokens: response.usage.completion_tokens,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error('Unable to found usage info');
|
|
132
|
+
}
|
|
133
|
+
return { chatItem, usage };
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -77,12 +77,12 @@ class OpenaiChatAdapter {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
mapResponse(response) {
|
|
80
|
-
let
|
|
80
|
+
let chatItem;
|
|
81
81
|
if (response.output_text) {
|
|
82
|
-
|
|
82
|
+
chatItem = { type: 'botMessage', botMessage: { text: response.output_text } };
|
|
83
83
|
}
|
|
84
84
|
else if (response.output && response.output[0]?.type == 'function_call') {
|
|
85
|
-
|
|
85
|
+
chatItem = {
|
|
86
86
|
type: 'functionCall',
|
|
87
87
|
functionCall: {
|
|
88
88
|
id: response.output[0].call_id,
|
|
@@ -94,7 +94,17 @@ class OpenaiChatAdapter {
|
|
|
94
94
|
else {
|
|
95
95
|
throw new Error('Not supported OpenIA Response');
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
let usage;
|
|
98
|
+
if (response.usage) {
|
|
99
|
+
usage = {
|
|
100
|
+
inputTokens: response.usage.input_tokens,
|
|
101
|
+
outputTokens: response.usage.output_tokens,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error('Unable to found usage info');
|
|
106
|
+
}
|
|
107
|
+
return { chatItem, usage };
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { Logger } from '../../../core/logger/Logger.js';
|
|
3
3
|
import { WhatsAppReceiver } from './WhatsAppReceiver.js';
|
|
4
|
-
import { singleton } from 'tsyringe';
|
|
5
4
|
import { WabotDevConnection } from './WabotDevConnection.js';
|
|
6
5
|
import { devListentEvent } from './WabotDevSocketContracts.js';
|
|
6
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
7
7
|
|
|
8
8
|
let WhatsAppReceiverByDevConnection = class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
|
|
9
9
|
wabotDevConnection;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { Logger } from '../../../core/logger/Logger.js';
|
|
3
3
|
import { WhatsAppReceiver } from './WhatsAppReceiver.js';
|
|
4
|
-
import { singleton } from 'tsyringe';
|
|
5
4
|
import { ExpressProvider } from '../../../feature/express/ExpressProvider.js';
|
|
6
5
|
import { WhatsAppRepository } from './WhatsAppRepository.js';
|
|
6
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
7
7
|
|
|
8
8
|
let WhatsAppReceiverByWebHook = class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
|
|
9
9
|
expressProvider;
|
package/dist/src/core/env/Env.js
CHANGED
|
@@ -28,7 +28,7 @@ class ChatBot {
|
|
|
28
28
|
}
|
|
29
29
|
const systemPrompt = await this.mindset.systemPrompt();
|
|
30
30
|
const tools = this.mindset.tools();
|
|
31
|
-
const newItemData = await this.adapter.nextItem({
|
|
31
|
+
const { chatItem: newItemData } = await this.adapter.nextItem({
|
|
32
32
|
model: 'gpt',
|
|
33
33
|
systemPrompt,
|
|
34
34
|
tools,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { HttpServerProvider } from '../http/HttpServerProvider.js';
|
|
3
3
|
import express from 'express';
|
|
4
|
-
import { singleton } from 'tsyringe';
|
|
5
4
|
import bodyParser from 'body-parser';
|
|
6
5
|
import { Logger } from '../../core/logger/Logger.js';
|
|
6
|
+
import { singleton } from '../../core/injection/index.js';
|
|
7
7
|
|
|
8
8
|
let ExpressProvider = class ExpressProvider {
|
|
9
9
|
httpServerProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
+
import { singleton } from '../../core/injection/index.js';
|
|
2
3
|
import { Logger } from '../../core/logger/Logger.js';
|
|
3
4
|
import { Server } from 'http';
|
|
4
|
-
import { singleton } from 'tsyringe';
|
|
5
5
|
|
|
6
6
|
let HttpServerProvider = class HttpServerProvider {
|
|
7
7
|
server = null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { singleton } from '../../core/injection/index.js';
|
|
2
3
|
import { Logger } from '../../core/logger/Logger.js';
|
|
3
4
|
import { HttpServerProvider } from '../http/HttpServerProvider.js';
|
|
4
5
|
import { Server } from 'socket.io';
|
|
5
|
-
import { singleton } from 'tsyringe';
|
|
6
6
|
|
|
7
7
|
let SocketServerProvider = class SocketServerProvider {
|
|
8
8
|
httpServerProvider;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -514,18 +514,27 @@ type IFunctionCallItem = {
|
|
|
514
514
|
type IChatItem = IBotMessageItem | IHumanMessageItem | IFunctionCallItem;
|
|
515
515
|
type IChatItemType = (typeof chatItemTypeOptions)[number];
|
|
516
516
|
|
|
517
|
+
interface ILanguageModelUsage {
|
|
518
|
+
inputTokens: number;
|
|
519
|
+
outputTokens: number;
|
|
520
|
+
}
|
|
521
|
+
|
|
517
522
|
interface IChatAdapterNextItemReq {
|
|
518
523
|
model: string;
|
|
519
524
|
systemPrompt: string;
|
|
520
525
|
tools: IMindsetTool[];
|
|
521
526
|
prevItems: IChatItem[];
|
|
522
527
|
}
|
|
528
|
+
interface IChatAdapterNextItemRes {
|
|
529
|
+
chatItem: IChatItem;
|
|
530
|
+
usage: ILanguageModelUsage;
|
|
531
|
+
}
|
|
523
532
|
interface IChatAdapter {
|
|
524
|
-
nextItem(req: IChatAdapterNextItemReq): Promise<
|
|
533
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
525
534
|
}
|
|
526
535
|
|
|
527
536
|
declare class ChatAdapter implements IChatAdapter {
|
|
528
|
-
nextItem(req: IChatAdapterNextItemReq): Promise<
|
|
537
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
529
538
|
}
|
|
530
539
|
|
|
531
540
|
type IChatItemData = IEntityData & IChatItem;
|
|
@@ -798,7 +807,7 @@ declare class ClaudeChatAdapter implements IChatAdapter {
|
|
|
798
807
|
private anthropic;
|
|
799
808
|
private logger;
|
|
800
809
|
constructor();
|
|
801
|
-
nextItem(req: IChatAdapterNextItemReq): Promise<
|
|
810
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
802
811
|
private mapChatItems;
|
|
803
812
|
private mapHumanMessage;
|
|
804
813
|
private mapBotMessage;
|
|
@@ -811,7 +820,7 @@ declare class DeepSeekChatAdapter implements IChatAdapter {
|
|
|
811
820
|
private deepSeek;
|
|
812
821
|
private logger;
|
|
813
822
|
constructor();
|
|
814
|
-
nextItem(req: IChatAdapterNextItemReq): Promise<
|
|
823
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
815
824
|
private mapChatItems;
|
|
816
825
|
private mapHumanMessage;
|
|
817
826
|
private mapBotMessage;
|
|
@@ -823,7 +832,7 @@ declare class DeepSeekChatAdapter implements IChatAdapter {
|
|
|
823
832
|
declare class OpenaiChatAdapter implements IChatAdapter {
|
|
824
833
|
private openai;
|
|
825
834
|
private logger;
|
|
826
|
-
nextItem(req: IChatAdapterNextItemReq): Promise<
|
|
835
|
+
nextItem(req: IChatAdapterNextItemReq): Promise<IChatAdapterNextItemRes>;
|
|
827
836
|
private mapChatItems;
|
|
828
837
|
private mapConectionMessage;
|
|
829
838
|
private mapBotMessage;
|
|
@@ -1279,4 +1288,4 @@ interface IValidateMaxOptions {
|
|
|
1279
1288
|
}
|
|
1280
1289
|
declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
|
|
1281
1290
|
|
|
1282
|
-
export { Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
|
|
1291
|
+
export { Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
|