11export * as Media from "./media.js"
22
3- import { Effect , Encoding , FileSystem , Schema , SchemaGetter } from "effect"
4- import { HttpClientRequest } from "effect/unstable/http"
3+ import { Effect , FileSystem , Schema , SchemaGetter } from "effect"
4+ import { Base64 } from "effect/encoding"
5+ import { HttpClientRequest } from "effect/http"
56import { ProviderID } from "./schema/ids.js"
67import { AIError , HttpContext , InvalidProviderOutputError , InvalidRequestError } from "./schema/errors.js"
78import { ProviderMetadata } from "./schema/options.js"
@@ -140,7 +141,7 @@ export class Asset {
140141 inline ( ) : Inline | undefined {
141142 const source = this . source
142143 if ( source . type !== "bytes" && source . type !== "base64" ) return undefined
143- const base64 = source . type === "base64" ? source . data : ( this . #base64 ??= Encoding . encodeBase64 ( source . data ) )
144+ const base64 = source . type === "base64" ? source . data : ( this . #base64 ??= Base64 . encode ( source . data ) )
144145 const mime = this . mediaType . toLowerCase ( )
145146 return { mime, base64, dataUrl : `data:${ mime } ;base64,${ base64 } ` }
146147 }
@@ -155,7 +156,7 @@ export class Asset {
155156 return Effect . fail ( invalid ( `Cannot materialize provider ref ${ source . provider } :${ source . id } ` ) )
156157 const decoded =
157158 source . type === "base64"
158- ? Effect . fromResult ( Encoding . decodeBase64 ( source . data ) ) . pipe (
159+ ? Effect . fromResult ( Base64 . decode ( source . data ) ) . pipe (
159160 Effect . mapError ( ( cause ) => invalid ( `Media asset contains invalid base64 data` , cause ) ) ,
160161 )
161162 : download ( source , this . headers )
@@ -168,7 +169,7 @@ export class Asset {
168169 const source = this . source
169170 if ( source . type === "base64" ) return Effect . succeed ( source . data )
170171 if ( this . #base64 !== undefined ) return Effect . succeed ( this . #base64)
171- return this . bytes ( ) . pipe ( Effect . map ( ( data ) => ( this . #base64 = Encoding . encodeBase64 ( data ) ) ) )
172+ return this . bytes ( ) . pipe ( Effect . map ( ( data ) => ( this . #base64 = Base64 . encode ( data ) ) ) )
172173 } )
173174 }
174175
@@ -183,7 +184,7 @@ export class Asset {
183184 toJSON ( ) {
184185 const source = this . source
185186 return {
186- source : source . type === "bytes" ? { ...source , data : Encoding . encodeBase64 ( source . data ) } : source ,
187+ source : source . type === "bytes" ? { ...source , data : Base64 . encode ( source . data ) } : source ,
187188 info : this . info ,
188189 providerMetadata : this . providerMetadata ,
189190 }
0 commit comments