@tstdl/base 0.92.37 → 0.92.38

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.
@@ -2,7 +2,7 @@ import '../polyfills.js';
2
2
  import { Resolvable, type resolveArgumentType } from '../injector/interfaces.js';
3
3
  import { AiServiceOptions } from './ai.service.js';
4
4
  import { FileContentPart, FileInput } from './types.js';
5
- export type AiFileServiceOptions = Pick<AiServiceOptions, 'apiKey' | 'vertex'>;
5
+ export type AiFileServiceOptions = Pick<AiServiceOptions, 'apiKey' | 'keyFile' | 'vertex'>;
6
6
  export type AiFileServiceArgument = AiFileServiceOptions;
7
7
  type File = {
8
8
  id: string;
@@ -75,8 +75,8 @@ import { assertDefinedPass, isBlob, isDefined, isUndefined } from '../utils/type
75
75
  import { millisecondsPerSecond } from '../utils/units.js';
76
76
  let AiFileService = class AiFileService {
77
77
  #options = injectArgument(this);
78
- #fileManager = isUndefined(this.#options.vertex) ? new GoogleAIFileManager(this.#options.apiKey) : undefined;
79
- #storage = isDefined(this.#options.vertex) ? new Storage({ projectId: this.#options.vertex.project, apiKey: this.#options.apiKey }) : undefined;
78
+ #fileManager = isUndefined(this.#options.vertex) ? new GoogleAIFileManager(assertDefinedPass(this.#options.apiKey, 'Api key not defined')) : undefined;
79
+ #storage = isDefined(this.#options.vertex) ? new Storage({ keyFile: assertDefinedPass(this.#options.keyFile, 'Key file not defined'), projectId: this.#options.vertex.project }) : undefined;
80
80
  #fileMap = new Map();
81
81
  #fileUriMap = new Map();
82
82
  #logger = inject(Logger, 'AiFileService');
@@ -11,7 +11,8 @@ export type SpecializedGenerationResultGenerator<T> = AsyncGenerator<T> & {
11
11
  raw: Promise<GenerationResult>;
12
12
  };
13
13
  export declare class AiServiceOptions {
14
- apiKey: string;
14
+ apiKey?: string;
15
+ keyFile?: string;
15
16
  vertex?: {
16
17
  project: string;
17
18
  location: string;
package/ai/ai.service.js CHANGED
@@ -24,6 +24,7 @@ import { AiSession } from './ai-session.js';
24
24
  import { isSchemaFunctionDeclarationWithHandler } from './types.js';
25
25
  export class AiServiceOptions {
26
26
  apiKey;
27
+ keyFile;
27
28
  vertex;
28
29
  defaultModel;
29
30
  }
@@ -37,8 +38,8 @@ let AiService = class AiService {
37
38
  #options = injectArgument(this, { optional: true }) ?? inject(AiServiceOptions);
38
39
  #fileService = inject(AiFileService, this.#options);
39
40
  #genAI = (isDefined(this.#options.vertex)
40
- ? new VertexAI({ project: this.#options.vertex.project, location: this.#options.vertex.location, googleAuthOptions: { apiKey: this.#options.apiKey } })
41
- : new GoogleGenerativeAI(this.#options.apiKey));
41
+ ? new VertexAI({ project: this.#options.vertex.project, location: this.#options.vertex.location, googleAuthOptions: { apiKey: this.#options.apiKey, keyFile: this.#options.keyFile } })
42
+ : new GoogleGenerativeAI(assertDefinedPass(this.#options.apiKey, 'Api key not defined')));
42
43
  defaultModel = this.#options.defaultModel ?? 'gemini-2.0-flash-exp';
43
44
  createSession() {
44
45
  return new AiSession(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.37",
3
+ "version": "0.92.38",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"