@anvia/core 0.22.0 → 0.24.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.
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "../chunk-4HWN7734.js";
4
- import "../chunk-YEBIVZM2.js";
5
- import "../chunk-VXONXP2G.js";
3
+ } from "../chunk-JI5YZWNT.js";
4
+ import "../chunk-DALYP4PX.js";
5
+ import "../chunk-BALBBVI3.js";
6
6
  import "../chunk-YK4WAAS4.js";
7
7
  import "../chunk-XUUY2L2D.js";
8
- import "../chunk-2NDQHV7V.js";
9
- import "../chunk-4BGN6PYF.js";
8
+ import "../chunk-HYUYZEAJ.js";
9
+ import "../chunk-MELYDKWQ.js";
10
10
  import "../chunk-2ODTMRHP.js";
11
11
  import "../chunk-UQX6EXWG.js";
12
12
  import "../chunk-MRQLEK2B.js";
13
+ import "../chunk-MNWK2USR.js";
14
+ import "../chunk-OIMLU4SF.js";
13
15
  import "../chunk-Q25IWLBT.js";
14
16
  import "../chunk-MC3CCKEB.js";
15
17
  import "../chunk-ADH7NNCS.js";
16
18
  import "../chunk-WQKHFADH.js";
17
- import "../chunk-MNWK2USR.js";
18
- import "../chunk-OIMLU4SF.js";
19
19
  import "../chunk-CWUJUSOS.js";
20
20
  export {
21
21
  AgentBuilder
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  parseToolArgs,
6
6
  toolResultContentToText
7
- } from "./chunk-2NDQHV7V.js";
7
+ } from "./chunk-HYUYZEAJ.js";
8
8
  import {
9
9
  runControl,
10
10
  toolCallControl
@@ -15,6 +15,9 @@ import {
15
15
  createMemoryCompactionSummary,
16
16
  cumulativeCompactedMessageCount
17
17
  } from "./chunk-MRQLEK2B.js";
18
+ import {
19
+ mapWithConcurrency
20
+ } from "./chunk-OIMLU4SF.js";
18
21
  import {
19
22
  CompletionRequestBuilder
20
23
  } from "./chunk-Q25IWLBT.js";
@@ -30,9 +33,6 @@ import {
30
33
  getAssistantGenerationMetadata,
31
34
  textFromAssistantContent
32
35
  } from "./chunk-ADH7NNCS.js";
33
- import {
34
- mapWithConcurrency
35
- } from "./chunk-OIMLU4SF.js";
36
36
  import {
37
37
  appendGuardrailPolicies,
38
38
  hasEnforcedOutputGuardrails,
@@ -2729,4 +2729,4 @@ export {
2729
2729
  extractRagText,
2730
2730
  PromptRequest
2731
2731
  };
2732
- //# sourceMappingURL=chunk-VXONXP2G.js.map
2732
+ //# sourceMappingURL=chunk-BALBBVI3.js.map
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  PromptRequest
3
- } from "./chunk-VXONXP2G.js";
3
+ } from "./chunk-BALBBVI3.js";
4
4
  import {
5
5
  isSkillTool
6
6
  } from "./chunk-YK4WAAS4.js";
7
7
  import {
8
8
  ToolSet
9
- } from "./chunk-2NDQHV7V.js";
9
+ } from "./chunk-HYUYZEAJ.js";
10
10
  import {
11
11
  createTool
12
- } from "./chunk-4BGN6PYF.js";
12
+ } from "./chunk-MELYDKWQ.js";
13
13
  import {
14
14
  isStreamingCompletionModel
15
15
  } from "./chunk-MC3CCKEB.js";
@@ -222,4 +222,4 @@ export {
222
222
  Agent,
223
223
  AgentSession
224
224
  };
225
- //# sourceMappingURL=chunk-YEBIVZM2.js.map
225
+ //# sourceMappingURL=chunk-DALYP4PX.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  InMemoryVectorStore,
3
3
  createTool
4
- } from "./chunk-4BGN6PYF.js";
4
+ } from "./chunk-MELYDKWQ.js";
5
+ import {
6
+ embedDocuments
7
+ } from "./chunk-MNWK2USR.js";
5
8
  import {
6
9
  isToolResultContentArray,
7
10
  serializeToolResultOutput
8
11
  } from "./chunk-ADH7NNCS.js";
9
- import {
10
- embedDocuments
11
- } from "./chunk-MNWK2USR.js";
12
12
 
