@@ -2286,130 +2286,6 @@ async function handleOllama({
2286
2286
} ) ;
2287
2287
}
2288
2288
2289
- /**
2290
- * Handles object generation for Atoma models.
2291
- *
2292
- * @param {ProviderOptions } options - Options specific to Atoma.
2293
- * @returns {Promise<GenerateObjectResult<unknown>> } - A promise that resolves to generated objects.
2294
- */
2295
- async function handleAtoma ( {
2296
- model,
2297
- apiKey,
2298
- schema,
2299
- schemaName : _schemaName ,
2300
- schemaDescription : _schemaDescription ,
2301
- mode : _mode ,
2302
- modelOptions : _modelOptions ,
2303
- context,
2304
- runtime : _runtime ,
2305
- provider : _provider ,
2306
- modelClass : _modelClass ,
2307
- } : ProviderOptions ) : Promise < GenerateObjectResult < unknown > > {
2308
- const atomaSDK = new AtomaSDK ( {
2309
- bearerAuth : apiKey ,
2310
- } ) ;
2311
-
2312
- try {
2313
- const result = await atomaSDK . chat . create ( {
2314
- messages : [
2315
- {
2316
- content : context ,
2317
- role : "user" ,
2318
- } ,
2319
- ] ,
2320
- model : model ,
2321
- } ) ;
2322
-
2323
- const completion = result . choices [ 0 ] . message . content ;
2324
-
2325
- if ( schema ) {
2326
- // For schema-based generation, we'll parse the completion as JSON
2327
- // and validate it against the schema
2328
- const parsedCompletion = JSON . parse ( completion ) ;
2329
- const validatedObject = schema . parse ( parsedCompletion ) ;
2330
-
2331
- return {
2332
- object : validatedObject ,
2333
- finishReason : ( result . choices [ 0 ] . finishReason ?? "stop" ) as
2334
- | "stop"
2335
- | "length"
2336
- | "error"
2337
- | "tool-calls" ,
2338
- usage : {
2339
- promptTokens : result . usage ?. promptTokens ?? 0 ,
2340
- completionTokens : result . usage ?. completionTokens ?? 0 ,
2341
- totalTokens : result . usage ?. totalTokens ?? 0 ,
2342
- } ,
2343
- warnings : undefined ,
2344
- request : { } ,
2345
- response : {
2346
- id : result . id ,
2347
- timestamp : new Date ( result . created * 1000 ) , // Convert Unix timestamp to Date
2348
- modelId : result . model ,
2349
- } ,
2350
- logprobs : undefined ,
2351
- experimental_providerMetadata : result . systemFingerprint
2352
- ? {
2353
- metadata : {
2354
- systemFingerprint : result . systemFingerprint ,
2355
- } ,
2356
- }
2357
- : undefined ,
2358
- toJsonResponse ( init ?: ResponseInit ) {
2359
- return new Response (
2360
- JSON . stringify ( { object : validatedObject } ) ,
2361
- {
2362
- ...init ,
2363
- headers : {
2364
- ...init ?. headers ,
2365
- "content-type" :
2366
- "application/json; charset=utf-8" ,
2367
- } ,
2368
- }
2369
- ) ;
2370
- } ,
2371
- } ;
2372
- }
2373
-
2374
- return {
2375
- object : completion ,
2376
- finishReason : ( result . choices [ 0 ] . finishReason ?? "stop" ) as
2377
- | "stop"
2378
- | "length"
2379
- | "error"
2380
- | "tool-calls" ,
2381
- usage : {
2382
- promptTokens : result . usage ?. promptTokens ?? 0 ,
2383
- completionTokens : result . usage ?. completionTokens ?? 0 ,
2384
- totalTokens : result . usage ?. totalTokens ?? 0 ,
2385
- } ,
2386
- warnings : undefined ,
2387
- request : { } ,
2388
- response : {
2389
- id : result . id ,
2390
- timestamp : new Date ( result . created * 1000 ) , // Convert Unix timestamp to Date
2391
- modelId : result . model ,
2392
- } ,
2393
- logprobs : undefined ,
2394
- experimental_providerMetadata : result . systemFingerprint
2395
- ? { metadata : { systemFingerprint : result . systemFingerprint } }
2396
- : undefined ,
2397
- toJsonResponse ( init ?: ResponseInit ) {
2398
- return new Response ( JSON . stringify ( { object : completion } ) , {
2399
- ...init ,
2400
- headers : {
2401
- ...init ?. headers ,
2402
- "content-type" : "application/json; charset=utf-8" ,
2403
- } ,
2404
- } ) ;
2405
- } ,
2406
- } ;
2407
- } catch ( error ) {
2408
- console . error ( "Error in Atoma handler:" , error ) ;
2409
- throw error ;
2410
- }
2411
- }
2412
-
2413
2289
/**
2414
2290
* Handles object generation for DeepSeek models.
2415
2291
*
0 commit comments