@orq-ai/evaluatorq 1.2.0-rc.4 → 1.2.1
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 +140 -8
- package/dist/lib/integrations/ai-sdk/convert.d.ts +3 -3
- package/dist/lib/integrations/ai-sdk/convert.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/convert.js +44 -4
- package/dist/lib/integrations/ai-sdk/types.d.ts +6 -0
- package/dist/lib/integrations/ai-sdk/types.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/wrap-agent.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/wrap-agent.js +71 -5
- package/dist/lib/integrations/common/utils.d.ts +9 -0
- package/dist/lib/integrations/common/utils.d.ts.map +1 -1
- package/dist/lib/integrations/common/utils.js +10 -0
- package/dist/lib/integrations/langchain/convert.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/convert.js +10 -6
- package/dist/lib/integrations/langchain/types.d.ts +6 -0
- package/dist/lib/integrations/langchain/types.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/wrap-agent.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/wrap-agent.js +56 -7
- package/dist/lib/integrations/openresponses/index.d.ts +12 -0
- package/dist/lib/integrations/openresponses/index.d.ts.map +1 -1
- package/dist/lib/integrations/openresponses/index.js +19 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,19 @@ An evaluation framework library that provides a flexible way to run parallel eva
|
|
|
12
12
|
- **Pass/Fail Tracking**: Evaluators can return pass/fail status for CI/CD integration
|
|
13
13
|
- **Integrations**: LangChain, LangGraph, and Vercel AI SDK agent integration
|
|
14
14
|
|
|
15
|
+
## 📖 Table of Contents
|
|
16
|
+
|
|
17
|
+
- [Installation](#-installation)
|
|
18
|
+
- [Getting Started](#-getting-started)
|
|
19
|
+
- [Quick Start](#-quick-start)
|
|
20
|
+
- [LangChain Integration](#-langchain-integration)
|
|
21
|
+
- [Vercel AI SDK Integration](#-vercel-ai-sdk-integration)
|
|
22
|
+
- [Configuration](#-configuration)
|
|
23
|
+
- [Orq Platform Integration](#-orq-platform-integration)
|
|
24
|
+
- [OpenTelemetry Tracing](#-opentelemetry-tracing)
|
|
25
|
+
- [Pass/Fail Tracking](#-passfail-tracking)
|
|
26
|
+
- [API Reference](#-api-reference)
|
|
27
|
+
|
|
15
28
|
## 📥 Installation
|
|
16
29
|
|
|
17
30
|
```bash
|
|
@@ -45,9 +58,25 @@ npm install langchain @langchain/core @langchain/langgraph
|
|
|
45
58
|
For Vercel AI SDK integration:
|
|
46
59
|
|
|
47
60
|
```bash
|
|
48
|
-
npm install ai
|
|
61
|
+
npm install ai
|
|
49
62
|
```
|
|
50
63
|
|
|
64
|
+
## 🏁 Getting Started
|
|
65
|
+
|
|
66
|
+
New to evaluatorq? Follow this path to get up and running:
|
|
67
|
+
|
|
68
|
+
| Step | What you'll learn | Example |
|
|
69
|
+
|------|------------------|---------|
|
|
70
|
+
| 1. **Basic eval** | Run your first evaluation with inline data | [`pass-fail-simple.ts`](../../examples/src/lib/basics/pass-fail-simple.ts) |
|
|
71
|
+
| 2. **Multiple jobs** | Run multiple jobs in parallel on each data point | [`example-runners.ts`](../../examples/src/lib/basics/example-runners.ts) |
|
|
72
|
+
| 3. **Reusable patterns** | Create reusable jobs and evaluators | [`eval-reuse.eval.ts`](../../examples/src/lib/basics/eval-reuse.eval.ts) |
|
|
73
|
+
| 4. **Datasets** | Load data from the Orq platform | [`dataset-example.eval.ts`](../../examples/src/lib/datasets/dataset-example.eval.ts) |
|
|
74
|
+
| 5. **Structured scores** | Return multi-dimensional metrics | [`structured-rubric.eval.ts`](../../examples/src/lib/structured/structured-rubric.eval.ts) |
|
|
75
|
+
| 6. **LangChain agent** | Evaluate a LangChain/LangGraph agent | [`langchain-agent-eval.ts`](../../examples/src/lib/integrations/langchain/langchain-agent-eval.ts) |
|
|
76
|
+
| 7. **Vercel AI SDK** | Evaluate a Vercel AI SDK agent | [`vercel_ai_sdk_integration_example.ts`](../../examples/src/lib/integrations/vercel/vercel_ai_sdk_integration_example.ts) |
|
|
77
|
+
|
|
78
|
+
> **Tip:** Start with step 1 and work your way up. Each example builds on concepts from the previous one.
|
|
79
|
+
|
|
51
80
|
## 🚀 Quick Start
|
|
52
81
|
|
|
53
82
|
### Basic Usage
|
|
@@ -89,6 +118,8 @@ await evaluatorq("text-analysis", {
|
|
|
89
118
|
});
|
|
90
119
|
```
|
|
91
120
|
|
|
121
|
+
> **Tip:** The `job()` helper preserves the job name in error messages. Always prefer `job("name", fn)` over raw functions for better debugging.
|
|
122
|
+
|
|
92
123
|
### Using Orq Platform Datasets
|
|
93
124
|
|
|
94
125
|
```typescript
|
|
@@ -125,6 +156,8 @@ await evaluatorq("dataset-evaluation", {
|
|
|
125
156
|
});
|
|
126
157
|
```
|
|
127
158
|
|
|
159
|
+
> **Tip:** Use `parallelism` to control how many data points are processed concurrently. Start with a low value (3-5) when calling external APIs to avoid rate limits.
|
|
160
|
+
|
|
128
161
|
### Advanced Features
|
|
129
162
|
|
|
130
163
|
#### Multiple Jobs
|
|
@@ -179,17 +212,47 @@ await evaluatorq("async-eval", {
|
|
|
179
212
|
});
|
|
180
213
|
```
|
|
181
214
|
|
|
215
|
+
#### Dashboard Organization with `path`
|
|
216
|
+
|
|
217
|
+
Use the `path` parameter to organize evaluation results into folders on the Orq dashboard:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
await evaluatorq("my-evaluation", {
|
|
221
|
+
path: "MyProject/Evaluations/Unit Tests",
|
|
222
|
+
data: [...],
|
|
223
|
+
jobs: [...],
|
|
224
|
+
evaluators: [...],
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
> **Tip:** Use paths like `"Team/Sprint-42/Feature-X"` to keep experiments organized across teams and sprints.
|
|
229
|
+
|
|
230
|
+
See [`path-organization.eval.ts`](../../examples/src/lib/structured/path-organization.eval.ts) for a complete example.
|
|
231
|
+
|
|
232
|
+
#### Evaluation Description
|
|
233
|
+
|
|
234
|
+
Add a description to document the purpose of each evaluation run:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
await evaluatorq("model-comparison", {
|
|
238
|
+
description: "Compare GPT-4o vs Claude on customer support responses",
|
|
239
|
+
data: [...],
|
|
240
|
+
jobs: [...],
|
|
241
|
+
evaluators: [...],
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
182
245
|
#### Structured Evaluation Results
|
|
183
246
|
|
|
184
247
|
Evaluators can return structured, multi-dimensional metrics using `EvaluationResultCell`. This is useful for metrics like BERT scores, ROUGE-N scores, or any evaluation that produces multiple sub-scores.
|
|
185
248
|
|
|
186
249
|
See the runnable examples in the `examples/` directory:
|
|
187
250
|
|
|
188
|
-
- [`structured-rubric.eval.ts`](../../examples/src/lib/structured-rubric.eval.ts) - Multi-criteria quality rubric (relevance, coherence, fluency)
|
|
189
|
-
- [`structured-sentiment.eval.ts`](../../examples/src/lib/structured-sentiment.eval.ts) - Sentiment distribution breakdown (positive, negative, neutral)
|
|
190
|
-
- [`structured-safety.eval.ts`](../../examples/src/lib/structured-safety.eval.ts) - Toxicity/safety severity scores with pass/fail tracking
|
|
251
|
+
- [`structured-rubric.eval.ts`](../../examples/src/lib/structured/structured-rubric.eval.ts) - Multi-criteria quality rubric (relevance, coherence, fluency)
|
|
252
|
+
- [`structured-sentiment.eval.ts`](../../examples/src/lib/structured/structured-sentiment.eval.ts) - Sentiment distribution breakdown (positive, negative, neutral)
|
|
253
|
+
- [`structured-safety.eval.ts`](../../examples/src/lib/structured/structured-safety.eval.ts) - Toxicity/safety severity scores with pass/fail tracking
|
|
191
254
|
|
|
192
|
-
For a BERT score example using the Orq platform, see [`llm-eval-with-results.ts`](../../examples/src/lib/llm-eval-with-results.ts).
|
|
255
|
+
For a BERT score example using the Orq platform, see [`llm-eval-with-results.ts`](../../examples/src/lib/basics/llm-eval-with-results.ts).
|
|
193
256
|
|
|
194
257
|
> **Note:** Structured results display as `[structured]` in the terminal summary table but are preserved in full when sent to the Orq platform and OpenTelemetry spans.
|
|
195
258
|
|
|
@@ -244,12 +307,60 @@ The LangChain integration allows you to:
|
|
|
244
307
|
- Automatically convert agent outputs to OpenResponses format
|
|
245
308
|
- Evaluate agent behavior using standard evaluatorq evaluators
|
|
246
309
|
|
|
310
|
+
### System Instructions
|
|
311
|
+
|
|
312
|
+
Use the `instructions` option to inject a system prompt into the agent. It can be a static string or a function that builds instructions dynamically from the dataset row:
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
import { wrapLangChainAgent } from "@orq-ai/evaluatorq/langchain";
|
|
316
|
+
|
|
317
|
+
// Static instructions
|
|
318
|
+
const job = wrapLangChainAgent(agent, {
|
|
319
|
+
name: "my-agent",
|
|
320
|
+
instructions: "You are a helpful weather assistant.",
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// Dynamic instructions from dataset inputs
|
|
324
|
+
const job = wrapLangChainAgent(agent, {
|
|
325
|
+
name: "research-agent",
|
|
326
|
+
instructions: (data) =>
|
|
327
|
+
`Research the topic: ${data.inputs.topic}. Focus on ${data.inputs.focus}.`,
|
|
328
|
+
});
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Input Modes
|
|
332
|
+
|
|
333
|
+
The wrapper reads the user input from `data.inputs` in three ways:
|
|
334
|
+
|
|
335
|
+
- **`prompt`** (default): `data.inputs.prompt` — a single string, sent as one user message.
|
|
336
|
+
- **`messages`**: `data.inputs.messages` — an array of `{ role, content }` objects, sent as-is.
|
|
337
|
+
- **Both**: when both are present, `messages` are sent first, followed by `prompt` as a final user message.
|
|
338
|
+
|
|
339
|
+
Change the prompt key with the `promptKey` option (e.g., `{ promptKey: "question" }`).
|
|
340
|
+
|
|
341
|
+
### Extracting Text
|
|
342
|
+
|
|
343
|
+
Agent wrappers return a full OpenResponses object. Use `extractText()` to pull out the assistant's reply:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
import { extractText } from "@orq-ai/evaluatorq/openresponses";
|
|
347
|
+
|
|
348
|
+
const scorer = async ({ output }) => {
|
|
349
|
+
const text = extractText(output);
|
|
350
|
+
return { value: text.length > 0 ? 1 : 0 };
|
|
351
|
+
};
|
|
352
|
+
```
|
|
353
|
+
|
|
247
354
|
### Examples
|
|
248
355
|
|
|
249
356
|
Complete examples are available in the examples folder:
|
|
250
357
|
|
|
251
|
-
- **LangChain Agent**: [`examples/src/lib/integrations/langchain-agent-eval.ts`](../../examples/src/lib/integrations/langchain-agent-eval.ts)
|
|
252
|
-
- **LangGraph Agent**: [`examples/src/lib/integrations/langgraph-agent-eval.ts`](../../examples/src/lib/integrations/langgraph-agent-eval.ts)
|
|
358
|
+
- **LangChain Agent**: [`examples/src/lib/integrations/langchain/langchain-agent-eval.ts`](../../examples/src/lib/integrations/langchain/langchain-agent-eval.ts)
|
|
359
|
+
- **LangGraph Agent**: [`examples/src/lib/integrations/langchain/langgraph-agent-eval.ts`](../../examples/src/lib/integrations/langchain/langgraph-agent-eval.ts)
|
|
360
|
+
- **LangChain Research Agent (advanced)**: [`examples/src/lib/integrations/langchain/langchain-research-eval.ts`](../../examples/src/lib/integrations/langchain/langchain-research-eval.ts) — Dataset-driven research agent with dynamic `instructions` and multi-criteria evaluators
|
|
361
|
+
- **LangGraph Research Agent (advanced)**: [`examples/src/lib/integrations/langchain/langgraph-research-eval.ts`](../../examples/src/lib/integrations/langchain/langgraph-research-eval.ts) — Multi-tool research agent with correctness, tool chain, quality, completeness, and efficiency evaluators
|
|
362
|
+
|
|
363
|
+
> **Tip:** Pass the `instructions` option to `wrapLangChainAgent` for dynamic system prompts — no need to write a custom job function.
|
|
253
364
|
|
|
254
365
|
## 🤖 Vercel AI SDK Integration
|
|
255
366
|
|
|
@@ -260,11 +371,15 @@ The Vercel AI SDK integration allows you to:
|
|
|
260
371
|
- Automatically convert agent outputs to OpenResponses format
|
|
261
372
|
- Evaluate agent behavior using standard evaluatorq evaluators
|
|
262
373
|
|
|
374
|
+
The same `instructions`, `messages` input, and `extractText` support described in the LangChain section also applies to `wrapAISdkAgent`.
|
|
375
|
+
|
|
263
376
|
### Examples
|
|
264
377
|
|
|
265
378
|
Complete examples are available in the examples folder:
|
|
266
379
|
|
|
267
|
-
- **Vercel AI SDK Agent**: [`examples/src/lib/integrations/vercel_ai_sdk_integration_example.ts`](../../examples/src/lib/integrations/vercel_ai_sdk_integration_example.ts)
|
|
380
|
+
- **Vercel AI SDK Agent**: [`examples/src/lib/integrations/vercel/vercel_ai_sdk_integration_example.ts`](../../examples/src/lib/integrations/vercel/vercel_ai_sdk_integration_example.ts)
|
|
381
|
+
- **Vercel AI SDK Dataset Eval**: [`examples/src/lib/integrations/vercel/vercel_ai_sdk_dataset_example.ts`](../../examples/src/lib/integrations/vercel/vercel_ai_sdk_dataset_example.ts) — Dataset-based weather agent evaluation with expected output comparison
|
|
382
|
+
- **Vercel Multi-Agent Eval (advanced)**: [`examples/src/lib/integrations/vercel/vercel-multi-agent-eval.ts`](../../examples/src/lib/integrations/vercel/vercel-multi-agent-eval.ts) — Research + math agents with `instructions` parameter, scored on correctness, tool usage, quality rubric, and safety
|
|
268
383
|
|
|
269
384
|
## 🔧 Configuration
|
|
270
385
|
|
|
@@ -388,6 +503,9 @@ Main function to run evaluations.
|
|
|
388
503
|
- `data`: Array of data points, async iterable, or Orq dataset config
|
|
389
504
|
- `jobs`: Array of job functions to run on each data point
|
|
390
505
|
- `evaluators`: Array of evaluator configurations
|
|
506
|
+
- `parallelism`: Number of concurrent jobs (default: 1)
|
|
507
|
+
- `path`: Optional string for organizing results on the Orq dashboard (e.g., `"Project/Category"`)
|
|
508
|
+
- `description`: Optional string describing the evaluation run
|
|
391
509
|
|
|
392
510
|
#### Returns:
|
|
393
511
|
|
|
@@ -461,6 +579,20 @@ type Scorer = (
|
|
|
461
579
|
import { wrapLangChainAgent, wrapLangGraphAgent } from "@orq-ai/evaluatorq/langchain";
|
|
462
580
|
import { wrapAISdkAgent } from "@orq-ai/evaluatorq/ai-sdk";
|
|
463
581
|
import type { ResponseResource } from "@orq-ai/evaluatorq/openresponses";
|
|
582
|
+
import { extractText } from "@orq-ai/evaluatorq/openresponses";
|
|
583
|
+
|
|
584
|
+
// Extract the assistant's text reply from an OpenResponses output
|
|
585
|
+
function extractText(output: unknown): string;
|
|
586
|
+
|
|
587
|
+
// Options accepted by wrapLangChainAgent, wrapLangGraphAgent, and wrapAISdkAgent
|
|
588
|
+
interface AgentJobOptions {
|
|
589
|
+
/** Job name (defaults to "agent" or agent.id) */
|
|
590
|
+
name?: string;
|
|
591
|
+
/** Key in data.inputs to use as the prompt (defaults to "prompt") */
|
|
592
|
+
promptKey?: string;
|
|
593
|
+
/** Static string or function returning system instructions */
|
|
594
|
+
instructions?: string | ((data: DataPoint) => string);
|
|
595
|
+
}
|
|
464
596
|
|
|
465
597
|
// Deployment helper types
|
|
466
598
|
interface DeploymentOptions {
|
|
@@ -13,10 +13,10 @@ export declare function buildInputFromSteps<TOOLS extends ToolSet>(result: Await
|
|
|
13
13
|
/**
|
|
14
14
|
* Converts Vercel AI SDK agent result to OpenResponses format.
|
|
15
15
|
*/
|
|
16
|
-
export declare function convertToOpenResponses<TOOLS extends ToolSet>(result: Awaited<ReturnType<Agent<never, TOOLS, never>["generate"]>>, agent: Agent<never, TOOLS, never
|
|
16
|
+
export declare function convertToOpenResponses<TOOLS extends ToolSet>(result: Awaited<ReturnType<Agent<never, TOOLS, never>["generate"]>>, agent: Agent<never, TOOLS, never>): ResponseResource;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Builds OpenResponses format from AI SDK agent result steps.
|
|
19
|
+
* Extracts input messages from the request body when available.
|
|
20
20
|
*/
|
|
21
21
|
export declare function buildOpenResponsesFromSteps<TOOLS extends ToolSet>(result: Awaited<ReturnType<Agent<never, TOOLS, never>["generate"]>>, agent: Agent<never, TOOLS, never>, _prompt?: string): ResponseResource;
|
|
22
22
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/ai-sdk/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAc,OAAO,EAAE,MAAM,IAAI,CAAC;AAOrD,OAAO,KAAK,EAMV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AASnC;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,OAAO,EACvD,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACnE,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,EAAE,CA6EX;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,SAAS,OAAO,EAC1D,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACnE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/ai-sdk/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAc,OAAO,EAAE,MAAM,IAAI,CAAC;AAOrD,OAAO,KAAK,EAMV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AASnC;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,OAAO,EACvD,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACnE,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,EAAE,CA6EX;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,SAAS,OAAO,EAC1D,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACnE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAChC,gBAAgB,CAElB;AA8FD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,SAAS,OAAO,EAC/D,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACnE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EACjC,OAAO,CAAC,EAAE,MAAM,GACf,gBAAgB,CA6JlB"}
|
|
@@ -84,12 +84,51 @@ export function buildInputFromSteps(result, prompt) {
|
|
|
84
84
|
/**
|
|
85
85
|
* Converts Vercel AI SDK agent result to OpenResponses format.
|
|
86
86
|
*/
|
|
87
|
-
export function convertToOpenResponses(result, agent
|
|
88
|
-
return buildOpenResponsesFromSteps(result, agent
|
|
87
|
+
export function convertToOpenResponses(result, agent) {
|
|
88
|
+
return buildOpenResponsesFromSteps(result, agent);
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
|
|
91
|
+
* Maps a request body role to an OpenResponses Message role.
|
|
92
|
+
*/
|
|
93
|
+
const ROLE_MAP = {
|
|
94
|
+
system: "system",
|
|
95
|
+
user: "user",
|
|
96
|
+
assistant: "assistant",
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Extracts text from request body message content.
|
|
100
|
+
* Content can be a plain string or an array of content blocks.
|
|
101
|
+
*/
|
|
102
|
+
function extractContentText(content) {
|
|
103
|
+
if (typeof content === "string")
|
|
104
|
+
return content;
|
|
105
|
+
return content
|
|
106
|
+
.filter((block) => block.type === "text" || block.type === "input_text")
|
|
107
|
+
.map((block) => block.text ?? "")
|
|
108
|
+
.join("");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Builds input ItemField[] from the request body input messages.
|
|
112
|
+
* Extracts system + user messages from result.steps[0].request.body.input.
|
|
113
|
+
*/
|
|
114
|
+
function buildInputFromRequestBody(requestInput) {
|
|
115
|
+
if (!requestInput || requestInput.length === 0)
|
|
116
|
+
return [];
|
|
117
|
+
return requestInput.map((msg) => {
|
|
118
|
+
const role = ROLE_MAP[msg.role] ?? "user";
|
|
119
|
+
const text = extractContentText(msg.content);
|
|
120
|
+
return {
|
|
121
|
+
type: "message",
|
|
122
|
+
id: generateItemId("msg"),
|
|
123
|
+
status: "completed",
|
|
124
|
+
role,
|
|
125
|
+
content: [{ type: "input_text", text }],
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Builds OpenResponses format from AI SDK agent result steps.
|
|
131
|
+
* Extracts input messages from the request body when available.
|
|
93
132
|
*/
|
|
94
133
|
export function buildOpenResponsesFromSteps(result, agent, _prompt) {
|
|
95
134
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -199,6 +238,7 @@ export function buildOpenResponsesFromSteps(result, agent, _prompt) {
|
|
|
199
238
|
model: result.response.modelId,
|
|
200
239
|
previous_response_id: null,
|
|
201
240
|
instructions: null,
|
|
241
|
+
input: buildInputFromRequestBody(requestBody?.input),
|
|
202
242
|
output,
|
|
203
243
|
error: status === "failed" ? { message: "Agent execution failed" } : null,
|
|
204
244
|
tools,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StepResult } from "ai";
|
|
2
|
+
import type { DataPoint } from "../../types.js";
|
|
2
3
|
import type { FunctionTool, ResponseResource } from "../openresponses/index.js";
|
|
3
4
|
export type { StepResult };
|
|
4
5
|
/**
|
|
@@ -52,5 +53,10 @@ export interface AgentJobOptions {
|
|
|
52
53
|
name?: string;
|
|
53
54
|
/** The key in data.inputs to use as the prompt (defaults to "prompt") */
|
|
54
55
|
promptKey?: string;
|
|
56
|
+
/**
|
|
57
|
+
* System instructions to prepend to the messages sent to the agent.
|
|
58
|
+
* Can be a static string or a function that receives the data point and returns the instructions.
|
|
59
|
+
*/
|
|
60
|
+
instructions?: string | ((data: DataPoint) => string);
|
|
55
61
|
}
|
|
56
62
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/ai-sdk/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGhF,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IAEvB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE;YACL,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;YAClB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;SACxB,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACxB,QAAQ,CAAC,EAAE,KAAK,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,KAAK,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;gBACb,UAAU,CAAC,EAAE,MAAM,CAAC;g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ACxB,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACxB,QAAQ,CAAC,EAAE,KAAK,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,KAAK,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;gBACb,UAAU,CAAC,EAAE,MAAM,CAAC;gBACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAClB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAChB,IAAI,CAAC,EAAE,MAAM,CAAC;gBACd,eAAe,CAAC,EAAE;oBAChB,MAAM,CAAC,EAAE;wBACP,MAAM,CAAC,EAAE,MAAM,CAAC;qBACjB,CAAC;iBACH,CAAC;aACH,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ,CAAC;IACF,gBAAgB,CAAC,EAAE;QACjB,MAAM,CAAC,EAAE;YACP,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;CACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-agent.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/ai-sdk/wrap-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"wrap-agent.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/ai-sdk/wrap-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAgB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEvD,OAAO,KAAK,EAAa,GAAG,EAAU,MAAM,gBAAgB,CAAC;AAM7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,OAAO,EAClD,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EACjC,OAAO,GAAE,eAAoB,GAC5B,GAAG,CAuFL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractPromptFromData } from "../common/
|
|
1
|
+
import { extractMessagesFromData, extractPromptFromData, } from "../common/utils.js";
|
|
2
2
|
import { convertToOpenResponses } from "./convert.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates an evaluatorq Job from any AI SDK Agent.
|
|
@@ -54,12 +54,78 @@ import { convertToOpenResponses } from "./convert.js";
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export function wrapAISdkAgent(agent, options = {}) {
|
|
57
|
-
const { name = agent.id ?? "agent", promptKey = "prompt" } = options;
|
|
57
|
+
const { name = agent.id ?? "agent", promptKey = "prompt", instructions, } = options;
|
|
58
58
|
return async (data, _row) => {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
59
|
+
const inputMessages = extractMessagesFromData(data);
|
|
60
|
+
const hasMessages = inputMessages !== undefined;
|
|
61
|
+
const hasPrompt = typeof data.inputs[promptKey] === "string" && data.inputs[promptKey];
|
|
62
|
+
let result;
|
|
63
|
+
if (instructions) {
|
|
64
|
+
// Resolve instructions (static string or dynamic function)
|
|
65
|
+
const resolvedInstructions = typeof instructions === "function" ? instructions(data) : instructions;
|
|
66
|
+
const systemMessage = {
|
|
67
|
+
role: "system",
|
|
68
|
+
content: resolvedInstructions,
|
|
69
|
+
};
|
|
70
|
+
if (hasMessages && hasPrompt) {
|
|
71
|
+
const messages = [
|
|
72
|
+
systemMessage,
|
|
73
|
+
...inputMessages,
|
|
74
|
+
{
|
|
75
|
+
role: "user",
|
|
76
|
+
content: data.inputs[promptKey],
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
result = await agent.generate({ messages });
|
|
80
|
+
}
|
|
81
|
+
else if (hasPrompt) {
|
|
82
|
+
const messages = [
|
|
83
|
+
systemMessage,
|
|
84
|
+
{
|
|
85
|
+
role: "user",
|
|
86
|
+
content: data.inputs[promptKey],
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
result = await agent.generate({ messages });
|
|
90
|
+
}
|
|
91
|
+
else if (hasMessages) {
|
|
92
|
+
const messages = [
|
|
93
|
+
systemMessage,
|
|
94
|
+
...inputMessages,
|
|
95
|
+
];
|
|
96
|
+
result = await agent.generate({ messages });
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error("Expected data.inputs.messages (array) or data.inputs.prompt (string), but neither was provided");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (hasMessages && hasPrompt) {
|
|
103
|
+
// Both exist — merge messages + prompt appended as user message
|
|
104
|
+
const messages = [
|
|
105
|
+
...inputMessages,
|
|
106
|
+
{
|
|
107
|
+
role: "user",
|
|
108
|
+
content: data.inputs[promptKey],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
result = await agent.generate({ messages });
|
|
112
|
+
}
|
|
113
|
+
else if (hasPrompt) {
|
|
114
|
+
// Prompt only — use native single-turn API
|
|
115
|
+
const prompt = extractPromptFromData(data, promptKey);
|
|
116
|
+
result = await agent.generate({ prompt });
|
|
117
|
+
}
|
|
118
|
+
else if (hasMessages) {
|
|
119
|
+
// Messages only — pass directly
|
|
120
|
+
result = await agent.generate({
|
|
121
|
+
messages: inputMessages,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new Error("Expected data.inputs.messages (array) or data.inputs.prompt (string), but neither was provided");
|
|
126
|
+
}
|
|
61
127
|
// Convert to OpenResponses format
|
|
62
|
-
const openResponsesOutput = convertToOpenResponses(result, agent
|
|
128
|
+
const openResponsesOutput = convertToOpenResponses(result, agent);
|
|
63
129
|
return {
|
|
64
130
|
name,
|
|
65
131
|
output: openResponsesOutput,
|
|
@@ -25,6 +25,15 @@ export declare function serializeArgs(args: unknown): string;
|
|
|
25
25
|
* @returns The corresponding OpenResponses status
|
|
26
26
|
*/
|
|
27
27
|
export declare function getResponseStatus(finishReason: string | undefined): ResponseResource["status"];
|
|
28
|
+
export type InputMessage = {
|
|
29
|
+
role: string;
|
|
30
|
+
content: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Safely extracts messages from a DataPoint.
|
|
34
|
+
* Returns undefined when `data.inputs.messages` is missing, not an array, or empty.
|
|
35
|
+
*/
|
|
36
|
+
export declare function extractMessagesFromData(data: DataPoint): InputMessage[] | undefined;
|
|
28
37
|
/**
|
|
29
38
|
* Extracts and validates a prompt string from a DataPoint.
|
|
30
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/common/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAiBnD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,gBAAgB,CAAC,QAAQ,CAAC,CAa5B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,GAChB,MAAM,CAQR"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/common/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAiBnD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,gBAAgB,CAAC,QAAQ,CAAC,CAa5B;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,GACd,YAAY,EAAE,GAAG,SAAS,CAI5B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,GAChB,MAAM,CAQR"}
|
|
@@ -56,6 +56,16 @@ export function getResponseStatus(finishReason) {
|
|
|
56
56
|
return "completed";
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Safely extracts messages from a DataPoint.
|
|
61
|
+
* Returns undefined when `data.inputs.messages` is missing, not an array, or empty.
|
|
62
|
+
*/
|
|
63
|
+
export function extractMessagesFromData(data) {
|
|
64
|
+
const messages = data.inputs.messages;
|
|
65
|
+
if (!Array.isArray(messages) || messages.length === 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
return messages;
|
|
68
|
+
}
|
|
59
69
|
/**
|
|
60
70
|
* Extracts and validates a prompt string from a DataPoint.
|
|
61
71
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/convert.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAO5D,OAAO,KAAK,EAMV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAEV,gBAAgB,EAGhB,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAwB1D;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,YAAY,EAAE,EACxB,KAAK,CAAC,EAAE,cAAc,EAAE,GACvB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/convert.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAO5D,OAAO,KAAK,EAMV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAEV,gBAAgB,EAGhB,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAwB1D;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,YAAY,EAAE,EACxB,KAAK,CAAC,EAAE,cAAc,EAAE,GACvB,gBAAgB,CA6MlB"}
|
|
@@ -45,12 +45,15 @@ export function convertToOpenResponses(messages, tools) {
|
|
|
45
45
|
// Handle both message objects and dict format
|
|
46
46
|
const msgType = getMessageType(msg);
|
|
47
47
|
const msgData = getMessageData(msg);
|
|
48
|
+
// Resolve the message ID: prefer msgData.id (from kwargs.id for constructor format)
|
|
49
|
+
// over msg.id (which is the LC constructor id array for serialized messages).
|
|
50
|
+
const messageId = msgData.id ?? (typeof msg.id === "string" ? msg.id : undefined);
|
|
48
51
|
if (msgType === "human") {
|
|
49
52
|
// User message goes into input
|
|
50
53
|
const contentText = getContent(msgData);
|
|
51
54
|
const inputMessage = {
|
|
52
55
|
type: "message",
|
|
53
|
-
id:
|
|
56
|
+
id: messageId ?? generateItemId("msg"),
|
|
54
57
|
role: "user",
|
|
55
58
|
status: "completed",
|
|
56
59
|
content: [{ type: "input_text", text: contentText }],
|
|
@@ -108,7 +111,7 @@ export function convertToOpenResponses(messages, tools) {
|
|
|
108
111
|
if (contentText) {
|
|
109
112
|
const outputMessage = {
|
|
110
113
|
type: "message",
|
|
111
|
-
id:
|
|
114
|
+
id: messageId ?? generateItemId("msg"),
|
|
112
115
|
role: "assistant",
|
|
113
116
|
status: "completed",
|
|
114
117
|
content: [
|
|
@@ -130,7 +133,7 @@ export function convertToOpenResponses(messages, tools) {
|
|
|
130
133
|
const outputContent = getContent(msgData);
|
|
131
134
|
const functionCallOutput = {
|
|
132
135
|
type: "function_call_output",
|
|
133
|
-
id:
|
|
136
|
+
id: messageId ?? generateItemId("fco"),
|
|
134
137
|
call_id: toolCallId,
|
|
135
138
|
output: outputContent,
|
|
136
139
|
status: "completed",
|
|
@@ -140,14 +143,14 @@ export function convertToOpenResponses(messages, tools) {
|
|
|
140
143
|
else if (msgType === "system") {
|
|
141
144
|
// System message goes into input
|
|
142
145
|
const contentText = getContent(msgData);
|
|
143
|
-
const
|
|
146
|
+
const inputMessage = {
|
|
144
147
|
type: "message",
|
|
145
|
-
id:
|
|
148
|
+
id: messageId ?? generateItemId("msg"),
|
|
146
149
|
role: "system",
|
|
147
150
|
status: "completed",
|
|
148
151
|
content: [{ type: "input_text", text: contentText }],
|
|
149
152
|
};
|
|
150
|
-
inputItems.push(
|
|
153
|
+
inputItems.push(inputMessage);
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
// Build tools array
|
|
@@ -184,6 +187,7 @@ export function convertToOpenResponses(messages, tools) {
|
|
|
184
187
|
model: modelName,
|
|
185
188
|
previous_response_id: null,
|
|
186
189
|
instructions: null,
|
|
190
|
+
input: inputItems,
|
|
187
191
|
output: outputItems,
|
|
188
192
|
error: status === "failed" ? { message: "Agent execution failed" } : null,
|
|
189
193
|
tools: toolsArray,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { BaseMessage } from "@langchain/core/messages";
|
|
5
5
|
import type { RunnableConfig } from "@langchain/core/runnables";
|
|
6
|
+
import type { DataPoint } from "../../types.js";
|
|
6
7
|
export type { BaseMessage, RunnableConfig };
|
|
7
8
|
/**
|
|
8
9
|
* Protocol for LangChain/LangGraph invocable objects.
|
|
@@ -120,6 +121,11 @@ export interface AgentJobOptions {
|
|
|
120
121
|
name?: string;
|
|
121
122
|
/** The key in data.inputs to use as the prompt (defaults to "prompt") */
|
|
122
123
|
promptKey?: string;
|
|
124
|
+
/**
|
|
125
|
+
* System instructions to prepend to the messages sent to the agent.
|
|
126
|
+
* Can be a static string or a function that receives the data point and returns the instructions.
|
|
127
|
+
*/
|
|
128
|
+
instructions?: string | ((data: DataPoint) => string);
|
|
123
129
|
}
|
|
124
130
|
/**
|
|
125
131
|
* Tool definition for OpenResponses output.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC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M,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-agent.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/wrap-agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAa,GAAG,EAAU,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"wrap-agent.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/langchain/wrap-agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAa,GAAG,EAAU,MAAM,gBAAgB,CAAC;AAM7D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACf,MAAM,YAAY,CAAC;AA8CpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,kBAAkB,EACzB,OAAO,GAAE,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,cAAc,EAAE,CAAA;CAAO,GAC3D,GAAG,CA8EL;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,kBAAkB,GACxB,cAAc,EAAE,CAgElB;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,2BAAqB,CAAC"}
|