@@ -75,7 +75,6 @@ function request(path::String, body::Union{Dict, Nothing} = nothing)
7575 " Content-type" => " application/json" ,
7676 ),
7777 ) do http_io
78-
7978 write (http_io, JSON3. write (body))
8079 startread (http_io)
8180
@@ -85,6 +84,10 @@ function request(path::String, body::Union{Dict, Nothing} = nothing)
8584
8685 put! (data_channel, chunk) # Write chunk to channel
8786 end
87+
88+ # get the last chunk once you've reached the end
89+ chunk = String (readavailable (http_io))
90+ put! (data_channel, chunk)
8891 end
8992 # always make the status code available via a channel for non streaming calls
9093 status_code = response. status
@@ -102,7 +105,13 @@ function request(path::String, body::Union{Dict, Nothing} = nothing)
102105 return data_channel
103106 end
104107
105- result = JSON3. read (String (take! (data_channel)))
108+ json_string = " "
109+ while isopen (data_channel)
110+ item = String (take! (data_channel))
111+ json_string *= item
112+ end
113+
114+ result = JSON3. read (json_string)
106115
107116 error = get (result, " error" , nothing )
108117
@@ -145,7 +154,7 @@ function run(input::Any, model_id_dict::Dict, options::Dict)
145154 error = get (results, " error" , nothing )
146155
147156 if error != = nothing
148- throw (Exception ( error) )
157+ throw (error)
149158 end
150159
151160 return results
0 commit comments