token-js / token.js

Integrate 200+ LLMs with one TypeScript SDK using OpenAI's format.
https://docs.tokenjs.ai/
MIT License
52 stars 3 forks source link

Reduce Bundle Size #75

Open RPate97 opened 1 month ago

RPate97 commented 1 month ago

Problem

Since token.js currently integrates with every LLM provider using their javascript SDK, the package size is much larger than necessary. This can impact the performance of backend services using token.js in serverless functions.

Solution

Refactor LLM provider integrations to work directly with each providers API instead of using the SDK.

Comments

It's recommended to do this one at a time. The following providers still need to be refactored to remove their SDKs.

Note that the OpenAI SDK is also used to integrate Perplexity and Groq, so they will need to be refactored as well when removing that SDK.

sam-goldman commented 1 month ago

AI21 doesn't have a JS library, so that integration doesn't use any dependencies aside from http and axios. I crossed it off the list.