13
13
  // src/tool/errors.ts
14
14
  var ToolCallError = class extends Error {
@@ -220,4 +220,4 @@ export {
220
220
  createMiddleware,
221
221
  createThinkTool
222
222
  };
223
- //# sourceMappingURL=chunk-2NDQHV7V.js.map
223
+ //# sourceMappingURL=chunk-HYUYZEAJ.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Agent,
3
3
  normalizeAgentId
4
- } from "./chunk-YEBIVZM2.js";
4
+ } from "./chunk-DALYP4PX.js";
5
5
  import {
6
6
  ToolSet
7
- } from "./chunk-2NDQHV7V.js";
7
+ } from "./chunk-HYUYZEAJ.js";
8
8
  import {
9
9
  resolveMemoryOptions
10
10
  } from "./chunk-UQX6EXWG.js";
@@ -217,4 +217,4 @@ var AgentBuilder = class {
217
217
  export {
218
218
  AgentBuilder
219
219
  };
220
- //# sourceMappingURL=chunk-4HWN7734.js.map
220
+ //# sourceMappingURL=chunk-JI5YZWNT.js.map
@@ -1,10 +1,10 @@
1
- import {
2
- toProviderJsonSchema
3
- } from "./chunk-WQKHFADH.js";
4
1
  import {
5
2
  cosineSimilarity,
6
3
  embedText
7
4
  } from "./chunk-MNWK2USR.js";
5
+ import {
6
+ toProviderJsonSchema
7
+ } from "./chunk-WQKHFADH.js";
8
8
 
9
9
  // src/vector-store/index.ts
10
10
  import { z } from "zod";
@@ -334,4 +334,4 @@ export {
334
334
  InMemoryVectorIndex,
335
335
  createVectorSearchTool
336
336
  };
337
- //# sourceMappingURL=chunk-4BGN6PYF.js.map
337
+ //# sourceMappingURL=chunk-MELYDKWQ.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-YK4WAAS4.js";
7
7
  import {
8
8
  createTool
9
- } from "./chunk-4BGN6PYF.js";
9
+ } from "./chunk-MELYDKWQ.js";
10
10
 
11
11
  // src/skills/instructions.ts
12
12
  function skillInstructions(skills) {
@@ -395,4 +395,4 @@ export {
395
395
  SkillValidationError,
396
396
  skill
397
397
  };
398
- //# sourceMappingURL=chunk-BCA4VZ5W.js.map
398
+ //# sourceMappingURL=chunk-NCPN4SJR.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "./chunk-4HWN7734.js";
3
+ } from "./chunk-JI5YZWNT.js";
4
4
  import {
5
5
  extractRagText
6
- } from "./chunk-VXONXP2G.js";
6
+ } from "./chunk-BALBBVI3.js";
7
7
  import {
8
8
  createTool
9
- } from "./chunk-4BGN6PYF.js";
9
+ } from "./chunk-MELYDKWQ.js";
10
10
  import {
11
11
  CompletionRequestBuilder
12
12
  } from "./chunk-Q25IWLBT.js";
@@ -138,4 +138,4 @@ export {
138
138
  Extractor,
139
139
  ExtractorBuilder
140
140
  };
141
- //# sourceMappingURL=chunk-KYEBWN3E.js.map
141
+ //# sourceMappingURL=chunk-YLMDBQO4.js.map
@@ -1,15 +1,15 @@
1
+ import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
2
+ import { l as JsonValue, C as CompletionModel, M as Message } from '../types-G12i56s2.js';
1
3
  import { A as Agent } from '../agent-x3YTyv5i.js';
2
- import { l as JsonValue, M as Message, C as CompletionModel } from '../types-G12i56s2.js';
3
4
  import { P as PromptResponse } from '../index-BxSbmOMr.js';
4
- import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
5
5
  import { E as EmbeddingModel } from '../types-BCTRUGex.js';
6
+ import 'zod';
6
7
  import '../guardrails/index.js';
7
8
  import '../types-D9JpeAPF.js';
8
9
  import '../types-BrLbKnEz.js';
9
10
  import '../tool-Cohdv5GC.js';
10
11
  import '../middleware-Dp3d_pxi.js';
11
12
  import '../types-O-abTIin.js';
12
- import 'zod';
13
13
 
