@wabot-dev/framework 0.1.0-beta.25 → 0.1.0-beta.26

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.
@@ -92,7 +92,7 @@ let DeepSeekChatBotAdapter = class DeepSeekChatBotAdapter extends ChatBotAdapter
92
92
  deepSeekInput.push({
93
93
  role: 'tool',
94
94
  tool_call_id: itemData.content.id,
95
- content: itemData.content.result,
95
+ content: itemData.content.result ?? 'No result',
96
96
  });
97
97
  }
98
98
  }
@@ -0,0 +1,101 @@
1
+ import { Logger } from '../../logger/Logger.js';
2
+ import { OpenAI } from 'openai';
3
+
4
+ class OpenaiChatAdapter {
5
+ openai = new OpenAI();
6
+ logger = new Logger('wabot:openai-chat-adapter');
7
+ async nextItem(req) {
8
+ const openIaInput = [];
9
+ openIaInput.push({ role: 'system', content: req.systemPrompt });
10
+ openIaInput.push(...this.mapChatItems(req.prevItems));
11
+ const tools = req.tools.map((x) => this.mapTool(x));
12
+ const response = await this.openai.responses.create({
13
+ model: req.model,
14
+ input: openIaInput,
15
+ tools,
16
+ });
17
+ return this.mapResponse(response);
18
+ }
19
+ mapChatItems(chatItems) {
20
+ const openIaInput = [];
21
+ for (const { type, content } of chatItems) {
22
+ switch (type) {
23
+ case 'CONNECTION_MESSAGE':
24
+ openIaInput.push(this.mapConectionMessage(content));
25
+ break;
26
+ case 'BOT_MESSAGE':
27
+ openIaInput.push(this.mapBotMessage(content));
28
+ break;
29
+ case 'FUNCTION_CALL':
30
+ openIaInput.push(...this.mapFunctionCall(content));
31
+ break;
32
+ }
33
+ }
34
+ return openIaInput;
35
+ }
36
+ mapConectionMessage(item) {
37
+ if (!item.text) {
38
+ throw new Error('System message content is empty');
39
+ }
40
+ return { role: 'user', content: item.text };
41
+ }
42
+ mapBotMessage(item) {
43
+ if (!item.text) {
44
+ throw new Error('System message content is empty');
45
+ }
46
+ return { role: 'assistant', content: item.text };
47
+ }
48
+ mapFunctionCall(item) {
49
+ return [
50
+ {
51
+ type: 'function_call',
52
+ call_id: item.id,
53
+ name: item.name,
54
+ arguments: JSON.stringify(item.arguments),
55
+ },
56
+ {
57
+ type: 'function_call_output',
58
+ call_id: item.id,
59
+ output: item.result ?? 'Not result',
60
+ },
61
+ ];
62
+ }
63
+ mapTool(tool) {
64
+ return {
65
+ type: 'function',
66
+ name: tool.name,
67
+ description: tool.description,
68
+ parameters: {
69
+ type: 'object',
70
+ properties: tool.parameters.reduce((prev, param) => ({
71
+ ...prev,
72
+ [param.name]: { type: param.type, description: param.description },
73
+ }), {}),
74
+ required: tool.parameters.map((param) => param.name),
75
+ },
76
+ strict: true,
77
+ };
78
+ }
79
+ mapResponse(response) {
80
+ let newItem;
81
+ if (response.output_text) {
82
+ newItem = { type: 'BOT_MESSAGE', content: { text: response.output_text } };
83
+ }
84
+ else if (response.output && response.output[0]?.type == 'function_call') {
85
+ newItem = {
86
+ type: 'FUNCTION_CALL',
87
+ content: {
88
+ id: response.output[0].call_id,
89
+ name: response.output[0].name,
90
+ arguments: response.output[0].arguments,
91
+ },
92
+ };
93
+ }
94
+ else {
95
+ throw new Error('Not supported OpenIA Response');
96
+ }
97
+ return newItem;
98
+ }
99
+ }
100
+
101
+ export { OpenaiChatAdapter };
@@ -73,7 +73,7 @@ let OpenaiChatBotAdapter = class OpenaiChatBotAdapter extends ChatBotAdapter {
73
73
  openIaInput.push({
74
74
  type: 'function_call_output',
75
75
  call_id: itemData.content.id,
76
- output: itemData.content.result,
76
+ output: itemData.content.result ?? 'Not result',
77
77
  });
78
78
  }
79
79
  }
@@ -117,7 +117,7 @@ interface IChatMessage extends IStorableData {
117
117
  text?: string;
118
118
  documents?: IChatDocument[];
119
119
  images?: IChatImage[];
120
- senderName: string;
120
+ senderName?: string;
121
121
  }
