@tstdl/base 0.92.104 → 0.92.106

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
@@ -11,6 +11,7 @@ import { GoogleGenerativeAI } from '@google/generative-ai';
11
11
  import { NotSupportedError } from '../errors/not-supported.error.js';
12
12
  import { Singleton } from '../injector/decorators.js';
13
13
  import { inject, injectArgument } from '../injector/inject.js';
14
+ import { Logger } from '../logger/logger.js';
14
15
  import { getShutdownSignal } from '../process-shutdown.js';
15
16
  import { DeferredPromise } from '../promise/deferred-promise.js';
16
17
  import { LazyPromise } from '../promise/lazy-promise.js';
@@ -28,7 +29,6 @@ import { resolveValueOrAsyncProvider } from '../utils/value-or-provider.js';
28
29
  import { AiFileService } from './ai-file.service.js';
29
30
  import { AiSession } from './ai-session.js';
30
31
  import { isSchemaFunctionDeclarationWithHandler } from './types.js';
31
- import { Logger } from '../logger/logger.js';
32
32
  export class AiServiceOptions {
33
33
  apiKey;
34
34
  keyFile;
@@ -252,7 +252,6 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
252
252
  let lastUsageMetadata;
253
253
  let candidate;
254
254
  for await (const generationResponse of generation.stream) {
255
- this.#logger.trace('Handling generation stream response');
256
255
  candidate = generationResponse.candidates.at(0);
257
256
  inputContent.push(candidate.content);
258
257
  const { promptTokenCount = 0, candidatesTokenCount = 0 } = generationResponse.usageMetadata ?? {};
@@ -71,6 +71,8 @@ export declare class DocumentManagementService extends DocumentManagementService
71
71
  loadDocument(id: string): Promise<Document>;
72
72
  loadDocumentFile(id: string): Promise<DocumentFile>;
73
73
  loadType(id: string): Promise<DocumentType>;
74
+ getFileContent(fileId: string): Promise<Uint8Array>;
75
+ getFileContentStream(fileId: string): ReadableStream<Uint8Array>;
74
76
  getFileContentUrl(fileId: string, title: string | null, download?: boolean): Promise<string>;
75
77
  createCategory(parameters: CreateDocumentCategoryParameters): Promise<DocumentCategory>;
76
78
  createType(parameters: CreateDocumentTypeParameters): Promise<DocumentType>;
@@ -250,6 +250,14 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
250
250
  async loadType(id) {
251
251
  return this.documentTypeService.load(id);
252
252
  }
253
+ async getFileContent(fileId) {
254
+ const key = getDocumentFileKey(fileId);
255
+ return this.fileObjectStorage.getContent(key);
256
+ }
257
+ getFileContentStream(fileId) {
258
+ const key = getDocumentFileKey(fileId);
259
+ return this.fileObjectStorage.getContentStream(key);
260
+ }
253
261
  async getFileContentUrl(fileId, title, download = false) {
254
262
  const file = await this.documentFileService.load(fileId);
255
263
  return this.getDocumentFileContentObjectUrl(title ?? fileId, file, download);
@@ -554,6 +562,7 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
554
562
  async enrichDocument(documentId) {
555
563
  const document = await this.documentService.load(documentId);
556
564
  const { properties, ...extractionResult } = await this.extractFileInformation(document.fileId, document.typeId);
565
+ this.logger.trace(`Applying extraction to document ${document.id}`);
557
566
  await this.documentService.transaction(async (documentService, transaction) => {
558
567
  await documentService.update(document.id, { ...extractionResult, validated: false });
559
568
  await this.setPropertyValues({ documentId, properties: properties }, transaction);
@@ -727,6 +736,7 @@ Ordne die Datei unter "file" der passenden Anforderungen unter "requests" zu. Gi
727
736
  .where(isString(assumeTypeId) ? eq(documentType.id, assumeTypeId) : undefined);
728
737
  const typeLabelEntries = types.map((type) => ({ id: type.typeId, label: `${type.categoryLabel} | ${type.typeGroup} | ${type.typeLabel}` }));
729
738
  const typeLabels = typeLabelEntries.map(({ label }) => label);
739
+ this.logger.trace(`Classifying document file ${fileId}`);
730
740
  const documentTypeGeneration = await this.#aiService.generate({
731
741
  ...defaultGenerationOptions,
732
742
  generationSchema: object({
@@ -766,6 +776,7 @@ Ordne die Datei unter "file" der passenden Anforderungen unter "requests" zu. Gi
766
776
  ? {}
767
777
  : { documentProperties: object(fromEntries(propertiesSchemaEntries)) })
768
778
  });
779
+ this.logger.trace(`Extracting document file ${fileId}`);
769
780
  const { json: extraction } = await this.#aiService.generate({
770
781
  model: 'gemini-2.0-flash',
771
782
  generationOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.104",
3
+ "version": "0.92.106",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"