14
14
  type EvalOutcome<Score = unknown> = {
15
15
  outcome: "pass";
@@ -45,14 +45,47 @@ declare const EvalOutcome: {
45
45
  };
46
46
 
47
47
  type EvalMetadata = Record<string, JsonValue | undefined>;
48
+ type EvalRunOptions = {
49
+ id?: string | undefined;
50
+ datasetName?: string | undefined;
51
+ datasetVersion?: string | undefined;
52
+ metadata?: EvalMetadata | undefined;
53
+ };
54
+ type EvalRunContext = {
55
+ id: string;
56
+ startedAt: string;
57
+ datasetName?: string | undefined;
58
+ datasetVersion?: string | undefined;
59
+ metadata?: EvalMetadata | undefined;
60
+ };
48
61
  type EvalCase<Input, Expected = unknown> = {
49
62
  id: string;
50
63
  input: Input;
51
64
  expected?: Expected | undefined;
65
+ context?: string[] | undefined;
66
+ retrievalContext?: string[] | undefined;
67
+ metadata?: EvalMetadata | undefined;
68
+ };
69
+ type EvalTurn = {
70
+ role: "user" | "assistant";
71
+ content: string;
52
72
  metadata?: EvalMetadata | undefined;
53
73
  };
74
+ type EvalTraceRef = {
75
+ traceId: string;
76
+ observationId?: string | undefined;
77
+ responseId?: string | undefined;
78
+ };
54
79
  type EvalTarget<Input, Output, Expected = unknown> = (input: Input, testCase: EvalCase<Input, Expected>) => Output | Promise<Output>;
55
80
  type EvalOutcomeStatus = "pass" | "fail" | "invalid";
81
+ type EvalScoreProjection = {
82
+ outcome: EvalOutcomeStatus;
83
+ value: number | string;
84
+ numericValue?: number | undefined;
85
+ categoricalValue?: string | undefined;
86
+ label: string;
87
+ explanation?: string | undefined;
88
+ };
56
89
  type EvalMetricArgs<Input, Output, Expected = unknown> = {
57
90
  suiteName: string;
58
91
  case: EvalCase<Input, Expected>;
@@ -79,35 +112,144 @@ type EvalCaseResult<Input, Output, Expected = unknown> = {
79
112
  };
80
113
  type EvalSuiteResult<Input, Output, Expected = unknown> = {
81
114
  name: string;
115
+ run: EvalRunContext & {
116
+ completedAt: string;
117
+ };
82
118
  results: Array<EvalCaseResult<Input, Output, Expected>>;
83
119
  passed: number;
84
120
  failed: number;
85
121
  invalid: number;
86
122
  durationMs: number;
123
+ reporterErrors: unknown[];
87
124
  };
88
125
  type EvalReportArgs<Input, Output, Score = unknown, Expected = unknown> = {
126
+ run?: EvalRunContext | undefined;
89
127
  suiteName: string;
90
128
  case: EvalCase<Input, Expected>;
91
129
  output?: Output | undefined;
92
130
  targetError?: unknown;
131
+ trace?: EvalTraceRef | undefined;
93
132
  metric: EvalMetric<Input, Output, Score, Expected>;
94
133
  outcome: EvalOutcome<Score>;
95
134
  };
135
+ type EvalRunStartArgs = {
136
+ run: EvalRunContext;
137
+ suiteName: string;
138
+ caseCount: number;
139
+ metricNames: string[];
140
+ };
141
+ type EvalRunEndArgs = EvalRunStartArgs & {
142
+ status: "completed" | "failed";
143
+ completedAt: string;
144
+ durationMs: number;
145
+ passed?: number | undefined;
146
+ failed?: number | undefined;
147
+ invalid?: number | undefined;
148
+ error?: unknown;
149
+ };
150
+ type EvalTraceSelectorArgs<Input, Output, Expected = unknown> = {
151
+ suiteName: string;
152
+ case: EvalCase<Input, Expected>;
153
+ output?: Output | undefined;
154
+ targetError?: unknown;
155
+ };
156
+ type EvalTraceSelector<Input, Output, Expected = unknown> = (args: EvalTraceSelectorArgs<Input, Output, Expected>) => EvalTraceRef | undefined | Promise<EvalTraceRef | undefined>;
96
157
  type EvalReporter<Input = unknown, Output = unknown, Expected = unknown> = {
158
+ onRunStart?(args: EvalRunStartArgs): void | Promise<void>;
97
159
  report(args: EvalReportArgs<Input, Output, unknown, Expected>): void | Promise<void>;
160
+ onRunEnd?(args: EvalRunEndArgs): void | Promise<void>;
98
161
  };
99
162
  type RunEvalSuiteOptions<Input, Output, Expected = unknown> = {
100
163
  name: string;
164
+ run?: EvalRunOptions | undefined;
101
165
  cases: Array<EvalCase<Input, Expected>>;
102
166
  target: EvalTarget<Input, Output, Expected>;
103
167
  metrics: Array<EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>>>;
104
168
  concurrency?: number | undefined;
169
+ trace?: EvalTraceSelector<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>> | undefined;
105
170
  reporters?: Array<EvalReporter<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>>> | undefined;
106
171
  failOnReporterError?: boolean | undefined;
107
172
  };
108
173
  type ValueSelector<Input, Output, Expected, Value> = (args: EvalMetricArgs<Input, Output, Expected>) => Value | Promise<Value>;
109
174
  type SelectorOrValue<Input, Output, Expected, Value> = Value | ValueSelector<Input, Output, Expected, Value>;
110
175
 
176
+ type LlmEvalOptions<Input, Output, Expected = unknown> = {
177
+ name?: string | undefined;
178
+ model: CompletionModel;
179
+ threshold?: number | undefined;
180
+ strictMode?: boolean | undefined;
181
+ includeReason?: boolean | undefined;
182
+ retries?: number | undefined;
183
+ input?: ValueSelector<Input, Output, Expected, string> | undefined;
184
+ actual?: ValueSelector<Input, Output, Expected, string> | undefined;
185
+ };
186
+ type AnswerRelevancyOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected>;
187
+ declare function answerRelevancy<Input, Output, Expected = unknown>(options: AnswerRelevancyOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
188
+ type PromptAlignmentOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
189
+ promptInstructions: string[];
190
+ };
191
+ declare function promptAlignment<Input, Output, Expected = unknown>(options: PromptAlignmentOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
192
+ type JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected = unknown> = {
193
+ name?: string | undefined;
194
+ schema: ZodSchema<SchemaOutput>;
195
+ model?: CompletionModel | undefined;
196
+ threshold?: number | undefined;
197
+ strictMode?: boolean | undefined;
198
+ includeReason?: boolean | undefined;
199
+ retries?: number | undefined;
200
+ actual?: ValueSelector<Input, Output, Expected, string> | undefined;
201
+ };
202
+ declare function jsonCorrectness<Input, Output, SchemaOutput, Expected = unknown>(options: JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected>): EvalMetric<Input, Output, number, Expected>;
203
+ type HallucinationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
204
+ context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
205
+ };
206
+ declare function hallucination<Input, Output, Expected = unknown>(options: HallucinationOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
207
+ type FaithfulnessOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
208
+ retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
209
+ truthsExtractionLimit?: number | undefined;
210
+ penalizeAmbiguousClaims?: boolean | undefined;
211
+ };
212
+ declare function faithfulness<Input, Output, Expected = unknown>(options: FaithfulnessOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
213
+ type SummarizationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
214
+ assessmentQuestions?: string[] | undefined;
215
+ questionCount?: number | undefined;
216
+ truthsExtractionLimit?: number | undefined;
217
+ };
218
+ declare function summarization<Input, Output, Expected = unknown>(options: SummarizationOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
219
+ type GEvalParameter = "input" | "actualOutput" | "expectedOutput" | "context" | "retrievalContext" | "metadata";
220
+ type GEvalRubric = {
221
+ scoreRange: readonly [number, number];
222
+ expectedOutcome: string;
223
+ };
224
+ type GEvalOptions<Input, Output, Expected = unknown> = Omit<LlmEvalOptions<Input, Output, Expected>, "name"> & {
225
+ name: string;
226
+ evaluationParams: GEvalParameter[];
227
+ criteria?: string | undefined;
228
+ evaluationSteps?: string[] | undefined;
229
+ rubric?: GEvalRubric[] | undefined;
230
+ expected?: ValueSelector<Input, Output, Expected, unknown> | undefined;
231
+ context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
232
+ retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
233
+ };
234
+ declare function gEval<Input, Output, Expected = unknown>(options: GEvalOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
235
+ type ConversationEvalOptions<Input, Output, Expected = unknown> = {
236
+ name?: string | undefined;
237
+ model: CompletionModel;
238
+ threshold?: number | undefined;
239
+ strictMode?: boolean | undefined;
240
+ includeReason?: boolean | undefined;
241
+ retries?: number | undefined;
242
+ concurrency?: number | undefined;
243
+ turns?: ValueSelector<Input, Output, Expected, ConversationSource> | undefined;
244
+ };
245
+ type TurnRelevancyOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected> & {
246
+ windowSize?: number | undefined;
247
+ };
248
+ declare function turnRelevancy<Input, Output, Expected = unknown>(options: TurnRelevancyOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
249
+ type KnowledgeRetentionOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected>;
250
+ declare function knowledgeRetention<Input, Output, Expected = unknown>(options: KnowledgeRetentionOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
251
+ type ConversationSource = EvalTurn[] | Message[];
252
+
111
253
  type AgentEvalTargetOptions<Input, Output = PromptResponse> = {
112
254
  prompt?: ((input: Input, testCase: EvalCase<Input>) => string | Message) | undefined;
113
255
  output?: ((response: PromptResponse, testCase: EvalCase<Input>) => Output) | undefined;
@@ -162,6 +304,14 @@ type LlmScoreOptions<Input, Output, Expected = unknown> = {
162
304
  };
163
305
  declare function llmScore<Input, Output, Expected = unknown>(options: LlmScoreOptions<Input, Output, Expected>): EvalMetric<Input, Output, LlmScoreMetricScore, Expected>;
164
306
 
307
+ declare function projectEvalOutcome(outcome: EvalOutcome, dataType: EvalMetric<unknown, unknown>["dataType"]): EvalScoreProjection;
308
+ declare function resolveEvalTraceRef(args: {
309
+ output?: unknown;
310
+ input?: unknown;
311
+ metadata?: EvalMetadata | undefined;
312
+ }): EvalTraceRef | undefined;
313
+ declare function defaultEvalTraceSelector<Input, Output, Expected>(args: EvalTraceSelectorArgs<Input, Output, Expected>): EvalTraceRef | undefined;
314
+
165
315
  declare function runEvalSuite<Input, Output, Expected = unknown>(options: RunEvalSuiteOptions<Input, Output, Expected>): Promise<EvalSuiteResult<Input, Output, Expected>>;
166
316
 
167
- export { type AgentEvalTargetOptions, type ContainsOptions, type EvalCase, type EvalCaseResult, type EvalMetadata, type EvalMetric, type EvalMetricArgs, type EvalMetricResult, EvalOutcome, type EvalOutcomeStatus, type EvalReportArgs, type EvalReporter, type EvalSuiteResult, type EvalTarget, type ExactMatchOptions, type LlmJudgeOptions, type LlmScoreMetricScore, type LlmScoreOptions, type RunEvalSuiteOptions, type SelectorOrValue, type SemanticSimilarityOptions, type ValueSelector, agentEvalTarget, contains, defineMetric, exactMatch, llmJudge, llmScore, runEvalSuite, semanticSimilarity };
317
+ export { type AgentEvalTargetOptions, type AnswerRelevancyOptions, type ContainsOptions, type EvalCase, type EvalCaseResult, type EvalMetadata, type EvalMetric, type EvalMetricArgs, type EvalMetricResult, EvalOutcome, type EvalOutcomeStatus, type EvalReportArgs, type EvalReporter, type EvalRunContext, type EvalRunEndArgs, type EvalRunOptions, type EvalRunStartArgs, type EvalScoreProjection, type EvalSuiteResult, type EvalTarget, type EvalTraceRef, type EvalTraceSelector, type EvalTraceSelectorArgs, type EvalTurn, type ExactMatchOptions, type FaithfulnessOptions, type GEvalOptions, type GEvalParameter, type GEvalRubric, type HallucinationOptions, type JsonCorrectnessOptions, type KnowledgeRetentionOptions, type LlmJudgeOptions, type LlmScoreMetricScore, type LlmScoreOptions, type PromptAlignmentOptions, type RunEvalSuiteOptions, type SelectorOrValue, type SemanticSimilarityOptions, type SummarizationOptions, type TurnRelevancyOptions, type ValueSelector, agentEvalTarget, answerRelevancy, contains, defaultEvalTraceSelector, defineMetric, exactMatch, faithfulness, gEval, hallucination, jsonCorrectness, knowledgeRetention, llmJudge, llmScore, projectEvalOutcome, promptAlignment, resolveEvalTraceRef, runEvalSuite, semanticSimilarity, summarization, turnRelevancy };