@tstdl/base 0.92.12 → 0.92.13

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/ai/ai.service.js CHANGED
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import '../polyfills.js';
8
- import { GoogleGenerativeAI } from '@google/generative-ai';
8
+ import { FunctionCallingMode as GoogleFunctionCallingMode, GoogleGenerativeAI } from '@google/generative-ai';
9
9
  import { NotSupportedError } from '../errors/not-supported.error.js';
10
10
  import { Singleton } from '../injector/decorators.js';
11
11
  import { inject, injectArgument } from '../injector/inject.js';
@@ -17,6 +17,11 @@ import { assertDefinedPass, assertNotNullPass, isDefined } from '../utils/type-g
17
17
  import { AiFileService } from './ai-file.service.js';
18
18
  import { AiSession } from './ai-session.js';
19
19
  import { isSchemaFunctionDeclarationWithHandler } from './types.js';
20
+ const functionCallingModeMap = {
21
+ auto: GoogleFunctionCallingMode.AUTO,
22
+ force: GoogleFunctionCallingMode.ANY,
23
+ none: GoogleFunctionCallingMode.NONE
24
+ };
20
25
  let AiService = class AiService {
21
26
  #options = injectArgument(this);
22
27
  #fileService = inject(AiFileService, this.#options);
@@ -159,7 +164,7 @@ Always output the content and tags in Deutsch.`,
159
164
  systemInstruction: request.systemInstruction,
160
165
  tools: isDefined(googleFunctionDeclarations) ? [{ functionDeclarations: googleFunctionDeclarations }] : undefined,
161
166
  toolConfig: isDefined(request.functionCallingMode)
162
- ? { functionCallingConfig: { mode: (request.functionCallingMode ?? 'auto').toUpperCase() } }
167
+ ? { functionCallingConfig: { mode: functionCallingModeMap[request.functionCallingMode] } }
163
168
  : undefined,
164
169
  contents: googleContent
165
170
  });
@@ -216,7 +221,7 @@ Always output the content and tags in Deutsch.`,
216
221
  return { text: part.text };
217
222
  }
218
223
  if (isDefined(part.fileData)) {
219
- const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), `File not found.`);
224
+ const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), 'File not found.');
220
225
  return { file: file.id };
221
226
  }
222
227
  ;
package/ai/types.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { hasOwnProperty } from '../utils/object/object.js';
2
+ import { isDefined } from '../utils/type-guards.js';
2
3
  export function declareFunctions(declarations) {
3
4
  return declarations;
4
5
  }
5
6
  export function declareFunction(description, parameters, handler) {
6
- return { description, parameters, handler };
7
+ if (isDefined(handler)) {
8
+ return { description, parameters, handler };
9
+ }
10
+ return { description, parameters };
7
11
  }
8
12
  export function isSchemaFunctionDeclarationWithHandler(declaration) {
9
13
  return hasOwnProperty(declaration, 'handler');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.12",
3
+ "version": "0.92.13",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"