@anvia/core 0.22.0 → 0.23.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";
@@ -49,10 +49,30 @@ type EvalCase<Input, Expected = unknown> = {
49
49
  id: string;
50
50
  input: Input;
51
51
  expected?: Expected | undefined;
52
+ context?: string[] | undefined;
53
+ retrievalContext?: string[] | undefined;
54
+ metadata?: EvalMetadata | undefined;
55
+ };
56
+ type EvalTurn = {
57
+ role: "user" | "assistant";
58
+ content: string;
52
59
  metadata?: EvalMetadata | undefined;
53
60
  };
61
+ type EvalTraceRef = {
62
+ traceId: string;
63
+ observationId?: string | undefined;
64
+ responseId?: string | undefined;
65
+ };
54
66
  type EvalTarget<Input, Output, Expected = unknown> = (input: Input, testCase: EvalCase<Input, Expected>) => Output | Promise<Output>;
55
67
  type EvalOutcomeStatus = "pass" | "fail" | "invalid";
68
+ type EvalScoreProjection = {
69
+ outcome: EvalOutcomeStatus;
70
+ value: number | string;
71
+ numericValue?: number | undefined;
72
+ categoricalValue?: string | undefined;
73
+ label: string;
74
+ explanation?: string | undefined;
75
+ };
56
76
  type EvalMetricArgs<Input, Output, Expected = unknown> = {
57
77
  suiteName: string;
58
78
  case: EvalCase<Input, Expected>;
@@ -90,9 +110,17 @@ type EvalReportArgs<Input, Output, Score = unknown, Expected = unknown> = {
90
110
  case: EvalCase<Input, Expected>;
91
111
  output?: Output | undefined;
92
112
  targetError?: unknown;
113
+ trace?: EvalTraceRef | undefined;
93
114
  metric: EvalMetric<Input, Output, Score, Expected>;
94
115
  outcome: EvalOutcome<Score>;
95
116
  };
117
+ type EvalTraceSelectorArgs<Input, Output, Expected = unknown> = {
118
+ suiteName: string;
119
+ case: EvalCase<Input, Expected>;
120
+ output?: Output | undefined;
121
+ targetError?: unknown;
122
+ };
123
+ type EvalTraceSelector<Input, Output, Expected = unknown> = (args: EvalTraceSelectorArgs<Input, Output, Expected>) => EvalTraceRef | undefined | Promise<EvalTraceRef | undefined>;
96
124
  type EvalReporter<Input = unknown, Output = unknown, Expected = unknown> = {
97
125
  report(args: EvalReportArgs<Input, Output, unknown, Expected>): void | Promise<void>;
98
126
  };
@@ -102,12 +130,90 @@ type RunEvalSuiteOptions<Input, Output, Expected = unknown> = {
102
130
  target: EvalTarget<Input, Output, Expected>;
103
131
  metrics: Array<EvalMetric<NoInfer<Input>, NoInfer<Output>, unknown, NoInfer<Expected>>>;
104
132
  concurrency?: number | undefined;
133
+ trace?: EvalTraceSelector<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>> | undefined;
105
134
  reporters?: Array<EvalReporter<NoInfer<Input>, NoInfer<Output>, NoInfer<Expected>>> | undefined;
106
135
  failOnReporterError?: boolean | undefined;
107
136
  };
108
137
  type ValueSelector<Input, Output, Expected, Value> = (args: EvalMetricArgs<Input, Output, Expected>) => Value | Promise<Value>;
109
138
  type SelectorOrValue<Input, Output, Expected, Value> = Value | ValueSelector<Input, Output, Expected, Value>;
110
139
 
140
+ type LlmEvalOptions<Input, Output, Expected = unknown> = {
141
+ name?: string | undefined;
142
+ model: CompletionModel;
143
+ threshold?: number | undefined;
144
+ strictMode?: boolean | undefined;
145
+ includeReason?: boolean | undefined;
146
+ retries?: number | undefined;
147
+ input?: ValueSelector<Input, Output, Expected, string> | undefined;
148
+ actual?: ValueSelector<Input, Output, Expected, string> | undefined;
149
+ };
150
+ type AnswerRelevancyOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected>;
151
+ declare function answerRelevancy<Input, Output, Expected = unknown>(options: AnswerRelevancyOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
152
+ type PromptAlignmentOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
153
+ promptInstructions: string[];
154
+ };
155
+ declare function promptAlignment<Input, Output, Expected = unknown>(options: PromptAlignmentOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
156
+ type JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected = unknown> = {
157
+ name?: string | undefined;
158
+ schema: ZodSchema<SchemaOutput>;
159
+ model?: CompletionModel | undefined;
160
+ threshold?: number | undefined;
161
+ strictMode?: boolean | undefined;
162
+ includeReason?: boolean | undefined;
163
+ retries?: number | undefined;
164
+ actual?: ValueSelector<Input, Output, Expected, string> | undefined;
165
+ };
166
+ declare function jsonCorrectness<Input, Output, SchemaOutput, Expected = unknown>(options: JsonCorrectnessOptions<Input, Output, SchemaOutput, Expected>): EvalMetric<Input, Output, number, Expected>;
167
+ type HallucinationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
168
+ context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
169
+ };
170
+ declare function hallucination<Input, Output, Expected = unknown>(options: HallucinationOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
171
+ type FaithfulnessOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
172
+ retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
173
+ truthsExtractionLimit?: number | undefined;
174
+ penalizeAmbiguousClaims?: boolean | undefined;
175
+ };
176
+ declare function faithfulness<Input, Output, Expected = unknown>(options: FaithfulnessOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
177
+ type SummarizationOptions<Input, Output, Expected = unknown> = LlmEvalOptions<Input, Output, Expected> & {
178
+ assessmentQuestions?: string[] | undefined;
179
+ questionCount?: number | undefined;
180
+ truthsExtractionLimit?: number | undefined;
181
+ };
182
+ declare function summarization<Input, Output, Expected = unknown>(options: SummarizationOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
183
+ type GEvalParameter = "input" | "actualOutput" | "expectedOutput" | "context" | "retrievalContext" | "metadata";
184
+ type GEvalRubric = {
185
+ scoreRange: readonly [number, number];
186
+ expectedOutcome: string;
187
+ };
188
+ type GEvalOptions<Input, Output, Expected = unknown> = Omit<LlmEvalOptions<Input, Output, Expected>, "name"> & {
189
+ name: string;
190
+ evaluationParams: GEvalParameter[];
191
+ criteria?: string | undefined;
192
+ evaluationSteps?: string[] | undefined;
193
+ rubric?: GEvalRubric[] | undefined;
194
+ expected?: ValueSelector<Input, Output, Expected, unknown> | undefined;
195
+ context?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
196
+ retrievalContext?: SelectorOrValue<Input, Output, Expected, string[]> | undefined;
197
+ };
198
+ declare function gEval<Input, Output, Expected = unknown>(options: GEvalOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
199
+ type ConversationEvalOptions<Input, Output, Expected = unknown> = {
200
+ name?: string | undefined;
201
+ model: CompletionModel;
202
+ threshold?: number | undefined;
203
+ strictMode?: boolean | undefined;
204
+ includeReason?: boolean | undefined;
205
+ retries?: number | undefined;
206
+ concurrency?: number | undefined;
207
+ turns?: ValueSelector<Input, Output, Expected, ConversationSource> | undefined;
208
+ };
209
+ type TurnRelevancyOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected> & {
210
+ windowSize?: number | undefined;
211
+ };
212
+ declare function turnRelevancy<Input, Output, Expected = unknown>(options: TurnRelevancyOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
213
+ type KnowledgeRetentionOptions<Input, Output, Expected = unknown> = ConversationEvalOptions<Input, Output, Expected>;
214
+ declare function knowledgeRetention<Input, Output, Expected = unknown>(options: KnowledgeRetentionOptions<Input, Output, Expected>): EvalMetric<Input, Output, number, Expected>;
215
+ type ConversationSource = EvalTurn[] | Message[];
216
+
111
217
  type AgentEvalTargetOptions<Input, Output = PromptResponse> = {
112
218
  prompt?: ((input: Input, testCase: EvalCase<Input>) => string | Message) | undefined;
113
219
  output?: ((response: PromptResponse, testCase: EvalCase<Input>) => Output) | undefined;
@@ -162,6 +268,14 @@ type LlmScoreOptions<Input, Output, Expected = unknown> = {
162
268
  };
163
269
  declare function llmScore<Input, Output, Expected = unknown>(options: LlmScoreOptions<Input, Output, Expected>): EvalMetric<Input, Output, LlmScoreMetricScore, Expected>;
164
270
 
271
+ declare function projectEvalOutcome(outcome: EvalOutcome, dataType: EvalMetric<unknown, unknown>["dataType"]): EvalScoreProjection;
272
+ declare function resolveEvalTraceRef(args: {
273
+ output?: unknown;
274
+ input?: unknown;
275
+ metadata?: EvalMetadata | undefined;
276
+ }): EvalTraceRef | undefined;
277
+ declare function defaultEvalTraceSelector<Input, Output, Expected>(args: EvalTraceSelectorArgs<Input, Output, Expected>): EvalTraceRef | undefined;
278
+
165
279
  declare function runEvalSuite<Input, Output, Expected = unknown>(options: RunEvalSuiteOptions<Input, Output, Expected>): Promise<EvalSuiteResult<Input, Output, Expected>>;
166
280
 
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 };
281
+ 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 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 };