@fiado/api-invoker 5.29.0 → 5.30.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.
@@ -1,11 +1,11 @@
1
1
  import { IHttpRequest } from "@fiado/http-client";
2
2
  import { IAiEngineApi } from "./interfaces/IAiEngineApi.js";
3
- import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine/index.js";
3
+ import { AiAnalyzeResponse, AiImageInput } from "@fiado/type-kit/bin/aiEngine/index.js";
4
4
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
5
5
  export declare class AiEngineApi implements IAiEngineApi {
6
6
  private readonly httpRequest;
7
7
  private readonly baseUrl;
8
8
  constructor(httpRequest: IHttpRequest);
9
- analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
9
+ analyze(prompt: string, systemPrompt?: string, modelId?: string, images?: AiImageInput[], maxTokens?: number): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
10
10
  }
11
11
  export {};
@@ -20,11 +20,13 @@ let AiEngineApi = class AiEngineApi {
20
20
  constructor(httpRequest) {
21
21
  this.httpRequest = httpRequest;
22
22
  }
23
- async analyze(prompt, systemPrompt, modelId) {
23
+ async analyze(prompt, systemPrompt, modelId, images, maxTokens) {
24
24
  try {
25
25
  const url = `${this.baseUrl}ai/analyze`;
26
- const body = { prompt, systemPrompt, modelId };
27
- log.info(`Calling AI Engine at: ${url}`);
26
+ const body = { prompt, systemPrompt, modelId, maxTokens, images };
27
+ // No se loguea el body: las imagenes en base64 lo harian ilegible y
28
+ // el prompt puede traer datos del cliente.
29
+ log.info(`Calling AI Engine at: ${url}`, { images: images?.length ?? 0 });
28
30
  return await this.httpRequest.post(url, body, { 'operationName': 'aiAnalyze' });
29
31
  }
30
32
  catch (error) {
@@ -1,6 +1,13 @@
1
- import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine/index.js";
1
+ import { AiAnalyzeResponse, AiImageInput } from "@fiado/type-kit/bin/aiEngine/index.js";
2
2
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
3
3
  export interface IAiEngineApi {
4
- analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
4
+ /**
5
+ * Analiza un prompt con Claude via Bedrock.
6
+ *
7
+ * @param images Imagenes en base64. Se envian antes del texto del prompt.
8
+ * Omitir para analisis de solo texto.
9
+ * @param maxTokens Limite de tokens de salida. Default del servidor si se omite.
10
+ */
11
+ analyze(prompt: string, systemPrompt?: string, modelId?: string, images?: AiImageInput[], maxTokens?: number): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
5
12
  }
6
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.29.0",
3
+ "version": "5.30.0",
4
4
  "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
5
5
  "type": "module",
6
6
  "main": "bin/index.js",
@@ -34,7 +34,7 @@
34
34
  "@fiado/gateway-adapter": "^3.9.0",
35
35
  "@fiado/http-client": "^2.0.1",
36
36
  "@fiado/logger": "^1.1.3",
37
- "@fiado/type-kit": "^3.308.0",
37
+ "@fiado/type-kit": "^3.309.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -2,7 +2,7 @@ import dotenv from 'dotenv';
2
2
  import { inject, injectable } from "inversify";
3
3
  import { IHttpRequest } from "@fiado/http-client";
4
4
  import { IAiEngineApi } from "./interfaces/IAiEngineApi.js";
5
- import { AiAnalyzeRequest, AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine/index.js";
5
+ import { AiAnalyzeRequest, AiAnalyzeResponse, AiImageInput } from "@fiado/type-kit/bin/aiEngine/index.js";
6
6
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
7
7
  import { log } from "@fiado/logger";
8
8
  dotenv.config();
@@ -14,11 +14,19 @@ export class AiEngineApi implements IAiEngineApi {
14
14
 
15
15
  constructor(@inject("IHttpRequest") private readonly httpRequest: IHttpRequest) {}
16
16
 
17
- public async analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>> {
17
+ public async analyze(
18
+ prompt: string,
19
+ systemPrompt?: string,
20
+ modelId?: string,
21
+ images?: AiImageInput[],
22
+ maxTokens?: number,
23
+ ): Promise<FiadoApiResponse<AiAnalyzeResponse>> {
18
24
  try {
19
25
  const url = `${this.baseUrl}ai/analyze`;
20
- const body: AiAnalyzeRequest = { prompt, systemPrompt, modelId };
21
- log.info(`Calling AI Engine at: ${url}`);
26
+ const body: AiAnalyzeRequest = { prompt, systemPrompt, modelId, maxTokens, images };
27
+ // No se loguea el body: las imagenes en base64 lo harian ilegible y
28
+ // el prompt puede traer datos del cliente.
29
+ log.info(`Calling AI Engine at: ${url}`, { images: images?.length ?? 0 });
22
30
  return await this.httpRequest.post(url, body, { 'operationName': 'aiAnalyze' });
23
31
  } catch (error) {
24
32
  log.error('Error calling AI Engine from api-invoker', error as Error);
@@ -1,6 +1,19 @@
1
- import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine/index.js";
1
+ import { AiAnalyzeResponse, AiImageInput } from "@fiado/type-kit/bin/aiEngine/index.js";
2
2
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
3
3
 
4
4
  export interface IAiEngineApi {
5
- analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
5
+ /**
6
+ * Analiza un prompt con Claude via Bedrock.
7
+ *
8
+ * @param images Imagenes en base64. Se envian antes del texto del prompt.
9
+ * Omitir para analisis de solo texto.
10
+ * @param maxTokens Limite de tokens de salida. Default del servidor si se omite.
11
+ */
12
+ analyze(
13
+ prompt: string,
14
+ systemPrompt?: string,
15
+ modelId?: string,
16
+ images?: AiImageInput[],
17
+ maxTokens?: number,
18
+ ): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
6
19
  }