122
122
  interface IConnectionChatMessage extends IChatMessage {
123
123
  chatConnection: IChatConnection;
@@ -129,7 +129,7 @@ interface IChatFunctionCall {
129
129
  id: string;
130
130
  name: string;
131
131
  arguments?: string;
132
- result: string;
132
+ result?: string;
133
133
  }
134
134
 
135
135
  type ISystemMessageItem = {
@@ -144,7 +144,8 @@ type ISystemFunctionCallItem = {
144
144
  type: 'FUNCTION_CALL';
145
145
  content: IChatFunctionCall;
146
146
  };
147
- type IChatItemData = IEntityData & (ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem);
147
+ type IChatItemRawData = ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem;
148
+ type IChatItemData = IEntityData & IChatItemRawData;
148
149
  type IChatItemType = IChatItemData['type'];
149
150
  declare class ChatItem extends Entity<IChatItemData> {
150
151
  getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
@@ -332,7 +333,17 @@ declare class MindsetOperator implements IMindset {
332
333
  identity(): Promise<IMindsetIdentity>;
333
334
  skills(): Promise<string>;
334
335
  limits(): Promise<string>;
336
+ systemPrompt(): Promise<string>;
337
+ tools(): IChatTool[];
338
+ tool(fn: IMindsetFunctionMetadata, module: IMindsetModuleMetadata): IChatTool;
339
+ private toolParameter;
340
+ /**
341
+ * @deprecated use id
342
+ */
335
343
  callFunction(name: string, params: string): Promise<string>;
344
+ /**
345
+ * @deprecated use id
346
+ */
336
347
  allFunctionsDescriptors(): Promise<{
337
348
  readonly type: "function";
338
349
  readonly name: string;
@@ -343,7 +354,13 @@ declare class MindsetOperator implements IMindset {
343
354
  readonly required: string[];
344
355
  };
345
356
  }[]>;
357
+ /**
358
+ * @deprecated use id
359
+ */
346
360
  private functionDescriptor;
361
+ /**
362
+ * @deprecated use id
363
+ */
347
364
  private toolParam;
348
365
  }
349
366
 
@@ -385,6 +402,27 @@ declare class ChatBot implements IChatBot {
385
402
  protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
386
403
  }
387
404
 
405
+ interface IChatToolParameter {
406
+ type: string;
407
+ name: string;
408
+ description: string;
409
+ }
410
+ interface IChatTool {
411
+ language: string;
412
+ name: string;
413
+ description: string;
414
+ parameters: IChatToolParameter[];
415
+ }
416
+ interface IChatAdapterNextItemReq {
417
+ model: string;
418
+ systemPrompt: string;
419
+ tools: IChatTool[];
420
+ prevItems: IChatItemRawData[];
421
+ }
422
+ interface IChatAdapter {
423
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatItemRawData>;
424
+ }
425
+
388
426
  declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
389
427
  private deepSeek;
390
428
  private model;
@@ -403,6 +441,18 @@ declare class OpenaiChatBotAdapter extends ChatBotAdapter {
403
441
  private mapChatItems;
404
442
  }
405
443
 
444
+ declare class OpenaiChatAdapter implements IChatAdapter {
445
+ private openai;
446
+ private logger;
447
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatItemRawData>;
448
+ private mapChatItems;
449
+ private mapConectionMessage;
450
+ private mapBotMessage;
451
+ private mapFunctionCall;
452
+ private mapTool;
453
+ private mapResponse;
454
+ }
455
+
406
456
  declare class ClaudeChatBotAdapter extends ChatBotAdapter {
407
457
  private anthropic;
408
458
  private model;
@@ -465,6 +515,7 @@ declare class Job extends Entity<IJobData> {
465
515
  interface ICrudRepository<T> {
466
516
  find(id: string): Promise<T | null>;
467
517
  findOrThrow(id: string): Promise<T>;
518
+ findByIds(ids: string[]): Promise<T[]>;
468
519
  findAll(id: string): Promise<T[]>;
469
520
  create(item: T): Promise<void>;
470
521
  update(item: T): Promise<void>;
@@ -515,6 +566,7 @@ declare class PgCrudRepository<P extends Entity<IEntityData>> extends PgReposito
515
566
  protected readonly config: IPgRepositoryConfig<P>;
516
567
  constructor(pool: Pool, config: IPgRepositoryConfig<P>);
517
568
  find(id: string): Promise<P | null>;
569
+ findByIds(ids: string[]): Promise<P[]>;
518
570
  findOrThrow(id: string): Promise<P>;
519
571
  findAll(): Promise<P[]>;
520
572
  create(item: P): Promise<void>;
@@ -1359,4 +1411,4 @@ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IM
1359
1411
 
1360
1412
  declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
1361
1413
 
1362
- export { Async, Auth, AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IJobData, type IJobEvent, type IJobEventListener, 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 IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, 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, type IrunChannelProps, 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, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, Random, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, command, commandHandler, container, get, inject, injectable, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runAsyncCommandHandlers, runChannel, runRestControllers, runServer, scoped, singleton, socket, telegram, validate, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
1414
+ export { Async, Auth, AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemRawData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatTool, type IChatToolParameter, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IJobData, type IJobEvent, type IJobEventListener, 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 IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, 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, type IrunChannelProps, 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, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, Random, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, command, commandHandler, container, get, inject, injectable, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runAsyncCommandHandlers, runChannel, runRestControllers, runServer, scoped, singleton, socket, telegram, validate, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
package/dist/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { DeepSeekChatBotAdapter } from './ai/deepseek/DeepSeekChatBotAdapter.js';
2
2
  export { OpenaiChatBotAdapter } from './ai/openia/OpenaiChatBotAdapter.js';
3
+ export { OpenaiChatAdapter } from './ai/openia/OpenaiChatAdapter.js';
3
4
  export { ClaudeChatBotAdapter } from './ai/claude/ClaudeChatBotAdapter.js';
4
5
  export { command } from './async/@command.js';
5
6
  export { commandHandler } from './async/@commandHandler.js';
@@ -22,6 +22,80 @@ let MindsetOperator = class MindsetOperator {
22
22
  limits() {
23
23
  return this.mindset.limits();
24
24
  }
25
+ async systemPrompt() {
26
+ let [identity, skills, limits] = await Promise.all([
27
+ this.identity(),
28
+ this.skills(),
29
+ this.limits(),
30
+ ]);
31
+ const language = identity.language.replaceAll('#', ' ');
32
+ const name = identity.name.replaceAll('#', ' ');
33
+ const age = identity.age ? identity.age.toString().replaceAll('#', ' ') : null;
34
+ const personality = identity.personality ? identity.personality.replaceAll('#', ' ') : null;
35
+ skills = skills.replaceAll('#', ' ');
36
+ limits = limits.replaceAll('#', ' ');
37
+ const systemPrompt = `
38
+ # System Instructions
39
+ you should act as a assistant.
40
+ your main language is ${language}.
41
+ your name is ${name}.
42
+ ${age ? 'you are ' + age + ' years old.' : ''}
43
+
44
+ ${personality ? '## Personality (in your main language) \n' + personality : ''}
45
+
46
+ ## Skills (in your main language)
47
+ ${skills}
48
+
49
+ ## System limitations (in your main language)
50
+ ${limits}
51
+
52
+ ## Chat memory
53
+ Next you will receive a chat history,
54
+ you should use this information to answer the user.
55
+ `;
56
+ return systemPrompt;
57
+ }
58
+ tools() {
59
+ return this.metadata.modules
60
+ .map((module) => module.functions.map((fn) => this.tool(fn, module)))
61
+ .flat();
62
+ }
63
+ tool(fn, module) {
64
+ const description = fn.config.description.replaceAll('#', ' ');
65
+ return {
66
+ language: module.config.language ?? 'english',
67
+ name: fn.name,
68
+ description,
69
+ parameters: fn.params.map((param) => this.toolParameter(param)),
70
+ };
71
+ }
72
+ toolParameter(param) {
73
+ let description = `
74
+ ### description (in your main language)
75
+ ${param.config.description.replaceAll('#', ' ')}
76
+ `;
77
+ const type = (() => {
78
+ if (param.type === Number)
79
+ return 'number';
80
+ if (param.type === String)
81
+ return 'string';
82
+ if (param.type === Date) {
83
+ description = `${description}
84
+ ### format: ISO 8681 - YYYY-MM-DDTHH:mm:ssZ
85
+ `;
86
+ return 'string';
87
+ }
88
+ throw new Error(`Unsupported type`);
89
+ })();
90
+ return {
91
+ type,
92
+ name: param.name,
93
+ description,
94
+ };
95
+ }
96
+ /**
97
+ * @deprecated use id
98
+ */
25
99
  async callFunction(name, params) {
26
100
  const fnMetadata = this.metadata.modules
27
101
  .map((module) => module.functions)
@@ -43,11 +117,17 @@ let MindsetOperator = class MindsetOperator {
43
117
  return `Error: ${error}`;
44
118
  }
45
119
  }
120
+ /**
121
+ * @deprecated use id
122
+ */
46
123
  async allFunctionsDescriptors() {
47
124
  return this.metadata.modules
48
125
  .map((module) => module.functions.map((fn) => this.functionDescriptor(fn)))
49
126
  .flat();
50
127
  }
128
+ /**
129
+ * @deprecated use id
130
+ */
51
131
  functionDescriptor(fn) {
52
132
  const description = fn.config.description.replaceAll('#', ' ');
53
133
  return {
@@ -64,6 +144,9 @@ let MindsetOperator = class MindsetOperator {
64
144
  },
65
145
  };
66
146
  }
147
+ /**
148
+ * @deprecated use id
149
+ */
67
150
  toolParam(param) {
68
151
  const addons = {
69
152
  description: `
@@ -18,6 +18,16 @@ class PgCrudRepository extends PgRepositoryBase {
18
18
  const items = await this.query(sql, [id]);
19
19
  return items.at(0) ?? null;
20
20
  }
21
+ async findByIds(ids) {
22
+ const sql = `
23
+ SELECT ${this.columns}
24
+ FROM ${this.table}
25
+ WHERE id IN (${ids.map((_, i) => '$' + (i + 1)).join(',')})
26
+ LIMIT 1
27
+ `;
28
+ const items = await this.query(sql, ids);
29
+ return items;
30
+ }
21
31
  async findOrThrow(id) {
22
32
  const item = await this.find(id);
23
33
  if (!item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.25",
3
+ "version": "0.1.0-beta.26",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",