File tree 1 file changed +50
-0
lines changed
packages/client-direct/src
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,56 @@ export class DirectClient {
270
270
res . json ( { images : imagesRes } ) ;
271
271
}
272
272
) ;
273
+
274
+ this . app . post (
275
+ "/fine-tune" ,
276
+ async ( req : express . Request , res : express . Response ) => {
277
+ try {
278
+ const response = await fetch ( 'https://api.bageldb.ai/api/v1/asset' , {
279
+ method : 'POST' ,
280
+ headers : {
281
+ 'Content-Type' : 'application/json' ,
282
+ 'X-API-KEY' : `${ process . env . BAGEL_API_KEY } `
283
+ } ,
284
+ body : JSON . stringify ( req . body )
285
+ } ) ;
286
+
287
+ const data = await response . json ( ) ;
288
+ res . json ( data ) ;
289
+ } catch ( error ) {
290
+ res . status ( 500 ) . json ( {
291
+ error : 'Failed to forward request to BagelDB' ,
292
+ details : error . message
293
+ } ) ;
294
+ }
295
+ }
296
+ ) ;
297
+ this . app . get (
298
+ "/fine-tune/:assetId" ,
299
+ async ( req : express . Request , res : express . Response ) => {
300
+ const assetId = req . params . assetId ;
301
+ try {
302
+ const response = await fetch ( `https://api.bageldb.ai/api/v1/asset/${ assetId } /download` , {
303
+ headers : {
304
+ 'X-API-KEY' : `${ process . env . BAGEL_API_KEY } `
305
+ }
306
+ } ) ;
307
+
308
+ // Forward the content-type header
309
+ res . set ( 'Content-Type' , response . headers . get ( 'content-type' ) ) ;
310
+
311
+ // Convert ReadableStream to Buffer and send
312
+ const arrayBuffer = await response . arrayBuffer ( ) ;
313
+ const buffer = Buffer . from ( arrayBuffer ) ;
314
+ res . send ( buffer ) ;
315
+ } catch ( error ) {
316
+ res . status ( 500 ) . json ( {
317
+ error : 'Failed to forward request to BagelDB' ,
318
+ details : error . message
319
+ } ) ;
320
+ }
321
+ }
322
+ ) ;
273
323
}
274
324
275
325
public registerAgent ( runtime : AgentRuntime ) {
You can’t perform that action at this time.
0 commit comments