Skip to content

Commit 3c04b92

Browse files
committed
refactor: remove Atoma model generation function from generation.ts
- Deleted the handleAtoma function, which was responsible for generating objects for Atoma models. - This change simplifies the codebase by removing unused functionality, improving maintainability.
1 parent be5aa19 commit 3c04b92

File tree

1 file changed

+0
-124
lines changed

1 file changed

+0
-124
lines changed

packages/core/src/generation.ts

-124
Original file line numberDiff line numberDiff line change
@@ -2286,130 +2286,6 @@ async function handleOllama({
22862286
});
22872287
}
22882288

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-
24132289
/**
24142290
* Handles object generation for DeepSeek models.
24152291
*

0 commit comments

Comments
 (0)