@tstdl/base 0.93.33 → 0.93.34
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 +3 -3
- package/ai/types.d.ts +4 -0
- package/orm/server/repository.js +4 -1
- package/package.json +1 -1
- package/test1.js +24 -32
package/ai/ai.service.js
CHANGED
|
@@ -205,7 +205,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
205
205
|
};
|
|
206
206
|
const model = this.mapModel(request.model);
|
|
207
207
|
const maxModelTokens = await this.getModelOutputTokenLimit(model);
|
|
208
|
-
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? maxModelTokens;
|
|
208
|
+
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? maxModelTokens ?? 8192;
|
|
209
209
|
const inputContent = this.convertContents(request.contents);
|
|
210
210
|
let iterations = 0;
|
|
211
211
|
let totalPromptTokens = 0;
|
|
@@ -221,7 +221,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
221
221
|
model,
|
|
222
222
|
config: {
|
|
223
223
|
...config,
|
|
224
|
-
maxOutputTokens: Math.min(
|
|
224
|
+
maxOutputTokens: Math.min(1000000, maxTotalOutputTokens - totalOutputTokens),
|
|
225
225
|
},
|
|
226
226
|
contents: inputContent,
|
|
227
227
|
});
|
|
@@ -356,7 +356,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
if (isUndefined(modelInfo.outputTokenLimit)) {
|
|
359
|
-
|
|
359
|
+
return null;
|
|
360
360
|
}
|
|
361
361
|
return modelInfo.outputTokenLimit;
|
|
362
362
|
}
|
package/ai/types.d.ts
CHANGED
|
@@ -137,6 +137,10 @@ export type GenerationOptions = {
|
|
|
137
137
|
* The maximum number of tokens the model is allowed to generate for its thinking phase.
|
|
138
138
|
*/
|
|
139
139
|
thinkingBudget?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Whether to include the model's internal thoughts in the response.
|
|
142
|
+
*/
|
|
143
|
+
includeThoughts?: boolean;
|
|
140
144
|
};
|
|
141
145
|
/**
|
|
142
146
|
* A request to generate content from the AI model.
|
package/orm/server/repository.js
CHANGED
|
@@ -54,6 +54,9 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
54
54
|
#tableWithMetadata = this.#table;
|
|
55
55
|
#columnDefinitions = this.#context.columnDefinitions ?? getColumnDefinitions(this.#table);
|
|
56
56
|
#columnDefinitionsMap = this.#context.columnDefinitionsMap ?? getColumnDefinitionsMap(this.#table);
|
|
57
|
+
#upsertManyExcludedMapping = fromEntries(this.#columnDefinitions
|
|
58
|
+
.filter((column) => column.name != this.#table.id.name)
|
|
59
|
+
.map((column) => [column.name, sql `excluded.${sql.identifier(this.getColumn(column).name)}`]));
|
|
57
60
|
hasMetadata = typeExtends(this.type, Entity);
|
|
58
61
|
/**
|
|
59
62
|
* Gets the Drizzle table definition for the entity type.
|
|
@@ -593,7 +596,7 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
593
596
|
const mappedUpdate = isDefined(update)
|
|
594
597
|
? await this.mapUpdate(update)
|
|
595
598
|
: {
|
|
596
|
-
...
|
|
599
|
+
...this.#upsertManyExcludedMapping,
|
|
597
600
|
...this._getMetadataUpdate(update),
|
|
598
601
|
};
|
|
599
602
|
const rows = await this.session
|
package/package.json
CHANGED
package/test1.js
CHANGED
|
@@ -28,40 +28,48 @@ async function bootstrap() {
|
|
|
28
28
|
configureAiService({
|
|
29
29
|
vertex: {
|
|
30
30
|
project: '922353391551', // insolytics-application
|
|
31
|
-
location: 'europe-
|
|
31
|
+
location: 'europe-west4', // netherlands
|
|
32
32
|
},
|
|
33
33
|
keyFile: '/home/patrick/.secret-files/insolytics-application-service-key.json',
|
|
34
34
|
});
|
|
35
|
+
/*
|
|
35
36
|
configureOrm({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
repositoryConfig: {
|
|
38
|
+
schema: 'test',
|
|
39
|
+
},
|
|
40
|
+
connection: {
|
|
41
|
+
host: config.database.host,
|
|
42
|
+
port: config.database.port,
|
|
43
|
+
user: config.database.user,
|
|
44
|
+
password: config.database.pass,
|
|
45
|
+
database: config.database.database,
|
|
46
|
+
},
|
|
46
47
|
});
|
|
48
|
+
|
|
47
49
|
configureAuthenticationServer({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
serviceOptions: {
|
|
51
|
+
secret: '6fze56uz5e6ufrtzufrtu',
|
|
52
|
+
},
|
|
51
53
|
});
|
|
54
|
+
|
|
52
55
|
configurePostgresLock();
|
|
53
56
|
configurePostgresQueue();
|
|
54
57
|
configurePostgresKeyValueStore();
|
|
58
|
+
|
|
55
59
|
await runInInjectionContext(injector, migratePostgresKeyValueStoreSchema);
|
|
56
60
|
await runInInjectionContext(injector, migratePostgresLockSchema);
|
|
57
61
|
await runInInjectionContext(injector, migratePostgresQueueSchema);
|
|
58
62
|
await runInInjectionContext(injector, migrateAuditSchema);
|
|
59
63
|
await runInInjectionContext(injector, migrateTestSchema);
|
|
64
|
+
*/
|
|
60
65
|
}
|
|
61
66
|
async function main(_cancellationSignal) {
|
|
62
|
-
const repository = injectRepository(Test);
|
|
63
67
|
const aiService = inject(AiService);
|
|
64
68
|
const aiResult = await aiService.generate({
|
|
69
|
+
generationOptions: {
|
|
70
|
+
includeThoughts: true,
|
|
71
|
+
},
|
|
72
|
+
model: 'gemini-2.5-flash-lite',
|
|
65
73
|
contents: [{
|
|
66
74
|
role: 'user',
|
|
67
75
|
parts: [
|
|
@@ -70,25 +78,9 @@ async function main(_cancellationSignal) {
|
|
|
70
78
|
}],
|
|
71
79
|
});
|
|
72
80
|
console.log('AI Result:', aiResult);
|
|
81
|
+
console.log(aiResult.content);
|
|
73
82
|
if (1 + 1 == 2)
|
|
74
83
|
process.exit(0);
|
|
75
|
-
if (await repository.count() == 0) {
|
|
76
|
-
await repository.insertMany(testData);
|
|
77
|
-
}
|
|
78
|
-
let result;
|
|
79
|
-
const benchmarkResult = await timedBenchmarkAsync(1000, async () => {
|
|
80
|
-
result = await repository.search({
|
|
81
|
-
query: {
|
|
82
|
-
$parade: { fields: ['content'], query: 'vitumins', distance: 2 },
|
|
83
|
-
},
|
|
84
|
-
highlight: { source: 'content', includePositions: true },
|
|
85
|
-
score: true,
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
for (const item of result) {
|
|
89
|
-
console.log(item);
|
|
90
|
-
}
|
|
91
|
-
console.log('Benchmark result:', benchmarkResult);
|
|
92
84
|
}
|
|
93
85
|
Application.run('Test', [
|
|
94
86
|
provideInitializer(bootstrap),
|