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