@tstdl/base 0.92.32 → 0.92.35
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-file.service.d.ts +3 -5
- package/ai/ai.service.d.ts +4 -0
- package/ai/ai.service.js +7 -4
- package/ai/types.d.ts +0 -1
- package/document-management/api/document-management.api.d.ts +4 -4
- package/package.json +2 -1
- package/schema/converters/openapi-converter.js +0 -1
- package/utils/comparison.d.ts +2 -2
- package/utils/comparison.js +10 -4
package/ai/ai-file.service.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import '../polyfills.js';
|
|
2
2
|
import { Resolvable, type resolveArgumentType } from '../injector/interfaces.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
defaultModel?: AiModel;
|
|
7
|
-
};
|
|
3
|
+
import { AiServiceOptions } from './ai.service.js';
|
|
4
|
+
import { FileContentPart, FileInput } from './types.js';
|
|
5
|
+
export type AiFileServiceOptions = Pick<AiServiceOptions, 'apiKey' | 'vertex'>;
|
|
8
6
|
export type AiFileServiceArgument = AiFileServiceOptions;
|
|
9
7
|
type File = {
|
|
10
8
|
id: string;
|
package/ai/ai.service.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type SpecializedGenerationResultGenerator<T> = AsyncGenerator<T> & {
|
|
|
12
12
|
};
|
|
13
13
|
export declare class AiServiceOptions {
|
|
14
14
|
apiKey: string;
|
|
15
|
+
vertex?: {
|
|
16
|
+
project: string;
|
|
17
|
+
location: string;
|
|
18
|
+
};
|
|
15
19
|
defaultModel?: AiModel;
|
|
16
20
|
}
|
|
17
21
|
export type AiServiceArgument = AiServiceOptions;
|
package/ai/ai.service.js
CHANGED
|
@@ -4,7 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { FinishReason, FunctionCallingMode as GoogleFunctionCallingMode,
|
|
7
|
+
import { FinishReason, FunctionCallingMode as GoogleFunctionCallingMode, VertexAI } from '@google-cloud/vertexai';
|
|
8
|
+
import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
8
9
|
import { NotSupportedError } from '../errors/not-supported.error.js';
|
|
9
10
|
import { Singleton } from '../injector/decorators.js';
|
|
10
11
|
import { inject, injectArgument } from '../injector/inject.js';
|
|
@@ -23,6 +24,7 @@ import { AiSession } from './ai-session.js';
|
|
|
23
24
|
import { isSchemaFunctionDeclarationWithHandler } from './types.js';
|
|
24
25
|
export class AiServiceOptions {
|
|
25
26
|
apiKey;
|
|
27
|
+
vertex;
|
|
26
28
|
defaultModel;
|
|
27
29
|
}
|
|
28
30
|
;
|
|
@@ -34,7 +36,9 @@ const functionCallingModeMap = {
|
|
|
34
36
|
let AiService = class AiService {
|
|
35
37
|
#options = injectArgument(this, { optional: true }) ?? inject(AiServiceOptions);
|
|
36
38
|
#fileService = inject(AiFileService, this.#options);
|
|
37
|
-
#genAI =
|
|
39
|
+
#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));
|
|
38
42
|
defaultModel = this.#options.defaultModel ?? 'gemini-2.0-flash-exp';
|
|
39
43
|
createSession() {
|
|
40
44
|
return new AiSession(this);
|
|
@@ -195,7 +199,6 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
195
199
|
topK: request.generationOptions?.topK,
|
|
196
200
|
responseMimeType: isDefined(request.generationSchema) ? 'application/json' : undefined,
|
|
197
201
|
responseSchema: isDefined(request.generationSchema) ? convertToOpenApiSchema(request.generationSchema) : undefined,
|
|
198
|
-
presencePenalty: request.generationOptions?.presencePenalty,
|
|
199
202
|
frequencyPenalty: request.generationOptions?.frequencyPenalty
|
|
200
203
|
};
|
|
201
204
|
const inputContent = this.convertContents(request.contents);
|
|
@@ -211,7 +214,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
211
214
|
maxOutputTokens: Math.min(8192, maxTotalOutputTokens - totalOutputTokens)
|
|
212
215
|
},
|
|
213
216
|
systemInstruction: request.systemInstruction,
|
|
214
|
-
tools: isDefined(googleFunctionDeclarations) ? [{ functionDeclarations: googleFunctionDeclarations }] : undefined,
|
|
217
|
+
tools: (isDefined(googleFunctionDeclarations) && (googleFunctionDeclarations.length > 0)) ? [{ functionDeclarations: googleFunctionDeclarations }] : undefined,
|
|
215
218
|
toolConfig: isDefined(request.functionCallingMode)
|
|
216
219
|
? { functionCallingConfig: { mode: functionCallingModeMap[request.functionCallingMode] } }
|
|
217
220
|
: undefined,
|
package/ai/types.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ export declare const documentManagementApiDefinition: {
|
|
|
32
32
|
resource: string;
|
|
33
33
|
method: "GET";
|
|
34
34
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
35
|
-
readonly id: string;
|
|
36
35
|
readonly title: string | null;
|
|
36
|
+
readonly id: string;
|
|
37
37
|
readonly download?: boolean | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
result: Uint8ArrayConstructor;
|
|
@@ -43,8 +43,8 @@ export declare const documentManagementApiDefinition: {
|
|
|
43
43
|
resource: string;
|
|
44
44
|
method: "GET";
|
|
45
45
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
46
|
-
readonly id: string;
|
|
47
46
|
readonly title: string | null;
|
|
47
|
+
readonly id: string;
|
|
48
48
|
readonly download?: boolean | undefined;
|
|
49
49
|
}>;
|
|
50
50
|
result: import("../../schema/index.js").StringSchema;
|
|
@@ -406,8 +406,8 @@ declare const _DocumentManagementApi: import("../../api/index.js").ApiClient<{
|
|
|
406
406
|
resource: string;
|
|
407
407
|
method: "GET";
|
|
408
408
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
409
|
-
readonly id: string;
|
|
410
409
|
readonly title: string | null;
|
|
410
|
+
readonly id: string;
|
|
411
411
|
readonly download?: boolean | undefined;
|
|
412
412
|
}>;
|
|
413
413
|
result: Uint8ArrayConstructor;
|
|
@@ -417,8 +417,8 @@ declare const _DocumentManagementApi: import("../../api/index.js").ApiClient<{
|
|
|
417
417
|
resource: string;
|
|
418
418
|
method: "GET";
|
|
419
419
|
parameters: import("../../schema/index.js").ObjectSchema<{
|
|
420
|
-
readonly id: string;
|
|
421
420
|
readonly title: string | null;
|
|
421
|
+
readonly id: string;
|
|
422
422
|
readonly download?: boolean | undefined;
|
|
423
423
|
}>;
|
|
424
424
|
result: import("../../schema/index.js").StringSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.35",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
"./utils/string": "./utils/string/index.js"
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
+
"@google-cloud/vertexai": "^1.9.2",
|
|
121
122
|
"disposablestack": "1.1",
|
|
122
123
|
"luxon": "^3.5",
|
|
123
124
|
"reflect-metadata": "^0.2",
|
package/utils/comparison.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare function compareByValueSelectionOrdered<T>(...selectors: (readonl
|
|
|
4
4
|
export declare function compareByValueToOrder<T>(order: T[]): (a: T, b: T) => number;
|
|
5
5
|
export declare const orderRest: unique symbol;
|
|
6
6
|
export declare function compareByValueSelectionToOrder<T, TSelect>(order: (TSelect | typeof orderRest)[], selector: (item: T) => TSelect): (a: T, b: T) => number;
|
|
7
|
-
export declare function compareByValue<T>(a: T, b: T): number;
|
|
8
|
-
export declare function compareByValueDescending<T>(a: T, b: T): number;
|
|
7
|
+
export declare function compareByValue<T>(a: T, b: T, strict?: boolean): number;
|
|
8
|
+
export declare function compareByValueDescending<T>(a: T, b: T, strict?: boolean): number;
|
package/utils/comparison.js
CHANGED
|
@@ -58,7 +58,7 @@ export function compareByValueSelectionToOrder(order, selector) {
|
|
|
58
58
|
return compareByValue(indexA, indexB);
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
export function compareByValue(a, b) {
|
|
61
|
+
export function compareByValue(a, b, strict = true) {
|
|
62
62
|
if (a === b) {
|
|
63
63
|
return 0;
|
|
64
64
|
}
|
|
@@ -68,9 +68,12 @@ export function compareByValue(a, b) {
|
|
|
68
68
|
else if (b > a) {
|
|
69
69
|
return -1;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
if (!strict) {
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
throw new Error('Objects not comparable');
|
|
72
75
|
}
|
|
73
|
-
export function compareByValueDescending(a, b) {
|
|
76
|
+
export function compareByValueDescending(a, b, strict = true) {
|
|
74
77
|
if (a === b) {
|
|
75
78
|
return 0;
|
|
76
79
|
}
|
|
@@ -80,5 +83,8 @@ export function compareByValueDescending(a, b) {
|
|
|
80
83
|
else if (b > a) {
|
|
81
84
|
return 1;
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
if (!strict) {
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
throw new Error('Objects not comparable');
|
|
84
90
|
}
|