@mate-academy/llm-gateway 8.6.0 → 8.8.0
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/README.md +40 -39
- package/dist/client/LLMClientEngine.d.ts +1 -0
- package/dist/client/LLMClientEngine.js +5 -4
- package/dist/client/LLMClientEngine.js.map +1 -1
- package/dist/client/agentRunner.d.ts +1 -0
- package/dist/client/agentRunner.js +30 -29
- package/dist/client/agentRunner.js.map +1 -1
- package/dist/client/codegen/fetchPromptRecords.js +0 -5
- package/dist/client/codegen/fetchPromptRecords.js.map +1 -1
- package/dist/client/codegen/index.d.ts +0 -1
- package/dist/client/codegen/index.js +0 -1
- package/dist/client/codegen/index.js.map +1 -1
- package/dist/client/codegen/renderSnapshot.constants.d.ts +0 -5
- package/dist/client/codegen/renderSnapshot.constants.js +1 -6
- package/dist/client/codegen/renderSnapshot.constants.js.map +1 -1
- package/dist/client/codegen/renderSnapshot.d.ts +4 -8
- package/dist/client/codegen/renderSnapshot.js +6 -81
- package/dist/client/codegen/renderSnapshot.js.map +1 -1
- package/dist/client/codegen/renderSnapshot.typedefs.d.ts +0 -1
- package/dist/client/createLLMClient.d.ts +5 -5
- package/dist/client/createLLMClient.js +4 -4
- package/dist/client/defineLLMPrompts.d.ts +6 -9
- package/dist/client/defineLLMPrompts.js.map +1 -1
- package/dist/client/llmClient.typedefs.d.ts +15 -14
- package/dist/client/promptRegistry.runtime.js +0 -6
- package/dist/client/promptRegistry.runtime.js.map +1 -1
- package/dist/client/promptSnapshot.typedefs.d.ts +3 -5
- package/dist/client/validationGate.d.ts +4 -8
- package/dist/client/validationGate.js +3 -25
- package/dist/client/validationGate.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.d.ts +14 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +113 -56
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js.map +1 -1
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.d.ts +6 -0
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js +45 -33
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js.map +1 -1
- package/dist/providers/OpenAI/OpenAI.typedefs.d.ts +10 -1
- package/dist/providers/OpenAI/OpenAI.typedefs.js +1 -0
- package/dist/providers/OpenAI/OpenAI.typedefs.js.map +1 -1
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.d.ts +9 -0
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +94 -47
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -1
- package/dist/services/LLMBaseService.abstract.d.ts +33 -0
- package/dist/services/LLMBaseService.abstract.js +89 -15
- package/dist/services/LLMBaseService.abstract.js.map +1 -1
- package/dist/services/agentRounds/LLMAgentRounds.d.ts +32 -0
- package/dist/services/agentRounds/LLMAgentRounds.js +77 -0
- package/dist/services/agentRounds/LLMAgentRounds.js.map +1 -0
- package/dist/services/agentRounds/agentRounds.typedefs.d.ts +48 -0
- package/dist/services/agentRounds/agentRounds.typedefs.js +3 -0
- package/dist/services/agentRounds/agentRounds.typedefs.js.map +1 -0
- package/dist/services/agentRounds/index.d.ts +2 -0
- package/dist/services/agentRounds/index.js +19 -0
- package/dist/services/agentRounds/index.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/utilities/llmTracing/llmTracing.typedefs.d.ts +1 -0
- package/dist/utilities/llmTracing/noopLLMTracing.js +3 -0
- package/dist/utilities/llmTracing/noopLLMTracing.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/codegen/extractVariables.d.ts +0 -7
- package/dist/client/codegen/extractVariables.js +0 -21
- package/dist/client/codegen/extractVariables.js.map +0 -1
|
@@ -5,6 +5,7 @@ const crypto_1 = require("crypto");
|
|
|
5
5
|
const serializeError_1 = require("../utilities/serializeError");
|
|
6
6
|
const LLMService_constants_1 = require("../LLMService.constants");
|
|
7
7
|
const utilities_1 = require("../utilities");
|
|
8
|
+
const agentRounds_1 = require("./agentRounds");
|
|
8
9
|
class LLMBaseService {
|
|
9
10
|
provider;
|
|
10
11
|
serviceName;
|
|
@@ -173,29 +174,83 @@ class LLMBaseService {
|
|
|
173
174
|
startedAt,
|
|
174
175
|
};
|
|
175
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Opens the per-round generation stream of an agent tool loop. Every model
|
|
179
|
+
* round the loop runs is traced through the returned recorder, so the run
|
|
180
|
+
* renders as one role-labelled transcript per round instead of a single
|
|
181
|
+
* generation covering the whole loop. The run's aggregate metrics point is
|
|
182
|
+
* written separately by `writeSuccessMetrics` and is unaffected.
|
|
183
|
+
*/
|
|
184
|
+
openAgentRounds(params) {
|
|
185
|
+
const { method, model, traceContext, modelParameters, } = params;
|
|
186
|
+
return new agentRounds_1.LLMAgentRounds((round) => {
|
|
187
|
+
const generationTrace = this.buildGenerationTrace({
|
|
188
|
+
method,
|
|
189
|
+
traceContext,
|
|
190
|
+
input: round.input,
|
|
191
|
+
output: round.isError
|
|
192
|
+
? this.describeError(round.error)
|
|
193
|
+
: round.output,
|
|
194
|
+
modelParameters,
|
|
195
|
+
startedAt: round.startedAt,
|
|
196
|
+
});
|
|
197
|
+
if (round.isError) {
|
|
198
|
+
this.recordGenerationTrace({
|
|
199
|
+
method,
|
|
200
|
+
model,
|
|
201
|
+
generationTrace,
|
|
202
|
+
isError: true,
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const { tokens, costs } = this.buildGenerationAccounting({
|
|
207
|
+
model,
|
|
208
|
+
usage: round.usage ?? {},
|
|
209
|
+
});
|
|
210
|
+
this.recordGenerationTrace({
|
|
211
|
+
method,
|
|
212
|
+
model,
|
|
213
|
+
generationTrace,
|
|
214
|
+
usageDetails: tokens,
|
|
215
|
+
costDetails: {
|
|
216
|
+
input: costs.input,
|
|
217
|
+
output: costs.output,
|
|
218
|
+
total: costs.total,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The generation a failed agent run falls back to when it never reached its
|
|
225
|
+
* first model round: a run that throws while assembling the request would
|
|
226
|
+
* otherwise trace nothing at all. Once a round has been recorded the
|
|
227
|
+
* transcript is already there, and no second observation is emitted for it.
|
|
228
|
+
*/
|
|
229
|
+
buildUnstartedRunTrace(params) {
|
|
230
|
+
const { rounds, method, traceContext, input, modelParameters, startedAt, } = params;
|
|
231
|
+
if (rounds.hasRecordedRound) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
return this.buildGenerationTrace({
|
|
235
|
+
method,
|
|
236
|
+
traceContext,
|
|
237
|
+
input,
|
|
238
|
+
modelParameters,
|
|
239
|
+
startedAt,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
176
242
|
/**
|
|
177
243
|
* Write success metrics for a specific method, and emit the matching
|
|
178
244
|
* generation observation when per-call trace context is provided.
|
|
179
245
|
*/
|
|
180
246
|
writeSuccessMetrics(params) {
|
|
181
|
-
const { method, model, usage
|
|
182
|
-
const costs = (
|
|
183
|
-
inputTextTokens,
|
|
184
|
-
outputTextTokens,
|
|
185
|
-
inputAudioTokens,
|
|
186
|
-
outputAudioTokens,
|
|
187
|
-
});
|
|
188
|
-
const input = inputTextTokens + inputAudioTokens;
|
|
189
|
-
const output = outputTextTokens + outputAudioTokens;
|
|
247
|
+
const { method, model, usage, writeMetrics, generationTrace, } = params;
|
|
248
|
+
const { tokens, costs } = this.buildGenerationAccounting({ model, usage });
|
|
190
249
|
this.recordGenerationTrace({
|
|
191
250
|
method,
|
|
192
251
|
model,
|
|
193
252
|
generationTrace,
|
|
194
|
-
usageDetails:
|
|
195
|
-
input,
|
|
196
|
-
output,
|
|
197
|
-
total: input + output,
|
|
198
|
-
},
|
|
253
|
+
usageDetails: tokens,
|
|
199
254
|
costDetails: {
|
|
200
255
|
input: costs.input,
|
|
201
256
|
output: costs.output,
|
|
@@ -212,13 +267,32 @@ class LLMBaseService {
|
|
|
212
267
|
modelConfig: model?.config || null,
|
|
213
268
|
method,
|
|
214
269
|
status: 'success',
|
|
270
|
+
tokens,
|
|
271
|
+
costs,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Token totals and costs of one accounted call, in the shape both the metrics
|
|
276
|
+
* writer and a generation observation take.
|
|
277
|
+
*/
|
|
278
|
+
buildGenerationAccounting(params) {
|
|
279
|
+
const { model, usage: { inputTextTokens = 0, outputTextTokens = 0, inputAudioTokens = 0, outputAudioTokens = 0, }, } = params;
|
|
280
|
+
const costs = (0, utilities_1.calculateCosts)(model, {
|
|
281
|
+
inputTextTokens,
|
|
282
|
+
outputTextTokens,
|
|
283
|
+
inputAudioTokens,
|
|
284
|
+
outputAudioTokens,
|
|
285
|
+
});
|
|
286
|
+
const input = inputTextTokens + inputAudioTokens;
|
|
287
|
+
const output = outputTextTokens + outputAudioTokens;
|
|
288
|
+
return {
|
|
215
289
|
tokens: {
|
|
216
290
|
input,
|
|
217
291
|
output,
|
|
218
292
|
total: input + output,
|
|
219
293
|
},
|
|
220
294
|
costs,
|
|
221
|
-
}
|
|
295
|
+
};
|
|
222
296
|
}
|
|
223
297
|
/**
|
|
224
298
|
* Write error metrics for a specific method, and emit the matching generation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMBaseService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMBaseService.abstract.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAWpC,+DAA4D;AAC5D,iEAAkF;AAElF,
|
|
1
|
+
{"version":3,"file":"LLMBaseService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMBaseService.abstract.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAWpC,+DAA4D;AAC5D,iEAAkF;AAElF,2CAQqB;AACrB,+CAA+C;AAO/C,MAAsB,cAAc;IAUhB;IAC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,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;;AAziBH,wCA0iBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type LLMAgentRoundSpec, type LLMAgentRoundWriter } from './agentRounds.typedefs';
|
|
2
|
+
/**
|
|
3
|
+
* The per-round generation stream of a single agent run.
|
|
4
|
+
*
|
|
5
|
+
* A tool loop is a sequence of model rounds, and each of them is a generation
|
|
6
|
+
* in its own right: the conversation as it stood when the request went out, and
|
|
7
|
+
* what the model answered with. Providers put every provider call through
|
|
8
|
+
* `run`, which is what guarantees a round that throws is traced exactly like a
|
|
9
|
+
* round that succeeds, and that no round of the loop goes unrecorded.
|
|
10
|
+
*
|
|
11
|
+
* The recorder deliberately knows nothing about messages — the provider hands
|
|
12
|
+
* over its own native array as the round's input.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LLMAgentRounds {
|
|
15
|
+
private readonly writeRound;
|
|
16
|
+
private didRecordRound;
|
|
17
|
+
constructor(writeRound: LLMAgentRoundWriter);
|
|
18
|
+
/**
|
|
19
|
+
* Whether any model round reached the tracer. A run that fails while still
|
|
20
|
+
* preparing its first request has no transcript to show, and its caller falls
|
|
21
|
+
* back to tracing the failure on its own.
|
|
22
|
+
*/
|
|
23
|
+
get hasRecordedRound(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Runs one provider call as a traced round. The provider's response is
|
|
26
|
+
* returned untouched and its failure rethrown unchanged: tracing never alters
|
|
27
|
+
* what the loop, or the caller, sees.
|
|
28
|
+
*/
|
|
29
|
+
run<ProviderResponse>(round: LLMAgentRoundSpec<ProviderResponse>): Promise<ProviderResponse>;
|
|
30
|
+
private callProvider;
|
|
31
|
+
private recordSafely;
|
|
32
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LLMAgentRounds = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The per-round generation stream of a single agent run.
|
|
6
|
+
*
|
|
7
|
+
* A tool loop is a sequence of model rounds, and each of them is a generation
|
|
8
|
+
* in its own right: the conversation as it stood when the request went out, and
|
|
9
|
+
* what the model answered with. Providers put every provider call through
|
|
10
|
+
* `run`, which is what guarantees a round that throws is traced exactly like a
|
|
11
|
+
* round that succeeds, and that no round of the loop goes unrecorded.
|
|
12
|
+
*
|
|
13
|
+
* The recorder deliberately knows nothing about messages — the provider hands
|
|
14
|
+
* over its own native array as the round's input.
|
|
15
|
+
*/
|
|
16
|
+
class LLMAgentRounds {
|
|
17
|
+
writeRound;
|
|
18
|
+
didRecordRound = false;
|
|
19
|
+
constructor(writeRound) {
|
|
20
|
+
this.writeRound = writeRound;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether any model round reached the tracer. A run that fails while still
|
|
24
|
+
* preparing its first request has no transcript to show, and its caller falls
|
|
25
|
+
* back to tracing the failure on its own.
|
|
26
|
+
*/
|
|
27
|
+
get hasRecordedRound() {
|
|
28
|
+
return this.didRecordRound;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Runs one provider call as a traced round. The provider's response is
|
|
32
|
+
* returned untouched and its failure rethrown unchanged: tracing never alters
|
|
33
|
+
* what the loop, or the caller, sees.
|
|
34
|
+
*/
|
|
35
|
+
async run(round) {
|
|
36
|
+
const startedAt = Date.now();
|
|
37
|
+
const response = await this.callProvider(round, startedAt);
|
|
38
|
+
try {
|
|
39
|
+
const { output, usage } = round.describeOutcome(response);
|
|
40
|
+
this.recordSafely({
|
|
41
|
+
input: round.input,
|
|
42
|
+
output,
|
|
43
|
+
usage,
|
|
44
|
+
startedAt,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
return response;
|
|
51
|
+
}
|
|
52
|
+
async callProvider(round, startedAt) {
|
|
53
|
+
try {
|
|
54
|
+
return await round.call();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.recordSafely({
|
|
58
|
+
input: round.input,
|
|
59
|
+
startedAt,
|
|
60
|
+
error,
|
|
61
|
+
isError: true,
|
|
62
|
+
});
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
recordSafely(round) {
|
|
67
|
+
try {
|
|
68
|
+
this.writeRound(round);
|
|
69
|
+
this.didRecordRound = true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.LLMAgentRounds = LLMAgentRounds;
|
|
77
|
+
//# sourceMappingURL=LLMAgentRounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMAgentRounds.js","sourceRoot":"","sources":["../../../src/services/agentRounds/LLMAgentRounds.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;GAWG;AACH,MAAa,cAAc;IAGI;IAFrB,cAAc,GAAG,KAAK,CAAC;IAE/B,YAA6B,UAA+B;QAA/B,eAAU,GAAV,UAAU,CAAqB;IAAG,CAAC;IAEhE;;;;OAIG;IACH,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CACP,KAA0C;QAE1C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAE3D,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YAE1D,IAAI,CAAC,YAAY,CAAC;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,MAAM;gBACN,KAAK;gBACL,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,YAAY,CACxB,KAA0C,EAC1C,SAAiB;QAEjB,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,CAAC;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,SAAS;gBACT,KAAK;gBACL,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAoB;QACvC,IAAI,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACvB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;IACH,CAAC;CACF;AAnED,wCAmEC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type LLMModelUsage } from '../../LLMService.typedefs';
|
|
2
|
+
/**
|
|
3
|
+
* One model round of an agent tool loop, as its provider observed it.
|
|
4
|
+
*
|
|
5
|
+
* `input` is the provider-native message array the round was sent with. Each
|
|
6
|
+
* provider keeps its own representation, so a round carries whatever that
|
|
7
|
+
* provider actually assembled — system instructions included — rather than a
|
|
8
|
+
* shared message shape none of them speaks.
|
|
9
|
+
*/
|
|
10
|
+
interface LLMAgentRoundBase {
|
|
11
|
+
input: unknown;
|
|
12
|
+
/**
|
|
13
|
+
* The round's own token usage. Providers that report usage per call fill it
|
|
14
|
+
* on every round; one that only totals a run leaves it unset until the last
|
|
15
|
+
* round, which then carries the run total.
|
|
16
|
+
*/
|
|
17
|
+
usage?: LLMModelUsage;
|
|
18
|
+
/** Epoch milliseconds stamped immediately before the provider call. */
|
|
19
|
+
startedAt: number;
|
|
20
|
+
}
|
|
21
|
+
interface LLMSuccessfulAgentRound extends LLMAgentRoundBase {
|
|
22
|
+
output: unknown;
|
|
23
|
+
error?: never;
|
|
24
|
+
isError?: false;
|
|
25
|
+
}
|
|
26
|
+
interface LLMFailedAgentRound extends LLMAgentRoundBase {
|
|
27
|
+
output?: never;
|
|
28
|
+
error: unknown;
|
|
29
|
+
isError: true;
|
|
30
|
+
}
|
|
31
|
+
export type LLMAgentRound = LLMSuccessfulAgentRound | LLMFailedAgentRound;
|
|
32
|
+
/**
|
|
33
|
+
* What one round's response contributes to its generation. Produced by the
|
|
34
|
+
* provider because only the provider knows which part of its response is the
|
|
35
|
+
* assistant output and where that response reports its usage.
|
|
36
|
+
*/
|
|
37
|
+
export interface LLMAgentRoundOutcome {
|
|
38
|
+
output: unknown;
|
|
39
|
+
usage?: LLMModelUsage;
|
|
40
|
+
}
|
|
41
|
+
export interface LLMAgentRoundSpec<ProviderResponse> {
|
|
42
|
+
input: unknown;
|
|
43
|
+
call: () => Promise<ProviderResponse>;
|
|
44
|
+
describeOutcome: (response: ProviderResponse) => LLMAgentRoundOutcome;
|
|
45
|
+
}
|
|
46
|
+
/** Emits the generation observation of a single agent round. */
|
|
47
|
+
export type LLMAgentRoundWriter = (round: LLMAgentRound) => void;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentRounds.typedefs.js","sourceRoot":"","sources":["../../../src/services/agentRounds/agentRounds.typedefs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agentRounds.typedefs"), exports);
|
|
18
|
+
__exportStar(require("./LLMAgentRounds"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/agentRounds/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,mDAAiC"}
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agentRounds"), exports);
|
|
17
18
|
__exportStar(require("./LLMBaseService.abstract"), exports);
|
|
18
19
|
__exportStar(require("./LLMCompletionService.abstract"), exports);
|
|
19
20
|
__exportStar(require("./LLMServicePurposeFactory.abstract"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kEAAgD;AAChD,sEAAoD;AACpD,kEAAgD;AAChD,oEAAkD;AAClD,oEAAkD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4DAA0C;AAC1C,kEAAgD;AAChD,sEAAoD;AACpD,kEAAgD;AAChD,oEAAkD;AAClD,oEAAkD"}
|
|
@@ -92,6 +92,7 @@ export interface LLMGatewayTracer {
|
|
|
92
92
|
withTrace<Result>(name: string, context: LLMTraceContext, fn: () => Promise<Result>): Promise<Result>;
|
|
93
93
|
recordGeneration(generation: LLMGenerationTraceRecord): void;
|
|
94
94
|
withToolObservation<Result>(name: string, input: unknown, fn: () => Promise<Result>): Promise<Result>;
|
|
95
|
+
withAgentObservation<Result>(name: string, input: unknown, fn: () => Promise<Result>): Promise<Result>;
|
|
95
96
|
/**
|
|
96
97
|
* Updates the active trace of this tracer only (name/input replace, metadata
|
|
97
98
|
* merges). A no-op outside an active scope. Isolated per tracer so it can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noopLLMTracing.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/noopLLMTracing.ts"],"names":[],"mappings":";;;AAMA,MAAM,oBAAoB;IACf,SAAS,GAAG,KAAK,CAAC;IAE3B,KAAK,CAAC,SAAS,CACb,KAAa,EACb,QAAyB,EACzB,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,gBAAgB;QACd,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,KAAa,EACb,MAAe,EACf,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,iBAAiB;QACf,sBAAsB;IACxB,CAAC;IAED,qBAAqB;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,sBAAsB;IACxB,CAAC;CACF;AAEY,QAAA,oBAAoB,GAAqB,IAAI,oBAAoB,EAAE,CAAC;AAE1E,MAAM,yBAAyB,GAA6B,GAAG,EAAE;IACtE,oCAAoC;AACtC,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC"}
|
|
1
|
+
{"version":3,"file":"noopLLMTracing.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/noopLLMTracing.ts"],"names":[],"mappings":";;;AAMA,MAAM,oBAAoB;IACf,SAAS,GAAG,KAAK,CAAC;IAE3B,KAAK,CAAC,SAAS,CACb,KAAa,EACb,QAAyB,EACzB,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,gBAAgB;QACd,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,KAAa,EACb,MAAe,EACf,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,KAAa,EACb,MAAe,EACf,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,iBAAiB;QACf,sBAAsB;IACxB,CAAC;IAED,qBAAqB;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,sBAAsB;IACxB,CAAC;CACF;AAEY,QAAA,oBAAoB,GAAqB,IAAI,oBAAoB,EAAE,CAAC;AAE1E,MAAM,yBAAyB,GAA6B,GAAG,EAAE;IACtE,oCAAoC;AACtC,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC"}
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the plain variable names a prompt references, matching the runtime
|
|
3
|
-
* compile path (only `{{var}}` survives the conditional drop, see plan §1.3).
|
|
4
|
-
* Section/closer tokens (`{{#cond}}`, `{{/cond}}`) are excluded so the generated
|
|
5
|
-
* required-variable set agrees with what the validation gate counts as provided.
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractRequiredVariables(promptText: string): string[];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractRequiredVariables = extractRequiredVariables;
|
|
4
|
-
const VARIABLE_PATTERN = /{{\s*([\w.]+)\s*}}/g;
|
|
5
|
-
/**
|
|
6
|
-
* Extracts the plain variable names a prompt references, matching the runtime
|
|
7
|
-
* compile path (only `{{var}}` survives the conditional drop, see plan §1.3).
|
|
8
|
-
* Section/closer tokens (`{{#cond}}`, `{{/cond}}`) are excluded so the generated
|
|
9
|
-
* required-variable set agrees with what the validation gate counts as provided.
|
|
10
|
-
*/
|
|
11
|
-
function extractRequiredVariables(promptText) {
|
|
12
|
-
const names = new Set();
|
|
13
|
-
for (const match of promptText.matchAll(VARIABLE_PATTERN)) {
|
|
14
|
-
const token = match[1];
|
|
15
|
-
if (!token.startsWith('#') && !token.startsWith('/')) {
|
|
16
|
-
names.add(token);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return [...names].sort();
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=extractVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractVariables.js","sourceRoot":"","sources":["../../../src/client/codegen/extractVariables.ts"],"names":[],"mappings":";;AAQA,4DAYC;AApBD,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,UAAkB;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEvB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|