agentlang 0.9.9 → 0.9.11
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/out/extension/main.cjs +38 -38
- package/out/extension/main.cjs.map +2 -2
- package/out/language/generated/ast.d.ts +1 -1
- package/out/language/generated/ast.js +1 -1
- package/out/language/generated/grammar.d.ts +1 -1
- package/out/language/generated/grammar.js +1 -1
- package/out/language/generated/module.d.ts +1 -1
- package/out/language/generated/module.js +1 -1
- package/out/language/main.cjs +850 -2388
- package/out/language/main.cjs.map +4 -4
- package/out/runtime/agents/common.d.ts +3 -1
- package/out/runtime/agents/common.d.ts.map +1 -1
- package/out/runtime/agents/common.js +35 -31
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/docs.d.ts +1 -0
- package/out/runtime/docs.d.ts.map +1 -1
- package/out/runtime/docs.js +16 -1
- package/out/runtime/docs.js.map +1 -1
- package/out/runtime/interpreter.d.ts +1 -0
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +60 -9
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/jsmodules.d.ts +2 -1
- package/out/runtime/jsmodules.d.ts.map +1 -1
- package/out/runtime/jsmodules.js +2 -1
- package/out/runtime/jsmodules.js.map +1 -1
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +3 -2
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +1 -0
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +3 -0
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts +12 -0
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +225 -28
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +7 -1
- package/out/runtime/modules/core.js.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.js +37 -6
- package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
- package/out/runtime/services/documentFetcher.d.ts +70 -0
- package/out/runtime/services/documentFetcher.d.ts.map +1 -0
- package/out/runtime/services/documentFetcher.js +582 -0
- package/out/runtime/services/documentFetcher.js.map +1 -0
- package/package.json +2 -1
- package/src/language/generated/ast.ts +1 -1
- package/src/language/generated/grammar.ts +1 -1
- package/src/language/generated/module.ts +1 -1
- package/src/runtime/agents/common.ts +37 -31
- package/src/runtime/docs.ts +17 -1
- package/src/runtime/interpreter.ts +64 -7
- package/src/runtime/jsmodules.ts +3 -1
- package/src/runtime/loader.ts +3 -2
- package/src/runtime/module.ts +4 -0
- package/src/runtime/modules/ai.ts +270 -33
- package/src/runtime/modules/core.ts +7 -1
- package/src/runtime/resolvers/sqldb/impl.ts +36 -6
- package/src/runtime/services/documentFetcher.ts +691 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as ai } from './ai.js';
|
|
1
|
+
import { default as ai, normalizeGeneratedCode } from './ai.js';
|
|
2
2
|
import { default as auth } from './auth.js';
|
|
3
3
|
import { default as files } from './files.js';
|
|
4
4
|
import { default as mcp } from './mcp.js';
|
|
@@ -527,6 +527,12 @@ export function eventMonitorsData(
|
|
|
527
527
|
export async function validateModule(moduleDef: any): Promise<Instance> {
|
|
528
528
|
try {
|
|
529
529
|
if (isString(moduleDef)) {
|
|
530
|
+
moduleDef = normalizeGeneratedCode(moduleDef);
|
|
531
|
+
if (!moduleDef.startsWith('module')) {
|
|
532
|
+
moduleDef = `module Temp
|
|
533
|
+
${moduleDef}
|
|
534
|
+
`;
|
|
535
|
+
}
|
|
530
536
|
await parseModule(moduleDef);
|
|
531
537
|
return makeInstance(
|
|
532
538
|
'agentlang',
|
|
@@ -241,10 +241,31 @@ export class SqlDbResolver extends Resolver {
|
|
|
241
241
|
) {
|
|
242
242
|
const ftsAttrs = inst.record.getFullTextSearchAttributes() || ['*'];
|
|
243
243
|
const textToEmbed = this.extractTextForEmbedding(rowObj, ftsAttrs);
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
let embeddingConfig: any = undefined;
|
|
245
|
+
const instanceEmbeddingConfig = inst.get('embeddingConfig');
|
|
246
|
+
if (instanceEmbeddingConfig) {
|
|
247
|
+
try {
|
|
248
|
+
embeddingConfig =
|
|
249
|
+
typeof instanceEmbeddingConfig === 'string'
|
|
250
|
+
? JSON.parse(instanceEmbeddingConfig)
|
|
251
|
+
: instanceEmbeddingConfig;
|
|
252
|
+
} catch {
|
|
253
|
+
// If parsing fails, will fall back to env vars
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (!embeddingConfig) {
|
|
257
|
+
embeddingConfig = {
|
|
258
|
+
provider: process.env.AGENTLANG_EMBEDDING_PROVIDER || 'openai',
|
|
259
|
+
model: process.env.AGENTLANG_EMBEDDING_MODEL || 'text-embedding-3-small',
|
|
260
|
+
chunkSize: process.env.AGENTLANG_EMBEDDING_CHUNKSIZE
|
|
261
|
+
? parseInt(process.env.AGENTLANG_EMBEDDING_CHUNKSIZE, 10)
|
|
262
|
+
: 1000,
|
|
263
|
+
chunkOverlap: process.env.AGENTLANG_EMBEDDING_CHUNKOVERLAP
|
|
264
|
+
? parseInt(process.env.AGENTLANG_EMBEDDING_CHUNKOVERLAP, 10)
|
|
265
|
+
: 200,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const embeddingService = new EmbeddingService(embeddingConfig);
|
|
248
269
|
const res = await embeddingService.embedText(textToEmbed);
|
|
249
270
|
await addRowForFullTextSearch(n, path, res, ctx);
|
|
250
271
|
}
|
|
@@ -330,11 +351,20 @@ export class SqlDbResolver extends Resolver {
|
|
|
330
351
|
const aggregates = SqlDbResolver.normalizedAggregates(inst, tableName);
|
|
331
352
|
|
|
332
353
|
let vectorResult: Instance[] | undefined;
|
|
333
|
-
|
|
354
|
+
// Use environment variable based embedding config for queries
|
|
355
|
+
const embeddingConfig = {
|
|
356
|
+
provider: process.env.AGENTLANG_EMBEDDING_PROVIDER || 'openai',
|
|
357
|
+
model: process.env.AGENTLANG_EMBEDDING_MODEL || 'text-embedding-3-small',
|
|
358
|
+
chunkSize: process.env.AGENTLANG_EMBEDDING_CHUNKSIZE
|
|
359
|
+
? parseInt(process.env.AGENTLANG_EMBEDDING_CHUNKSIZE, 10)
|
|
360
|
+
: 1000,
|
|
361
|
+
chunkOverlap: process.env.AGENTLANG_EMBEDDING_CHUNKOVERLAP
|
|
362
|
+
? parseInt(process.env.AGENTLANG_EMBEDDING_CHUNKOVERLAP, 10)
|
|
363
|
+
: 200,
|
|
364
|
+
};
|
|
334
365
|
const ftsAttrs = inst.record.getFullTextSearchAttributes();
|
|
335
366
|
if (
|
|
336
367
|
(await isVectorStoreSupported()) &&
|
|
337
|
-
embeddingConfig &&
|
|
338
368
|
qattrs &&
|
|
339
369
|
(ftsAttrs || Object.keys(qattrs).some(k => k.endsWith('?')))
|
|
340
370
|
) {
|