@tstdl/base 0.92.78 → 0.92.79

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.
Files changed (2) hide show
  1. package/ai/ai.service.js +22 -20
  2. package/package.json +1 -1
package/ai/ai.service.js CHANGED
@@ -339,27 +339,29 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
339
339
  convertGoogleContent(content) {
340
340
  return {
341
341
  role: content.role,
342
- parts: content.parts
343
- .map((part) => {
344
- if (isDefined(part.text)) {
345
- if (part.text.length == 0) {
346
- return null;
342
+ parts: isUndefined(content.parts)
343
+ ? []
344
+ : content.parts
345
+ .map((part) => {
346
+ if (isDefined(part.text)) {
347
+ if (part.text.length == 0) {
348
+ return null;
349
+ }
350
+ return { text: part.text };
347
351
  }
348
- return { text: part.text };
349
- }
350
- if (isDefined(part.fileData)) {
351
- const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), 'File not found.');
352
- return { file: file.id };
353
- }
354
- if (isDefined(part.functionResponse)) {
355
- return { functionResult: { name: part.functionResponse.name, value: part.functionResponse.response } };
356
- }
357
- if (isDefined(part.functionCall)) {
358
- return { functionCall: { name: part.functionCall.name, parameters: part.functionCall.args } };
359
- }
360
- throw new NotSupportedError('Unsupported content part.');
361
- })
362
- .filter(isNotNull)
352
+ if (isDefined(part.fileData)) {
353
+ const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), 'File not found.');
354
+ return { file: file.id };
355
+ }
356
+ if (isDefined(part.functionResponse)) {
357
+ return { functionResult: { name: part.functionResponse.name, value: part.functionResponse.response } };
358
+ }
359
+ if (isDefined(part.functionCall)) {
360
+ return { functionCall: { name: part.functionCall.name, parameters: part.functionCall.args } };
361
+ }
362
+ throw new NotSupportedError('Unsupported content part.');
363
+ })
364
+ .filter(isNotNull)
363
365
  };
364
366
  }
365
367
  getModel(model) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.78",
3
+ "version": "0.92.79",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"