@cdot65/daystrom 1.0.3
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 +93 -0
- package/dist/airs/management.d.ts +21 -0
- package/dist/airs/management.d.ts.map +1 -0
- package/dist/airs/management.js +78 -0
- package/dist/airs/management.js.map +1 -0
- package/dist/airs/scanner.d.ts +8 -0
- package/dist/airs/scanner.d.ts.map +1 -0
- package/dist/airs/scanner.js +28 -0
- package/dist/airs/scanner.js.map +1 -0
- package/dist/airs/types.d.ts +26 -0
- package/dist/airs/types.d.ts.map +1 -0
- package/dist/airs/types.js +6 -0
- package/dist/airs/types.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +3 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +127 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/list.d.ts +3 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +22 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +57 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/resume.d.ts +3 -0
- package/dist/cli/commands/resume.d.ts.map +1 -0
- package/dist/cli/commands/resume.js +95 -0
- package/dist/cli/commands/resume.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/prompts.d.ts +6 -0
- package/dist/cli/prompts.d.ts.map +1 -0
- package/dist/cli/prompts.js +72 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/cli/renderer.d.ts +15 -0
- package/dist/cli/renderer.d.ts.map +1 -0
- package/dist/cli/renderer.js +103 -0
- package/dist/cli/renderer.js.map +1 -0
- package/dist/config/loader.d.ts +3 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +63 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +72 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +42 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/constraints.d.ts +16 -0
- package/dist/core/constraints.d.ts.map +1 -0
- package/dist/core/constraints.js +77 -0
- package/dist/core/constraints.js.map +1 -0
- package/dist/core/loop.d.ts +23 -0
- package/dist/core/loop.d.ts.map +1 -0
- package/dist/core/loop.js +146 -0
- package/dist/core/loop.js.map +1 -0
- package/dist/core/metrics.d.ts +3 -0
- package/dist/core/metrics.d.ts.map +1 -0
- package/dist/core/metrics.js +38 -0
- package/dist/core/metrics.js.map +1 -0
- package/dist/core/types.d.ts +104 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/prompts/analyze-results.d.ts +3 -0
- package/dist/llm/prompts/analyze-results.d.ts.map +1 -0
- package/dist/llm/prompts/analyze-results.js +38 -0
- package/dist/llm/prompts/analyze-results.js.map +1 -0
- package/dist/llm/prompts/generate-tests.d.ts +3 -0
- package/dist/llm/prompts/generate-tests.d.ts.map +1 -0
- package/dist/llm/prompts/generate-tests.js +33 -0
- package/dist/llm/prompts/generate-tests.js.map +1 -0
- package/dist/llm/prompts/generate-topic.d.ts +4 -0
- package/dist/llm/prompts/generate-topic.d.ts.map +1 -0
- package/dist/llm/prompts/generate-topic.js +32 -0
- package/dist/llm/prompts/generate-topic.js.map +1 -0
- package/dist/llm/prompts/improve-topic.d.ts +3 -0
- package/dist/llm/prompts/improve-topic.d.ts.map +1 -0
- package/dist/llm/prompts/improve-topic.js +50 -0
- package/dist/llm/prompts/improve-topic.js.map +1 -0
- package/dist/llm/provider.d.ts +15 -0
- package/dist/llm/provider.d.ts.map +1 -0
- package/dist/llm/provider.js +71 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/llm/schemas.d.ts +97 -0
- package/dist/llm/schemas.d.ts.map +1 -0
- package/dist/llm/schemas.js +22 -0
- package/dist/llm/schemas.js.map +1 -0
- package/dist/llm/service.d.ts +19 -0
- package/dist/llm/service.d.ts.map +1 -0
- package/dist/llm/service.js +177 -0
- package/dist/llm/service.js.map +1 -0
- package/dist/memory/diff.d.ts +4 -0
- package/dist/memory/diff.d.ts.map +1 -0
- package/dist/memory/diff.js +24 -0
- package/dist/memory/diff.js.map +1 -0
- package/dist/memory/extractor.d.ts +15 -0
- package/dist/memory/extractor.d.ts.map +1 -0
- package/dist/memory/extractor.js +129 -0
- package/dist/memory/extractor.js.map +1 -0
- package/dist/memory/injector.d.ts +8 -0
- package/dist/memory/injector.d.ts.map +1 -0
- package/dist/memory/injector.js +76 -0
- package/dist/memory/injector.js.map +1 -0
- package/dist/memory/prompts/extract-learnings.d.ts +3 -0
- package/dist/memory/prompts/extract-learnings.d.ts.map +1 -0
- package/dist/memory/prompts/extract-learnings.js +34 -0
- package/dist/memory/prompts/extract-learnings.js.map +1 -0
- package/dist/memory/schemas.d.ts +63 -0
- package/dist/memory/schemas.d.ts.map +1 -0
- package/dist/memory/schemas.js +13 -0
- package/dist/memory/schemas.js.map +1 -0
- package/dist/memory/store.d.ts +13 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +88 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/types.d.ts +55 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +6 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/persistence/store.d.ts +12 -0
- package/dist/persistence/store.d.ts.map +1 -0
- package/dist/persistence/store.js +68 -0
- package/dist/persistence/store.js.map +1 -0
- package/dist/persistence/types.d.ts +17 -0
- package/dist/persistence/types.d.ts.map +1 -0
- package/dist/persistence/types.js +2 -0
- package/dist/persistence/types.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export const generateTopicPrompt = ChatPromptTemplate.fromMessages([
|
|
3
|
+
[
|
|
4
|
+
'system',
|
|
5
|
+
`You are an expert at configuring Prisma AIRS custom topic guardrails. Your job is to create a topic definition that will effectively {intent} conversations about the described topic.
|
|
6
|
+
|
|
7
|
+
Constraints:
|
|
8
|
+
- Name: max 100 characters, concise and descriptive
|
|
9
|
+
- Description: max 250 characters, clearly defines what should be detected
|
|
10
|
+
- Examples: 1-5 examples, each max 250 characters
|
|
11
|
+
- Combined total (name + description + all examples) must not exceed 1000 characters
|
|
12
|
+
|
|
13
|
+
The description should be specific enough to catch relevant content but not so broad that it triggers on unrelated topics. Examples should represent diverse ways users might discuss the topic.
|
|
14
|
+
{memorySection}`,
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
'human',
|
|
18
|
+
`Create a custom topic guardrail to {intent} the following:
|
|
19
|
+
|
|
20
|
+
Topic: {topicDescription}
|
|
21
|
+
|
|
22
|
+
{seedExamplesSection}
|
|
23
|
+
|
|
24
|
+
Generate a topic definition with a name, description, and up to 5 representative examples.`,
|
|
25
|
+
],
|
|
26
|
+
]);
|
|
27
|
+
export function buildSeedExamplesSection(seeds) {
|
|
28
|
+
if (!seeds || seeds.length === 0)
|
|
29
|
+
return '';
|
|
30
|
+
return `Seed examples to build upon:\n${seeds.map((s, i) => `${i + 1}. ${s}`).join('\n')}`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=generate-topic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-topic.js","sourceRoot":"","sources":["../../../src/llm/prompts/generate-topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,YAAY,CAAC;IACjE;QACE,QAAQ;QACR;;;;;;;;;gBASY;KACb;IACD;QACE,OAAO;QACP;;;;;;2FAMuF;KACxF;CACF,CAAC,CAAC;AAEH,MAAM,UAAU,wBAAwB,CAAC,KAAgB;IACvD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,OAAO,iCAAiC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-topic.d.ts","sourceRoot":"","sources":["../../../src/llm/prompts/improve-topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,eAAO,MAAM,kBAAkB,8BA+C7B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export const improveTopicPrompt = ChatPromptTemplate.fromMessages([
|
|
3
|
+
[
|
|
4
|
+
'system',
|
|
5
|
+
`You are an expert at refining Prisma AIRS custom topic guardrails. Based on test results and analysis, improve the topic definition to reduce false positives and false negatives.
|
|
6
|
+
|
|
7
|
+
Constraints (MUST be respected):
|
|
8
|
+
- Name: KEEP THE EXACT SAME NAME as the current definition. Do NOT rename.
|
|
9
|
+
- Description: max 250 characters
|
|
10
|
+
- Examples: 1-5 examples, each max 250 characters
|
|
11
|
+
- Combined total (name + description + all examples): max 1000 characters
|
|
12
|
+
|
|
13
|
+
Focus on improving only the description and examples:
|
|
14
|
+
- Making the description more precise to reduce false positives
|
|
15
|
+
- Adding examples that cover missed patterns (false negatives)
|
|
16
|
+
- Removing or replacing examples that cause over-matching
|
|
17
|
+
- Using clear, unambiguous language
|
|
18
|
+
{memorySection}`,
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
'human',
|
|
22
|
+
`Improve this guardrail definition based on the analysis:
|
|
23
|
+
|
|
24
|
+
Current Definition:
|
|
25
|
+
- Name: {currentName}
|
|
26
|
+
- Description: {currentDescription}
|
|
27
|
+
- Examples: {currentExamples}
|
|
28
|
+
|
|
29
|
+
Performance (iteration {iteration}):
|
|
30
|
+
- Coverage: {coverage} (target: {targetCoverage})
|
|
31
|
+
- TPR: {tpr}, TNR: {tnr}
|
|
32
|
+
- Accuracy: {accuracy}
|
|
33
|
+
|
|
34
|
+
Analysis Summary: {analysisSummary}
|
|
35
|
+
|
|
36
|
+
False Positive Patterns: {fpPatterns}
|
|
37
|
+
False Negative Patterns: {fnPatterns}
|
|
38
|
+
|
|
39
|
+
Specific False Positives:
|
|
40
|
+
{specificFPs}
|
|
41
|
+
|
|
42
|
+
Specific False Negatives:
|
|
43
|
+
{specificFNs}
|
|
44
|
+
|
|
45
|
+
Suggestions from analysis: {suggestions}
|
|
46
|
+
|
|
47
|
+
Generate an improved topic definition that addresses these issues while staying within constraints.`,
|
|
48
|
+
],
|
|
49
|
+
]);
|
|
50
|
+
//# sourceMappingURL=improve-topic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-topic.js","sourceRoot":"","sources":["../../../src/llm/prompts/improve-topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,YAAY,CAAC;IAChE;QACE,QAAQ;QACR;;;;;;;;;;;;;gBAaY;KACb;IACD;QACE,OAAO;QACP;;;;;;;;;;;;;;;;;;;;;;;;;oGAyBgG;KACjG;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
import type { LlmProvider } from '../config/schema.js';
|
|
3
|
+
export interface LlmProviderConfig {
|
|
4
|
+
provider: LlmProvider;
|
|
5
|
+
model?: string;
|
|
6
|
+
anthropicApiKey?: string;
|
|
7
|
+
googleApiKey?: string;
|
|
8
|
+
googleCloudProject?: string;
|
|
9
|
+
googleCloudLocation?: string;
|
|
10
|
+
awsRegion?: string;
|
|
11
|
+
awsAccessKeyId?: string;
|
|
12
|
+
awsSecretAccessKey?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createLlmProvider(config: LlmProviderConfig): Promise<BaseChatModel>;
|
|
15
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/llm/provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAGjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAWD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgEzF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ChatAnthropic } from '@langchain/anthropic';
|
|
2
|
+
import { ChatBedrockConverse } from '@langchain/aws';
|
|
3
|
+
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
|
4
|
+
import { ChatVertexAI } from '@langchain/google-vertexai';
|
|
5
|
+
const DEFAULT_MODELS = {
|
|
6
|
+
'claude-api': 'claude-opus-4-6',
|
|
7
|
+
'claude-vertex': 'claude-opus-4-6',
|
|
8
|
+
'claude-bedrock': 'anthropic.claude-opus-4-6-v1',
|
|
9
|
+
'gemini-api': 'gemini-2.0-flash',
|
|
10
|
+
'gemini-vertex': 'gemini-2.0-flash',
|
|
11
|
+
'gemini-bedrock': 'gemini-2.0-flash',
|
|
12
|
+
};
|
|
13
|
+
export async function createLlmProvider(config) {
|
|
14
|
+
const modelName = config.model ?? DEFAULT_MODELS[config.provider];
|
|
15
|
+
switch (config.provider) {
|
|
16
|
+
case 'claude-api':
|
|
17
|
+
return new ChatAnthropic({
|
|
18
|
+
model: modelName,
|
|
19
|
+
anthropicApiKey: config.anthropicApiKey,
|
|
20
|
+
temperature: 0,
|
|
21
|
+
});
|
|
22
|
+
case 'claude-vertex': {
|
|
23
|
+
const { AnthropicVertex } = await import('@anthropic-ai/vertex-sdk');
|
|
24
|
+
const client = new AnthropicVertex({
|
|
25
|
+
projectId: config.googleCloudProject,
|
|
26
|
+
region: config.googleCloudLocation ?? 'global',
|
|
27
|
+
});
|
|
28
|
+
return new ChatAnthropic({
|
|
29
|
+
model: modelName,
|
|
30
|
+
temperature: 0,
|
|
31
|
+
createClient: () => client,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
case 'claude-bedrock': {
|
|
35
|
+
const opts = {
|
|
36
|
+
model: modelName,
|
|
37
|
+
region: config.awsRegion ?? 'us-east-1',
|
|
38
|
+
temperature: 0,
|
|
39
|
+
};
|
|
40
|
+
if (config.awsAccessKeyId && config.awsSecretAccessKey) {
|
|
41
|
+
opts.credentials = {
|
|
42
|
+
accessKeyId: config.awsAccessKeyId,
|
|
43
|
+
secretAccessKey: config.awsSecretAccessKey,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return new ChatBedrockConverse(opts);
|
|
47
|
+
}
|
|
48
|
+
case 'gemini-api':
|
|
49
|
+
return new ChatGoogleGenerativeAI({
|
|
50
|
+
model: modelName,
|
|
51
|
+
apiKey: config.googleApiKey,
|
|
52
|
+
temperature: 0,
|
|
53
|
+
});
|
|
54
|
+
case 'gemini-vertex':
|
|
55
|
+
return new ChatVertexAI({
|
|
56
|
+
model: modelName,
|
|
57
|
+
location: config.googleCloudLocation ?? 'us-central1',
|
|
58
|
+
temperature: 0,
|
|
59
|
+
authOptions: { projectId: config.googleCloudProject },
|
|
60
|
+
});
|
|
61
|
+
case 'gemini-bedrock':
|
|
62
|
+
return new ChatBedrockConverse({
|
|
63
|
+
model: modelName,
|
|
64
|
+
region: config.awsRegion ?? 'us-east-1',
|
|
65
|
+
temperature: 0,
|
|
66
|
+
});
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Unknown LLM provider: ${config.provider}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/llm/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAe1D,MAAM,cAAc,GAAgC;IAClD,YAAY,EAAE,iBAAiB;IAC/B,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,8BAA8B;IAChD,YAAY,EAAE,kBAAkB;IAChC,eAAe,EAAE,kBAAkB;IACnC,gBAAgB,EAAE,kBAAkB;CACrC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAyB;IAC/D,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,cAAc,CAAC,MAAM,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L,KAAK,eAAe;YAClB,OAAO,IAAI,YAAY,CAAC;gBACtB,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE,MAAM,CAAC,mBAAmB,IAAI,aAAa;gBACrD,WAAW,EAAE,CAAC;gBACd,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,kBAAkB,EAAE;aACtD,CAAC,CAAC;QAEL,KAAK,gBAAgB;YACnB,OAAO,IAAI,mBAAmB,CAAC;gBAC7B,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,MAAM,CAAC,SAAS,IAAI,WAAW;gBACvC,WAAW,EAAE,CAAC;aACf,CAAC,CAAC;QAEL;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CustomTopicSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
description: z.ZodString;
|
|
5
|
+
examples: z.ZodArray<z.ZodString, "many">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
description: string;
|
|
8
|
+
examples: string[];
|
|
9
|
+
name: string;
|
|
10
|
+
}, {
|
|
11
|
+
description: string;
|
|
12
|
+
examples: string[];
|
|
13
|
+
name: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const TestCaseSchema: z.ZodObject<{
|
|
16
|
+
prompt: z.ZodString;
|
|
17
|
+
expectedTriggered: z.ZodBoolean;
|
|
18
|
+
category: z.ZodString;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
category: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
expectedTriggered: boolean;
|
|
23
|
+
}, {
|
|
24
|
+
category: string;
|
|
25
|
+
prompt: string;
|
|
26
|
+
expectedTriggered: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const TestSuiteSchema: z.ZodObject<{
|
|
29
|
+
positiveTests: z.ZodArray<z.ZodObject<{
|
|
30
|
+
prompt: z.ZodString;
|
|
31
|
+
expectedTriggered: z.ZodBoolean;
|
|
32
|
+
category: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
category: string;
|
|
35
|
+
prompt: string;
|
|
36
|
+
expectedTriggered: boolean;
|
|
37
|
+
}, {
|
|
38
|
+
category: string;
|
|
39
|
+
prompt: string;
|
|
40
|
+
expectedTriggered: boolean;
|
|
41
|
+
}>, "many">;
|
|
42
|
+
negativeTests: z.ZodArray<z.ZodObject<{
|
|
43
|
+
prompt: z.ZodString;
|
|
44
|
+
expectedTriggered: z.ZodBoolean;
|
|
45
|
+
category: z.ZodString;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
category: string;
|
|
48
|
+
prompt: string;
|
|
49
|
+
expectedTriggered: boolean;
|
|
50
|
+
}, {
|
|
51
|
+
category: string;
|
|
52
|
+
prompt: string;
|
|
53
|
+
expectedTriggered: boolean;
|
|
54
|
+
}>, "many">;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
positiveTests: {
|
|
57
|
+
category: string;
|
|
58
|
+
prompt: string;
|
|
59
|
+
expectedTriggered: boolean;
|
|
60
|
+
}[];
|
|
61
|
+
negativeTests: {
|
|
62
|
+
category: string;
|
|
63
|
+
prompt: string;
|
|
64
|
+
expectedTriggered: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
}, {
|
|
67
|
+
positiveTests: {
|
|
68
|
+
category: string;
|
|
69
|
+
prompt: string;
|
|
70
|
+
expectedTriggered: boolean;
|
|
71
|
+
}[];
|
|
72
|
+
negativeTests: {
|
|
73
|
+
category: string;
|
|
74
|
+
prompt: string;
|
|
75
|
+
expectedTriggered: boolean;
|
|
76
|
+
}[];
|
|
77
|
+
}>;
|
|
78
|
+
export declare const AnalysisReportSchema: z.ZodObject<{
|
|
79
|
+
summary: z.ZodString;
|
|
80
|
+
falsePositivePatterns: z.ZodArray<z.ZodString, "many">;
|
|
81
|
+
falseNegativePatterns: z.ZodArray<z.ZodString, "many">;
|
|
82
|
+
suggestions: z.ZodArray<z.ZodString, "many">;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
summary: string;
|
|
85
|
+
falsePositivePatterns: string[];
|
|
86
|
+
falseNegativePatterns: string[];
|
|
87
|
+
suggestions: string[];
|
|
88
|
+
}, {
|
|
89
|
+
summary: string;
|
|
90
|
+
falsePositivePatterns: string[];
|
|
91
|
+
falseNegativePatterns: string[];
|
|
92
|
+
suggestions: string[];
|
|
93
|
+
}>;
|
|
94
|
+
export type CustomTopicOutput = z.infer<typeof CustomTopicSchema>;
|
|
95
|
+
export type TestSuiteOutput = z.infer<typeof TestSuiteSchema>;
|
|
96
|
+
export type AnalysisReportOutput = z.infer<typeof AnalysisReportSchema>;
|
|
97
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/llm/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAI5B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;EAIzB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG1B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC9D,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CustomTopicSchema = z.object({
|
|
3
|
+
name: z.string().min(1),
|
|
4
|
+
description: z.string().min(1),
|
|
5
|
+
examples: z.array(z.string().min(1)).min(1).max(5),
|
|
6
|
+
});
|
|
7
|
+
export const TestCaseSchema = z.object({
|
|
8
|
+
prompt: z.string().min(1),
|
|
9
|
+
expectedTriggered: z.boolean(),
|
|
10
|
+
category: z.string().min(1),
|
|
11
|
+
});
|
|
12
|
+
export const TestSuiteSchema = z.object({
|
|
13
|
+
positiveTests: z.array(TestCaseSchema).min(1),
|
|
14
|
+
negativeTests: z.array(TestCaseSchema).min(1),
|
|
15
|
+
});
|
|
16
|
+
export const AnalysisReportSchema = z.object({
|
|
17
|
+
summary: z.string().min(1),
|
|
18
|
+
falsePositivePatterns: z.array(z.string()),
|
|
19
|
+
falseNegativePatterns: z.array(z.string()),
|
|
20
|
+
suggestions: z.array(z.string()).min(1),
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/llm/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,qBAAqB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,qBAAqB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
import type { LlmService } from '../core/loop.js';
|
|
3
|
+
import type { AnalysisReport, CustomTopic, EfficacyMetrics, TestCase, TestResult } from '../core/types.js';
|
|
4
|
+
import type { MemoryInjector } from '../memory/injector.js';
|
|
5
|
+
export declare class LangChainLlmService implements LlmService {
|
|
6
|
+
private model;
|
|
7
|
+
private memoryInjector?;
|
|
8
|
+
private memorySection;
|
|
9
|
+
constructor(model: BaseChatModel, memoryInjector?: MemoryInjector | undefined);
|
|
10
|
+
loadMemory(topicDescription: string): Promise<number>;
|
|
11
|
+
generateTopic(description: string, intent: string, seeds?: string[]): Promise<CustomTopic>;
|
|
12
|
+
generateTests(topic: CustomTopic, intent: string): Promise<{
|
|
13
|
+
positiveTests: TestCase[];
|
|
14
|
+
negativeTests: TestCase[];
|
|
15
|
+
}>;
|
|
16
|
+
analyzeResults(topic: CustomTopic, results: TestResult[], metrics: EfficacyMetrics): Promise<AnalysisReport>;
|
|
17
|
+
improveTopic(topic: CustomTopic, metrics: EfficacyMetrics, analysis: AnalysisReport, results: TestResult[], iteration: number, targetCoverage: number): Promise<CustomTopic>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/llm/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AASjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACR,UAAU,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAoD5D,qBAAa,mBAAoB,YAAW,UAAU;IAIlD,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc,CAAC;IAJzB,OAAO,CAAC,aAAa,CAAM;gBAGjB,KAAK,EAAE,aAAa,EACpB,cAAc,CAAC,EAAE,cAAc,YAAA;IAGnC,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrD,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IA+B1F,aAAa,CACjB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;QAAC,aAAa,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;IAuB9D,cAAc,CAClB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC;IAqCpB,YAAY,CAChB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,UAAU,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,WAAW,CAAC;CA6CxB"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { MAX_COMBINED_LENGTH, MAX_DESCRIPTION_LENGTH, MAX_EXAMPLE_LENGTH, MAX_EXAMPLES, MAX_NAME_LENGTH, validateTopic, } from '../core/constraints.js';
|
|
2
|
+
import { analyzeResultsPrompt } from './prompts/analyze-results.js';
|
|
3
|
+
import { generateTestsPrompt } from './prompts/generate-tests.js';
|
|
4
|
+
import { buildSeedExamplesSection, generateTopicPrompt } from './prompts/generate-topic.js';
|
|
5
|
+
import { improveTopicPrompt } from './prompts/improve-topic.js';
|
|
6
|
+
import { AnalysisReportSchema, CustomTopicSchema, TestSuiteSchema, } from './schemas.js';
|
|
7
|
+
const MAX_RETRIES = 3;
|
|
8
|
+
/** Truncate a string so its UTF-8 byte length does not exceed maxBytes. */
|
|
9
|
+
function sliceToBytes(s, maxBytes) {
|
|
10
|
+
while (Buffer.byteLength(s, 'utf8') > maxBytes) {
|
|
11
|
+
s = s.slice(0, -1);
|
|
12
|
+
}
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
/** UTF-8 byte length of a string. */
|
|
16
|
+
function byteLen(s) {
|
|
17
|
+
return Buffer.byteLength(s, 'utf8');
|
|
18
|
+
}
|
|
19
|
+
/** Clamp topic fields to fit Prisma AIRS constraints (byte-aware, including combined limit) */
|
|
20
|
+
function clampTopic(topic) {
|
|
21
|
+
const name = sliceToBytes(topic.name, MAX_NAME_LENGTH);
|
|
22
|
+
let description = sliceToBytes(topic.description, MAX_DESCRIPTION_LENGTH);
|
|
23
|
+
const examples = topic.examples
|
|
24
|
+
.slice(0, MAX_EXAMPLES)
|
|
25
|
+
.map((e) => sliceToBytes(e, MAX_EXAMPLE_LENGTH));
|
|
26
|
+
// Enforce combined byte-length limit by dropping examples from the end, then trimming description
|
|
27
|
+
const combined = () => byteLen(name) + byteLen(description) + examples.reduce((s, e) => s + byteLen(e), 0);
|
|
28
|
+
while (combined() > MAX_COMBINED_LENGTH && examples.length > 1) {
|
|
29
|
+
examples.pop();
|
|
30
|
+
}
|
|
31
|
+
/* v8 ignore next 4 -- unreachable with current MAX constants (100+250+250=600 < 1000) */
|
|
32
|
+
if (combined() > MAX_COMBINED_LENGTH) {
|
|
33
|
+
const overflow = combined() - MAX_COMBINED_LENGTH;
|
|
34
|
+
description = sliceToBytes(description, byteLen(description) - overflow);
|
|
35
|
+
}
|
|
36
|
+
return { name, description, examples };
|
|
37
|
+
}
|
|
38
|
+
export class LangChainLlmService {
|
|
39
|
+
model;
|
|
40
|
+
memoryInjector;
|
|
41
|
+
memorySection = '';
|
|
42
|
+
constructor(model, memoryInjector) {
|
|
43
|
+
this.model = model;
|
|
44
|
+
this.memoryInjector = memoryInjector;
|
|
45
|
+
}
|
|
46
|
+
async loadMemory(topicDescription) {
|
|
47
|
+
if (!this.memoryInjector)
|
|
48
|
+
return 0;
|
|
49
|
+
this.memorySection = await this.memoryInjector.buildMemorySection(topicDescription);
|
|
50
|
+
// Count lines starting with "- [" as learning count
|
|
51
|
+
return this.memorySection.split('\n').filter((l) => l.startsWith('- [')).length;
|
|
52
|
+
}
|
|
53
|
+
async generateTopic(description, intent, seeds) {
|
|
54
|
+
const structured = this.model.withStructuredOutput(CustomTopicSchema);
|
|
55
|
+
const chain = generateTopicPrompt.pipe(structured);
|
|
56
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
57
|
+
try {
|
|
58
|
+
const raw = await chain.invoke({
|
|
59
|
+
topicDescription: description,
|
|
60
|
+
intent,
|
|
61
|
+
seedExamplesSection: buildSeedExamplesSection(seeds),
|
|
62
|
+
memorySection: this.memorySection,
|
|
63
|
+
});
|
|
64
|
+
const result = clampTopic(raw);
|
|
65
|
+
const errors = validateTopic(result);
|
|
66
|
+
if (errors.length === 0)
|
|
67
|
+
return result;
|
|
68
|
+
if (attempt === MAX_RETRIES - 1) {
|
|
69
|
+
throw new Error(`LLM output violates constraints after ${MAX_RETRIES} attempts: ${errors.map((e) => e.message).join(', ')}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (attempt === MAX_RETRIES - 1)
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/* v8 ignore next */
|
|
78
|
+
throw new Error('Unreachable');
|
|
79
|
+
}
|
|
80
|
+
async generateTests(topic, intent) {
|
|
81
|
+
const structured = this.model.withStructuredOutput(TestSuiteSchema);
|
|
82
|
+
const chain = generateTestsPrompt.pipe(structured);
|
|
83
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
84
|
+
try {
|
|
85
|
+
const raw = await chain.invoke({
|
|
86
|
+
topicName: topic.name,
|
|
87
|
+
topicDescription: topic.description,
|
|
88
|
+
topicExamples: topic.examples.map((e, i) => `${i + 1}. ${e}`).join('\n'),
|
|
89
|
+
intent,
|
|
90
|
+
memorySection: this.memorySection,
|
|
91
|
+
});
|
|
92
|
+
return raw;
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (attempt === MAX_RETRIES - 1)
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/* v8 ignore next */
|
|
100
|
+
throw new Error('Unreachable');
|
|
101
|
+
}
|
|
102
|
+
async analyzeResults(topic, results, metrics) {
|
|
103
|
+
const structured = this.model.withStructuredOutput(AnalysisReportSchema);
|
|
104
|
+
const chain = analyzeResultsPrompt.pipe(structured);
|
|
105
|
+
const fps = results.filter((r) => !r.testCase.expectedTriggered && r.actualTriggered);
|
|
106
|
+
const fns = results.filter((r) => r.testCase.expectedTriggered && !r.actualTriggered);
|
|
107
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
108
|
+
try {
|
|
109
|
+
const raw = await chain.invoke({
|
|
110
|
+
topicName: topic.name,
|
|
111
|
+
topicDescription: topic.description,
|
|
112
|
+
topicExamples: topic.examples.join(', '),
|
|
113
|
+
tpr: `${(metrics.truePositiveRate * 100).toFixed(1)}%`,
|
|
114
|
+
tnr: `${(metrics.trueNegativeRate * 100).toFixed(1)}%`,
|
|
115
|
+
accuracy: `${(metrics.accuracy * 100).toFixed(1)}%`,
|
|
116
|
+
coverage: `${(metrics.coverage * 100).toFixed(1)}%`,
|
|
117
|
+
falsePositives: fps.length > 0
|
|
118
|
+
? fps.map((r) => `- "${r.testCase.prompt}" (${r.testCase.category})`).join('\n')
|
|
119
|
+
: 'None',
|
|
120
|
+
falseNegatives: fns.length > 0
|
|
121
|
+
? fns.map((r) => `- "${r.testCase.prompt}" (${r.testCase.category})`).join('\n')
|
|
122
|
+
: 'None',
|
|
123
|
+
memorySection: this.memorySection,
|
|
124
|
+
});
|
|
125
|
+
return raw;
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (attempt === MAX_RETRIES - 1)
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/* v8 ignore next */
|
|
133
|
+
throw new Error('Unreachable');
|
|
134
|
+
}
|
|
135
|
+
async improveTopic(topic, metrics, analysis, results, iteration, targetCoverage) {
|
|
136
|
+
const structured = this.model.withStructuredOutput(CustomTopicSchema);
|
|
137
|
+
const chain = improveTopicPrompt.pipe(structured);
|
|
138
|
+
const fps = results.filter((r) => !r.testCase.expectedTriggered && r.actualTriggered);
|
|
139
|
+
const fns = results.filter((r) => r.testCase.expectedTriggered && !r.actualTriggered);
|
|
140
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
141
|
+
try {
|
|
142
|
+
const raw = await chain.invoke({
|
|
143
|
+
currentName: topic.name,
|
|
144
|
+
currentDescription: topic.description,
|
|
145
|
+
currentExamples: topic.examples.join(', '),
|
|
146
|
+
iteration,
|
|
147
|
+
coverage: `${(metrics.coverage * 100).toFixed(1)}%`,
|
|
148
|
+
targetCoverage: `${(targetCoverage * 100).toFixed(1)}%`,
|
|
149
|
+
tpr: `${(metrics.truePositiveRate * 100).toFixed(1)}%`,
|
|
150
|
+
tnr: `${(metrics.trueNegativeRate * 100).toFixed(1)}%`,
|
|
151
|
+
accuracy: `${(metrics.accuracy * 100).toFixed(1)}%`,
|
|
152
|
+
analysisSummary: analysis.summary,
|
|
153
|
+
fpPatterns: analysis.falsePositivePatterns.join('; ') || 'None',
|
|
154
|
+
fnPatterns: analysis.falseNegativePatterns.join('; ') || 'None',
|
|
155
|
+
specificFPs: fps.map((r) => `- "${r.testCase.prompt}"`).join('\n') || 'None',
|
|
156
|
+
specificFNs: fns.map((r) => `- "${r.testCase.prompt}"`).join('\n') || 'None',
|
|
157
|
+
suggestions: analysis.suggestions.join('; '),
|
|
158
|
+
memorySection: this.memorySection,
|
|
159
|
+
});
|
|
160
|
+
const result = clampTopic(raw);
|
|
161
|
+
const errors = validateTopic(result);
|
|
162
|
+
if (errors.length === 0)
|
|
163
|
+
return result;
|
|
164
|
+
if (attempt === MAX_RETRIES - 1) {
|
|
165
|
+
throw new Error(`LLM output violates constraints after ${MAX_RETRIES} attempts: ${errors.map((e) => e.message).join(', ')}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
if (attempt === MAX_RETRIES - 1)
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/* v8 ignore next */
|
|
174
|
+
throw new Error('Unreachable');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/llm/service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,wBAAwB,CAAC;AAUhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAEL,oBAAoB,EAEpB,iBAAiB,EAEjB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,2EAA2E;AAC3E,SAAS,YAAY,CAAC,CAAS,EAAE,QAAgB;IAC/C,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC;QAC/C,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,qCAAqC;AACrC,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,+FAA+F;AAC/F,SAAS,UAAU,CAAC,KAAwB;IAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,EA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,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,GAAG,aAAa,CAwB9F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function computeIterationDiff(from, to) {
|
|
2
|
+
const fromExSet = new Set(from.topic.examples);
|
|
3
|
+
const toExSet = new Set(to.topic.examples);
|
|
4
|
+
const examplesAdded = to.topic.examples.filter((e) => !fromExSet.has(e));
|
|
5
|
+
const examplesRemoved = from.topic.examples.filter((e) => !toExSet.has(e));
|
|
6
|
+
return {
|
|
7
|
+
fromIteration: from.iteration,
|
|
8
|
+
toIteration: to.iteration,
|
|
9
|
+
descriptionChanged: from.topic.description !== to.topic.description,
|
|
10
|
+
examplesChanged: examplesAdded.length > 0 || examplesRemoved.length > 0,
|
|
11
|
+
examplesAdded,
|
|
12
|
+
examplesRemoved,
|
|
13
|
+
descriptionBefore: from.topic.description,
|
|
14
|
+
descriptionAfter: to.topic.description,
|
|
15
|
+
metricDelta: {
|
|
16
|
+
coverage: to.metrics.coverage - from.metrics.coverage,
|
|
17
|
+
tpr: to.metrics.truePositiveRate - from.metrics.truePositiveRate,
|
|
18
|
+
tnr: to.metrics.trueNegativeRate - from.metrics.trueNegativeRate,
|
|
19
|
+
accuracy: to.metrics.accuracy - from.metrics.accuracy,
|
|
20
|
+
f1: to.metrics.f1Score - from.metrics.f1Score,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/memory/diff.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,oBAAoB,CAAC,IAAqB,EAAE,EAAmB;IAC7E,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,KAAK,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|
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
import type { RunState } from '../core/types.js';
|
|
3
|
+
import { type MemoryStore } from './store.js';
|
|
4
|
+
import type { Learning } from './types.js';
|
|
5
|
+
export declare class LearningExtractor {
|
|
6
|
+
private model;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(model: BaseChatModel, store: MemoryStore);
|
|
9
|
+
extractAndSave(runState: RunState): Promise<{
|
|
10
|
+
learnings: Learning[];
|
|
11
|
+
}>;
|
|
12
|
+
private mergeLearnings;
|
|
13
|
+
private formatIterationHistory;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/memory/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAExD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,KAAK;gBADL,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,WAAW;IAGtB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;IAoF5E,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,sBAAsB;CAkC/B"}
|