@langwatch/scenario 0.2.13 → 0.4.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/README.md +36 -9
- package/dist/index.d.mts +433 -256
- package/dist/index.d.ts +433 -256
- package/dist/index.js +2221 -516
- package/dist/index.mjs +2611 -303
- package/dist/integrations/vitest/config.mjs +0 -2
- package/dist/integrations/vitest/reporter.js +36 -11
- package/dist/integrations/vitest/reporter.mjs +159 -8
- package/dist/integrations/vitest/setup-global.mjs +0 -2
- package/dist/integrations/vitest/setup.js +85 -53
- package/dist/integrations/vitest/setup.mjs +619 -18
- package/package.json +46 -30
- package/dist/chunk-6SKQWXT7.mjs +0 -528
- package/dist/chunk-7P6ASYW6.mjs +0 -9
- package/dist/chunk-OL4RFXV4.mjs +0 -133
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ import { describe, it, expect } from "vitest";
|
|
|
78
78
|
import { openai } from "@ai-sdk/openai";
|
|
79
79
|
import scenario, { type AgentAdapter, AgentRole } from "@langwatch/scenario";
|
|
80
80
|
import { generateText, tool } from "ai";
|
|
81
|
-
import { z } from "zod";
|
|
81
|
+
import { z } from "zod/v4";
|
|
82
82
|
|
|
83
83
|
describe("Weather Agent", () => {
|
|
84
84
|
it("should get the weather for a city", async () => {
|
|
@@ -103,13 +103,40 @@ describe("Weather Agent", () => {
|
|
|
103
103
|
tools: { get_current_weather: getCurrentWeather },
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
if (response.toolCalls
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
107
|
+
const toolCall = response.toolCalls[0];
|
|
108
|
+
// Agent executes the tool directly and returns both messages
|
|
109
|
+
const toolResult = await getCurrentWeather.execute(
|
|
110
|
+
toolCall.input as { city: string },
|
|
111
|
+
{
|
|
112
|
+
toolCallId: toolCall.toolCallId,
|
|
113
|
+
messages: input.messages,
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
role: "assistant",
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: "tool-call",
|
|
122
|
+
toolName: toolCall.toolName,
|
|
123
|
+
toolCallId: toolCall.toolCallId,
|
|
124
|
+
input: toolCall.input,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
role: "tool",
|
|
130
|
+
content: [
|
|
131
|
+
{
|
|
132
|
+
type: "tool-result",
|
|
133
|
+
toolName: toolCall.toolName,
|
|
134
|
+
toolCallId: toolCall.toolCallId,
|
|
135
|
+
output: { type: "text", value: toolResult as string },
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
];
|
|
113
140
|
}
|
|
114
141
|
|
|
115
142
|
return response.text;
|
|
@@ -138,7 +165,7 @@ describe("Weather Agent", () => {
|
|
|
138
165
|
|
|
139
166
|
// 4. Assert the final result
|
|
140
167
|
expect(result.success).toBe(true);
|
|
141
|
-
});
|
|
168
|
+
}, 30_000); // 30s test timeout
|
|
142
169
|
});
|
|
143
170
|
```
|
|
144
171
|
|