@@ -5,6 +5,10 @@ import { generateText, tool } from "ai";
5
5
import { openai } from "@ai-sdk/openai" ;
6
6
import { z } from "zod" ;
7
7
8
+ import * as fs from "fs" ;
9
+ import { fileURLToPath } from "url" ;
10
+ import path from "path" ;
11
+
8
12
import { AISDKExporter } from "../vercel.js" ;
9
13
import { waitUntilRunFound } from "./utils.js" ;
10
14
import { Client } from "../index.js" ;
@@ -25,7 +29,7 @@ test("nested generateText", async () => {
25
29
const wrapper = traceable (
26
30
async ( ) => {
27
31
return generateText ( {
28
- model : openai ( "gpt-4.1-mini " ) ,
32
+ model : openai ( "gpt-4.1-nano " ) ,
29
33
messages : [
30
34
{
31
35
role : "user" ,
@@ -43,15 +47,52 @@ test("nested generateText", async () => {
43
47
description : "view tracking information for a specific order" ,
44
48
parameters : z . object ( { orderId : z . string ( ) } ) ,
45
49
execute : async ( ) => {
50
+ const pathname = path . join (
51
+ path . dirname ( fileURLToPath ( import . meta. url ) ) ,
52
+ "test_data" ,
53
+ "parrot-icon.png"
54
+ ) ;
55
+ const buffer = fs . readFileSync ( pathname ) ;
46
56
await generateText ( {
47
- model : openai ( "gpt-4.1-mini " ) ,
57
+ model : openai ( "gpt-4.1-nano " ) ,
48
58
experimental_telemetry : AISDKExporter . getSettings ( {
49
59
runName : "How are you 1" ,
50
60
} ) ,
51
61
messages : [
52
62
{
53
63
role : "user" ,
54
- content : `How are you feeling?` ,
64
+ content : [
65
+ {
66
+ type : "text" ,
67
+ text : "What is this?" ,
68
+ } ,
69
+ // Node Buffer
70
+ {
71
+ type : "image" ,
72
+ image : Buffer . from ( buffer ) ,
73
+ } ,
74
+ // ArrayBuffer
75
+ {
76
+ type : "image" ,
77
+ image : buffer . buffer . slice (
78
+ buffer . byteOffset ,
79
+ buffer . byteOffset + buffer . byteLength
80
+ ) ,
81
+ } ,
82
+ {
83
+ type : "image" ,
84
+ image : new Uint8Array ( buffer ) ,
85
+ } ,
86
+ {
87
+ type : "image" ,
88
+ image : buffer . toString ( "base64" ) ,
89
+ } ,
90
+ {
91
+ type : "image" ,
92
+ image :
93
+ "https://png.pngtree.com/png-vector/20221025/ourmid/pngtree-navigation-bar-3d-search-url-png-image_6360655.png" ,
94
+ } ,
95
+ ] ,
55
96
} ,
56
97
] ,
57
98
} ) ;
@@ -122,4 +163,12 @@ test("nested generateText", async () => {
122
163
expect (
123
164
storedRun . child_runs ?. [ 0 ] ?. child_runs ?. [ 3 ] ?. child_runs ?. [ 1 ] . name
124
165
) . toEqual ( "How are you 2" ) ;
166
+ expect (
167
+ storedRun . child_runs ?. [ 0 ] ?. child_runs ?. [ 3 ] ?. child_runs ?. [ 0 ] . child_runs
168
+ ?. length
169
+ ) . toEqual ( 1 ) ;
170
+ expect (
171
+ storedRun . child_runs ?. [ 0 ] ?. child_runs ?. [ 3 ] ?. child_runs ?. [ 1 ] . child_runs
172
+ ?. length
173
+ ) . toEqual ( 1 ) ;
125
174
} ) ;
0 commit comments