@anvia/core 0.21.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.
- package/dist/agent/index.d.ts +11 -11
- package/dist/agent/index.js +9 -9
- package/dist/{agent-Q7FT1xmG.d.ts → agent-x3YTyv5i.d.ts} +8 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-PJDL5UT2.js → chunk-ADH7NNCS.js} +63 -1
- package/dist/chunk-ADH7NNCS.js.map +1 -0
- package/dist/{chunk-3IYTCGHS.js → chunk-BALBBVI3.js} +14 -7
- package/dist/{chunk-3IYTCGHS.js.map → chunk-BALBBVI3.js.map} +1 -1
- package/dist/{chunk-N3YV3WCO.js → chunk-DALYP4PX.js} +21 -4
- package/dist/chunk-DALYP4PX.js.map +1 -0
- package/dist/{chunk-6X2UTX3L.js → chunk-HYUYZEAJ.js} +2 -2
- package/dist/{chunk-SWUH4G2I.js → chunk-I6XOQ4LK.js} +2 -2
- package/dist/{chunk-WHAPIIEZ.js → chunk-JI5YZWNT.js} +5 -5
- package/dist/{chunk-F56AMXMQ.js → chunk-MC3CCKEB.js} +2 -2
- package/dist/{chunk-TGLNXVII.js → chunk-MRQLEK2B.js} +3 -3
- package/dist/{chunk-MTGNA4OS.js → chunk-Q25IWLBT.js} +2 -2
- package/dist/{chunk-ZNTIUOKL.js → chunk-UQX6EXWG.js} +2 -2
- package/dist/{chunk-ZSTUMG7G.js → chunk-YLMDBQO4.js} +5 -5
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +11 -5
- package/dist/{errors-Bf661V89.d.ts → errors-2moLDuuN.d.ts} +2 -2
- package/dist/evals/index.d.ts +124 -10
- package/dist/evals/index.js +1021 -29
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +8 -8
- package/dist/extractor/index.js +10 -10
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/{index-XTUEMWhU.d.ts → index-BxSbmOMr.d.ts} +4 -2
- package/dist/index.d.ts +13 -13
- package/dist/index.js +18 -12
- package/dist/internal/agent.d.ts +8 -8
- package/dist/internal/agent.js +7 -7
- package/dist/{json-D9IvOgx_.d.ts → json-BVPssigK.d.ts} +1 -1
- package/dist/loaders/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/index.d.ts +4 -4
- package/dist/memory/index.js +4 -4
- package/dist/{middleware-DfMc30in.d.ts → middleware-Dp3d_pxi.d.ts} +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/pipeline/index.d.ts +8 -8
- package/dist/request/index.d.ts +8 -8
- package/dist/request/index.js +6 -6
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +2 -2
- package/dist/{think-tool-CpCKo8Q8.d.ts → think-tool-DfCMuO8e.d.ts} +1 -1
- package/dist/tool/index.d.ts +5 -5
- package/dist/tool/index.js +2 -2
- package/dist/{tool-Dhwg__1L.d.ts → tool-Cohdv5GC.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-fBv8mhvP.d.ts → types-04LqWrmy.d.ts} +1 -1
- package/dist/{types-DBHzPsbx.d.ts → types-BrLbKnEz.d.ts} +1 -1
- package/dist/{types-BCA8p0sb.d.ts → types-D9JpeAPF.d.ts} +1 -1
- package/dist/{types-XjIh933x.d.ts → types-G12i56s2.d.ts} +26 -1
- package/dist/{types-BBEf34DP.d.ts → types-JJCxRnaZ.d.ts} +2 -2
- package/dist/{types-BrxxAtcJ.d.ts → types-O-abTIin.d.ts} +1 -1
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +2 -2
- package/dist/vector-store/index.d.ts +4 -4
- package/package.json +1 -1
- package/dist/chunk-N3YV3WCO.js.map +0 -1
- package/dist/chunk-PJDL5UT2.js.map +0 -1
- /package/dist/{chunk-6X2UTX3L.js.map → chunk-HYUYZEAJ.js.map} +0 -0
- /package/dist/{chunk-SWUH4G2I.js.map → chunk-I6XOQ4LK.js.map} +0 -0
- /package/dist/{chunk-WHAPIIEZ.js.map → chunk-JI5YZWNT.js.map} +0 -0
- /package/dist/{chunk-F56AMXMQ.js.map → chunk-MC3CCKEB.js.map} +0 -0
- /package/dist/{chunk-TGLNXVII.js.map → chunk-MRQLEK2B.js.map} +0 -0
- /package/dist/{chunk-MTGNA4OS.js.map → chunk-Q25IWLBT.js.map} +0 -0
- /package/dist/{chunk-ZNTIUOKL.js.map → chunk-UQX6EXWG.js.map} +0 -0
- /package/dist/{chunk-ZSTUMG7G.js.map → chunk-YLMDBQO4.js.map} +0 -0
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptRequest
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
9
|
+
} from "./chunk-HYUYZEAJ.js";
|
|
10
10
|
import {
|
|
11
11
|
createTool
|
|
12
12
|
} from "./chunk-MELYDKWQ.js";
|
|
13
13
|
import {
|
|
14
14
|
isStreamingCompletionModel
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MC3CCKEB.js";
|
|
16
|
+
import {
|
|
17
|
+
getAssistantGenerationMetadata
|
|
18
|
+
} from "./chunk-ADH7NNCS.js";
|
|
16
19
|
|
|
17
20
|
// src/agent/agent.ts
|
|
18
21
|
import { z } from "zod";
|
|
@@ -186,6 +189,20 @@ var AgentSession = class {
|
|
|
186
189
|
}
|
|
187
190
|
return memory.store.load(this.context);
|
|
188
191
|
}
|
|
192
|
+
async contextUsage() {
|
|
193
|
+
const messages = await this.messages();
|
|
194
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
195
|
+
const message = messages[index];
|
|
196
|
+
if (message === void 0) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const generation = getAssistantGenerationMetadata(message);
|
|
200
|
+
if (generation !== void 0) {
|
|
201
|
+
return generation.contextUsage;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
189
206
|
async clear() {
|
|
190
207
|
const memory = this.agent.memory;
|
|
191
208
|
if (memory === void 0) {
|
|
@@ -205,4 +222,4 @@ export {
|
|
|
205
222
|
Agent,
|
|
206
223
|
AgentSession
|
|
207
224
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-DALYP4PX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/agent.ts","../src/agent/ids.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isStreamingCompletionModel } from \"../completion/create-completion\";\nimport type {\n CompletionModel,\n ContextUsage,\n Document,\n JsonObject,\n JsonValue,\n Message as MessageType,\n ProviderTool,\n ToolChoice,\n} from \"../completion/index\";\nimport { getAssistantGenerationMetadata } from \"../completion/types\";\nimport type { GuardrailPolicy } from \"../guardrails\";\nimport type { PromptHook } from \"../hooks\";\nimport type { MemoryContext, MemoryRegistration, SessionOptions } from \"../memory/types\";\nimport type { AgentObserverRegistration } from \"../observability\";\nimport { PromptRequest } from \"../request\";\nimport { createTool } from \"../tool/create-tool\";\nimport type { ToolSearchDocument } from \"../tool/dynamic-tools\";\nimport type { AgentMiddleware } from \"../tool/middleware\";\nimport { isSkillTool } from \"../tool/skill-tool-marker\";\nimport type {\n AnyTool,\n NormalizedToolOutput,\n Tool,\n ToolApprovalsOptions,\n ToolCallContext,\n ToolCallStreamEvent,\n} from \"../tool/tool\";\nimport { ToolSet } from \"../tool/tool-set\";\nimport type { VectorSearchIndex } from \"../vector-store\";\nimport { normalizeAgentId } from \"./ids\";\nimport type {\n AgentEventStoreRegistration,\n AgentOptions,\n AgentToolOptions,\n DynamicContextRegistration,\n DynamicToolRegistration,\n} from \"./types\";\n\nexport const DEFAULT_MAX_TURNS = 20;\n\nexport class Agent<M extends CompletionModel = CompletionModel> {\n readonly id: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly model: M;\n readonly instructions: string | undefined;\n readonly staticContext: Document[];\n readonly temperature: number | undefined;\n readonly maxTokens: number | undefined;\n readonly additionalParams: JsonValue | undefined;\n readonly toolSet: ToolSet;\n readonly providerTools: ProviderTool[];\n readonly toolChoice: ToolChoice | undefined;\n readonly defaultMaxTurns: number | undefined;\n readonly hook: PromptHook | undefined;\n readonly outputSchema: JsonObject | undefined;\n readonly observers: AgentObserverRegistration[];\n readonly approvals: ToolApprovalsOptions | undefined;\n readonly guardrails: GuardrailPolicy[];\n readonly dynamicContexts: DynamicContextRegistration[];\n readonly dynamicTools: DynamicToolRegistration[];\n readonly middlewares: AgentMiddleware[];\n readonly memory: MemoryRegistration | undefined;\n readonly eventStore: AgentEventStoreRegistration | undefined;\n\n constructor(options: AgentOptions<M>) {\n this.id = normalizeAgentId(options.id);\n this.name = options.name;\n this.description = options.description;\n this.model = options.model;\n this.instructions = options.instructions;\n this.staticContext = [...(options.staticContext ?? [])];\n this.temperature = options.temperature;\n this.maxTokens = options.maxTokens;\n this.additionalParams = options.additionalParams;\n this.toolSet = options.toolSet ?? new ToolSet();\n this.providerTools = [...(options.providerTools ?? [])];\n this.toolChoice = options.toolChoice;\n this.defaultMaxTurns = options.defaultMaxTurns ?? DEFAULT_MAX_TURNS;\n this.hook = options.hook;\n this.outputSchema = options.outputSchema;\n this.observers = [...(options.observers ?? [])];\n this.approvals = options.approvals;\n this.guardrails = [...(options.guardrails ?? [])];\n this.dynamicContexts = [...(options.dynamicContexts ?? [])];\n this.dynamicTools = [...(options.dynamicTools ?? [])];\n this.middlewares = [...(options.middlewares ?? [])];\n this.memory = options.memory;\n this.eventStore = options.eventStore;\n }\n\n prompt(prompt: string | MessageType | MessageType[]): PromptRequest<M> {\n return PromptRequest.fromAgent(this, prompt);\n }\n\n session(sessionId: string, options: SessionOptions = {}): AgentSession<M> {\n if (this.memory === undefined) {\n throw new Error(`Agent \"${this.id}\" has no memory store configured.`);\n }\n const normalized = sessionId.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Session id must be a non-empty string.\");\n }\n const context: MemoryContext = {\n sessionId: normalized,\n };\n if (options.userId !== undefined) {\n context.userId = options.userId;\n }\n if (options.metadata !== undefined) {\n context.metadata = options.metadata;\n }\n return new AgentSession(this, context);\n }\n\n asTool(options: AgentToolOptions): Tool<{ prompt: string }, string> {\n const description =\n options.description ?? this.description ?? `Prompt the ${options.name} agent.`;\n\n return createTool({\n name: options.name,\n description,\n input: z.object({\n prompt: z.string().describe(\"The prompt to send to the agent.\"),\n }),\n output: z.string(),\n execute: async ({ prompt }, context: ToolCallContext) => {\n const request = this.prompt(prompt);\n const childRequest =\n options.maxTurns === undefined ? request : request.maxTurns(options.maxTurns);\n if (\n options.stream === true &&\n context.emitStreamEvent !== undefined &&\n this.model.capabilities.streaming &&\n isStreamingCompletionModel(this.model)\n ) {\n let output = \"\";\n const childStream =\n context.includeToolCallDeltas === false\n ? childRequest.stream({ includeToolCallDeltas: false })\n : childRequest.stream();\n for await (const event of childStream) {\n const streamEvent: ToolCallStreamEvent = {\n agentId: this.id,\n event,\n };\n if (this.name !== undefined) {\n streamEvent.agentName = this.name;\n }\n await context.emitStreamEvent(streamEvent);\n if (event.type === \"final\") {\n output = event.output;\n }\n }\n return output;\n }\n const response = await childRequest.send();\n return response.output;\n },\n });\n }\n\n getTool(toolName: string): AnyTool | undefined {\n const staticTool = this.toolSet.get(toolName);\n if (staticTool !== undefined) {\n return staticTool;\n }\n\n for (const registration of this.dynamicTools) {\n const dynamicTool = dynamicToolSetFromIndex(registration.index)?.get(toolName);\n if (dynamicTool !== undefined) {\n return dynamicTool;\n }\n }\n\n return undefined;\n }\n\n async callTool(\n toolName: string,\n args: string,\n context?: ToolCallContext,\n ): Promise<NormalizedToolOutput> {\n if (this.toolSet.contains(toolName)) {\n return this.toolSet.call(toolName, args, context);\n }\n\n for (const registration of this.dynamicTools) {\n const toolSet = dynamicToolSetFromIndex(registration.index);\n if (toolSet?.contains(toolName)) {\n return toolSet.call(toolName, args, context);\n }\n }\n\n return this.toolSet.call(toolName, args, context);\n }\n\n shouldApplyToolMiddleware(toolName: string): boolean {\n return !isSkillTool(this.getTool(toolName));\n }\n}\n\nexport class AgentSession<M extends CompletionModel = CompletionModel> {\n constructor(\n private readonly agent: Agent<M>,\n private readonly context: {\n sessionId: string;\n userId?: string | undefined;\n metadata?: JsonObject | undefined;\n },\n ) {}\n\n prompt(prompt: string | MessageType): PromptRequest<M> {\n if (Array.isArray(prompt)) {\n throw new TypeError(\"AgentSession.prompt does not accept Message[] transcripts.\");\n }\n return PromptRequest.fromAgent(this.agent, prompt, { memoryContext: this.context });\n }\n\n async messages(): Promise<MessageType[]> {\n const memory = this.agent.memory;\n if (memory === undefined) {\n throw new Error(`Agent \"${this.agent.id}\" has no memory store configured.`);\n }\n return memory.store.load(this.context);\n }\n\n async contextUsage(): Promise<ContextUsage | undefined> {\n const messages = await this.messages();\n for (let index = messages.length - 1; index >= 0; index -= 1) {\n const message = messages[index];\n if (message === undefined) {\n continue;\n }\n const generation = getAssistantGenerationMetadata(message);\n if (generation !== undefined) {\n return generation.contextUsage;\n }\n }\n return undefined;\n }\n\n async clear(): Promise<void> {\n const memory = this.agent.memory;\n if (memory === undefined) {\n throw new Error(`Agent \"${this.agent.id}\" has no memory store configured.`);\n }\n await memory.store.clear(this.context);\n }\n}\n\nfunction dynamicToolSetFromIndex(\n index: VectorSearchIndex<ToolSearchDocument>,\n): ToolSet | undefined {\n const maybeIndex = index as { toolSet?: unknown };\n return maybeIndex.toolSet instanceof ToolSet ? maybeIndex.toolSet : undefined;\n}\n","export function normalizeAgentId(id: string): string {\n if (typeof id !== \"string\") {\n throw new TypeError(\"Agent id must be a string.\");\n }\n\n const normalized = id.trim();\n if (normalized.length === 0)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vC;AACF;AAEA,SAAS,wBACP,OACqB;AACrB,QAAM,aAAa;AACnB,SAAO,WAAW,mBAAmB,UAAU,WAAW,UAAU;AACtE;","names":[]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
isToolResultContentArray,
|
|
10
10
|
serializeToolResultOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ADH7NNCS.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-
|
|
223
|
+
//# sourceMappingURL=chunk-HYUYZEAJ.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isJsonValue,
|
|
7
7
|
reasoningDisplayText,
|
|
8
8
|
serializeToolResultOutput
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ADH7NNCS.js";
|
|
10
10
|
|
|
11
11
|
// src/ui/messages.ts
|
|
12
12
|
function uiMessagesToCoreMessages(messages) {
|
|
@@ -463,4 +463,4 @@ export {
|
|
|
463
463
|
uiMessagesToCoreMessages,
|
|
464
464
|
coreMessagesToUIMessages
|
|
465
465
|
};
|
|
466
|
-
//# sourceMappingURL=chunk-
|
|
466
|
+
//# sourceMappingURL=chunk-I6XOQ4LK.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent,
|
|
3
3
|
normalizeAgentId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DALYP4PX.js";
|
|
5
5
|
import {
|
|
6
6
|
ToolSet
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HYUYZEAJ.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveMemoryOptions
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UQX6EXWG.js";
|
|
11
11
|
import {
|
|
12
12
|
isProviderTool
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ADH7NNCS.js";
|
|
14
14
|
import {
|
|
15
15
|
toProviderJsonSchema
|
|
16
16
|
} from "./chunk-WQKHFADH.js";
|
|
@@ -217,4 +217,4 @@ var AgentBuilder = class {
|
|
|
217
217
|
export {
|
|
218
218
|
AgentBuilder
|
|
219
219
|
};
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
220
|
+
//# sourceMappingURL=chunk-JI5YZWNT.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
assertCompletionRequestSupported,
|
|
4
4
|
isProviderTool,
|
|
5
5
|
textFromAssistantContent
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ADH7NNCS.js";
|
|
7
7
|
import {
|
|
8
8
|
toProviderJsonSchema
|
|
9
9
|
} from "./chunk-WQKHFADH.js";
|
|
@@ -218,4 +218,4 @@ export {
|
|
|
218
218
|
createParsedCompletion,
|
|
219
219
|
isStreamingCompletionModel
|
|
220
220
|
};
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
221
|
+
//# sourceMappingURL=chunk-MC3CCKEB.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCompletion
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MC3CCKEB.js";
|
|
4
4
|
import {
|
|
5
5
|
Message
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ADH7NNCS.js";
|
|
7
7
|
|
|
8
8
|
// src/memory/errors.ts
|
|
9
9
|
var MemoryCompactionError = class extends Error {
|
|
@@ -217,4 +217,4 @@ export {
|
|
|
217
217
|
createMemoryCompactionSummary,
|
|
218
218
|
cumulativeCompactedMessageCount
|
|
219
219
|
};
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
220
|
+
//# sourceMappingURL=chunk-MRQLEK2B.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Message,
|
|
3
3
|
assertCompletionRequestSupported,
|
|
4
4
|
isProviderTool
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ADH7NNCS.js";
|
|
6
6
|
|
|
7
7
|
// src/completion/documents.ts
|
|
8
8
|
function normalizeDocuments(documents) {
|
|
@@ -135,4 +135,4 @@ export {
|
|
|
135
135
|
formatDocument,
|
|
136
136
|
CompletionRequestBuilder
|
|
137
137
|
};
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
138
|
+
//# sourceMappingURL=chunk-Q25IWLBT.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertNonnegativeInteger,
|
|
3
3
|
assertPositiveInteger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MRQLEK2B.js";
|
|
5
5
|
|
|
6
6
|
// src/memory/options.ts
|
|
7
7
|
function resolveMemoryOptions(options = {}) {
|
|
@@ -30,4 +30,4 @@ function resolveMemoryOptions(options = {}) {
|
|
|
30
30
|
export {
|
|
31
31
|
resolveMemoryOptions
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-UQX6EXWG.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JI5YZWNT.js";
|
|
4
4
|
import {
|
|
5
5
|
extractRagText
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BALBBVI3.js";
|
|
7
7
|
import {
|
|
8
8
|
createTool
|
|
9
9
|
} from "./chunk-MELYDKWQ.js";
|
|
10
10
|
import {
|
|
11
11
|
CompletionRequestBuilder
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q25IWLBT.js";
|
|
13
13
|
import {
|
|
14
14
|
CompletionCapabilityError,
|
|
15
15
|
Message,
|
|
16
16
|
Usage
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ADH7NNCS.js";
|
|
18
18
|
|
|
19
19
|
// src/extractor/extractor.ts
|
|
20
20
|
var SUBMIT_TOOL_NAME = "submit";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
Extractor,
|
|
139
139
|
ExtractorBuilder
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-YLMDBQO4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue, k as isStreamingCompletionModel } from '../json-
|
|
2
|
-
import { D as Document, M as Message, C as CompletionModel,
|
|
3
|
-
export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions,
|
|
1
|
+
export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue, k as isStreamingCompletionModel } from '../json-BVPssigK.js';
|
|
2
|
+
import { D as Document, M as Message, C as CompletionModel, i as CompletionTool, L as ToolChoice, l as JsonValue, J as JsonObject, f as CompletionRequest, g as CompletionResponse } from '../types-G12i56s2.js';
|
|
3
|
+
export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, N as CompletionCapabilityError, O as CompletionModelCapabilities, d as CompletionModelInfo, e as CompletionModelMetadataOptions, h as CompletionSource, Q as CompletionStreamEvent, j as ContextUsage, R as DocumentContent, I as ImageContent, V as ImageDetail, k as JsonPrimitive, m as MessageOptions, n as ModelContextLimits, P as ProviderTool, o as ProviderToolCall, W as Reasoning, X as ReasoningContent, Y as ReasoningContentType, Z as StreamingCompletionModel, S as SystemMessage, T as Text, p as ToolCall, _ as ToolCallArgumentsMode, q as ToolContent, r as ToolDefinition, $ as ToolFunction, s as ToolMessage, t as ToolResult, u as ToolResultContent, v as ToolResultMessageOptions, w as ToolResultOptions, U as Usage, a0 as UsageDetails, x as UserContent, y as UserMessage, a1 as assertCompletionRequestSupported, z as calculateContextUsage, B as getAssistantGenerationMetadata, E as isProviderTool, H as isToolResultContentArray, a2 as reasoningDisplayText, F as resolveCompletionModelInfo, K as serializeToolResultOutput, a3 as textFromAssistantContent, G as withContextUsage } from '../types-G12i56s2.js';
|
|
4
4
|
import '../zod-schema-C7F4clpm.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
package/dist/completion/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
CompletionRequestBuilder,
|
|
3
3
|
formatDocument,
|
|
4
4
|
normalizeDocuments
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-Q25IWLBT.js";
|
|
6
6
|
import {
|
|
7
7
|
createCompletion,
|
|
8
8
|
createCompletionStream,
|
|
9
9
|
createParsedCompletion,
|
|
10
10
|
isStreamingCompletionModel
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-MC3CCKEB.js";
|
|
12
12
|
import {
|
|
13
13
|
AssistantContent,
|
|
14
14
|
CompletionCapabilityError,
|
|
@@ -17,14 +17,17 @@ import {
|
|
|
17
17
|
Usage,
|
|
18
18
|
UserContent,
|
|
19
19
|
assertCompletionRequestSupported,
|
|
20
|
+
calculateContextUsage,
|
|
20
21
|
getAssistantGenerationMetadata,
|
|
21
22
|
isJsonValue,
|
|
22
23
|
isProviderTool,
|
|
23
24
|
isToolResultContentArray,
|
|
24
25
|
reasoningDisplayText,
|
|
26
|
+
resolveCompletionModelInfo,
|
|
25
27
|
serializeToolResultOutput,
|
|
26
|
-
textFromAssistantContent
|
|
27
|
-
|
|
28
|
+
textFromAssistantContent,
|
|
29
|
+
withContextUsage
|
|
30
|
+
} from "../chunk-ADH7NNCS.js";
|
|
28
31
|
import "../chunk-WQKHFADH.js";
|
|
29
32
|
export {
|
|
30
33
|
AssistantContent,
|
|
@@ -35,6 +38,7 @@ export {
|
|
|
35
38
|
Usage,
|
|
36
39
|
UserContent,
|
|
37
40
|
assertCompletionRequestSupported,
|
|
41
|
+
calculateContextUsage,
|
|
38
42
|
createCompletion,
|
|
39
43
|
createCompletionStream,
|
|
40
44
|
createParsedCompletion,
|
|
@@ -46,7 +50,9 @@ export {
|
|
|
46
50
|
isToolResultContentArray,
|
|
47
51
|
normalizeDocuments,
|
|
48
52
|
reasoningDisplayText,
|
|
53
|
+
resolveCompletionModelInfo,
|
|
49
54
|
serializeToolResultOutput,
|
|
50
|
-
textFromAssistantContent
|
|
55
|
+
textFromAssistantContent,
|
|
56
|
+
withContextUsage
|
|
51
57
|
};
|
|
52
58
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompletionModel, M as Message, U as Usage } from './types-
|
|
2
|
-
import { S as SummaryMemoryCompactorOptions, e as MemoryCompactor } from './types-
|
|
1
|
+
import { C as CompletionModel, M as Message, U as Usage } from './types-G12i56s2.js';
|
|
2
|
+
import { S as SummaryMemoryCompactorOptions, e as MemoryCompactor } from './types-BrLbKnEz.js';
|
|
3
3
|
|
|
4
4
|
declare function createSummaryMemoryCompactor(model: CompletionModel, options?: SummaryMemoryCompactorOptions): MemoryCompactor;
|
|
5
5
|
declare function isMemoryCompactionSummary(message: Message): boolean;
|
package/dist/evals/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { A as Agent } from '../agent-Q7FT1xmG.js';
|
|
2
|
-
import { i as JsonValue, M as Message, C as CompletionModel } from '../types-XjIh933x.js';
|
|
3
|
-
import { P as PromptResponse } from '../index-XTUEMWhU.js';
|
|
4
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';
|
|
3
|
+
import { A as Agent } from '../agent-x3YTyv5i.js';
|
|
4
|
+
import { P as PromptResponse } from '../index-BxSbmOMr.js';
|
|
5
5
|
import { E as EmbeddingModel } from '../types-BCTRUGex.js';
|
|
6
|
-
import '../guardrails/index.js';
|
|
7
|
-
import '../types-BCA8p0sb.js';
|
|
8
|
-
import '../types-DBHzPsbx.js';
|
|
9
|
-
import '../tool-Dhwg__1L.js';
|
|
10
|
-
import '../middleware-DfMc30in.js';
|
|
11
|
-
import '../types-BrxxAtcJ.js';
|
|
12
6
|
import 'zod';
|
|
7
|
+
import '../guardrails/index.js';
|
|
8
|
+
import '../types-D9JpeAPF.js';
|
|
9
|
+
import '../types-BrLbKnEz.js';
|
|
10
|
+
import '../tool-Cohdv5GC.js';
|
|
11
|
+
import '../middleware-Dp3d_pxi.js';
|
|
12
|
+
import '../types-O-abTIin.js';
|
|
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;
|
|
52
54
|
metadata?: EvalMetadata | undefined;
|
|
53
55
|
};
|
|
56
|
+
type EvalTurn = {
|
|
57
|
+
role: "user" | "assistant";
|
|
58
|
+
content: string;
|
|
59
|
+
metadata?: EvalMetadata | undefined;
|
|
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 };
|