@tstdl/base 0.92.105 → 0.92.107
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
|
@@ -177,7 +177,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
177
177
|
for (const call of generation.functionCalls) {
|
|
178
178
|
const fn = assertDefinedPass(options.functions[call.name], 'Function in response not declared.');
|
|
179
179
|
const parametersSchema = await resolveValueOrAsyncProvider(fn.parameters);
|
|
180
|
-
const parameters = parametersSchema.parse(call.parameters);
|
|
180
|
+
const parameters = isDefined(parametersSchema) ? parametersSchema.parse(call.parameters) : call.parameters;
|
|
181
181
|
const handlerResult = isSchemaFunctionDeclarationWithHandler(fn) ? await fn.handler(parameters) : undefined;
|
|
182
182
|
result.push({ functionName: call.name, parameters: parameters, handlerResult: handlerResult });
|
|
183
183
|
}
|
|
@@ -317,7 +317,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
317
317
|
for (const call of generation.functionCalls) {
|
|
318
318
|
const fn = assertDefinedPass(options.functions[call.name], 'Function in response not declared.');
|
|
319
319
|
const parametersSchema = await resolveValueOrAsyncProvider(fn.parameters);
|
|
320
|
-
const parameters = parametersSchema.parse(call.parameters);
|
|
320
|
+
const parameters = isDefined(parametersSchema) ? parametersSchema.parse(call.parameters) : call.parameters;
|
|
321
321
|
const handlerResult = isSchemaFunctionDeclarationWithHandler(fn) ? await fn.handler(parameters) : undefined;
|
|
322
322
|
yield { functionName: call.name, parameters: parameters, handlerResult: handlerResult };
|
|
323
323
|
}
|
|
@@ -358,7 +358,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
358
358
|
return {
|
|
359
359
|
name,
|
|
360
360
|
description: declaration.description,
|
|
361
|
-
parameters: convertToOpenApiSchema(parametersSchema)
|
|
361
|
+
parameters: isDefined(parametersSchema) ? convertToOpenApiSchema(parametersSchema) : undefined
|
|
362
362
|
};
|
|
363
363
|
});
|
|
364
364
|
const functionsArray = await toArrayAsync(mapped);
|
package/ai/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type FileInput = {
|
|
|
9
9
|
export type SchemaFunctionDeclarations = Record<string, SchemaFunctionDeclaration<any>>;
|
|
10
10
|
export type SchemaFunctionDeclarationWithoutHandler<T extends Record = Record> = {
|
|
11
11
|
description: string;
|
|
12
|
-
parameters
|
|
12
|
+
parameters?: ValueOrAsyncProvider<ObjectSchema<T>>;
|
|
13
13
|
enabled?: ValueOrAsyncProvider<boolean>;
|
|
14
14
|
};
|
|
15
15
|
export type SchemaFunctionDeclarationWithHandler<T extends Record = Record, R = unknown> = SchemaFunctionDeclarationWithoutHandler<T> & {
|
|
@@ -20,7 +20,7 @@ export type SchemaFunctionDeclarationHandlerResult<T extends SchemaFunctionDecla
|
|
|
20
20
|
export type SchemaFunctionDeclarationsResult<T extends SchemaFunctionDeclarations = SchemaFunctionDeclarations> = {
|
|
21
21
|
[P in keyof T]: {
|
|
22
22
|
functionName: P;
|
|
23
|
-
parameters: SchemaOutput<ResolvedValueOrProvider<T[P]['parameters']
|
|
23
|
+
parameters: SchemaOutput<NonNullable<ResolvedValueOrProvider<T[P]['parameters']>>>;
|
|
24
24
|
handlerResult: SchemaFunctionDeclarationHandlerResult<T[P]>;
|
|
25
25
|
};
|
|
26
26
|
}[keyof T];
|
|
@@ -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);
|