diff --git a/package.json b/package.json index 69128e0..6f84eac 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,14 @@ "name": "token.js", "version": "0.0.2", "description": "Integrate 9 LLM providers with a single Typescript SDK using OpenAIs format.", - "main": "dist/index", - "types": "dist/index", + "main": "dist/index.cjs", + "module": "dist/index.js", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs" + } + }, "files": [ "dist/*" ], @@ -31,7 +37,6 @@ "axios": "^1.7.2", "chalk": "^4.1.2", "cohere-ai": "^7.10.6", - "groq-sdk": "^0.5.0", "mime-types": "^2.1.35", "nanoid": "^5.0.7", "openai": "^4.52.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e38e5c7..1df2848 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,9 +26,6 @@ dependencies: cohere-ai: specifier: ^7.10.6 version: 7.10.6(@aws-sdk/client-sso-oidc@3.609.0) - groq-sdk: - specifier: ^0.5.0 - version: 0.5.0 mime-types: specifier: ^2.1.35 version: 2.1.35 @@ -4297,21 +4294,6 @@ packages: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true - /groq-sdk@0.5.0: - resolution: {integrity: sha512-RVmhW7qZ+XZoy5fIuSdx/LGQJONpL8MHgZEW7dFwTdgkzStub2XQx6OKv28CHogijdwH41J+Npj/z2jBPu3vmw==} - dependencies: - '@types/node': 18.19.39 - '@types/node-fetch': 2.6.11 - abort-controller: 3.0.0 - agentkeepalive: 4.5.0 - form-data-encoder: 1.7.2 - formdata-node: 4.4.1 - node-fetch: 2.7.0 - web-streams-polyfill: 3.3.3 - transitivePeerDependencies: - - encoding - dev: false - /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} dev: true diff --git a/src/handlers/groq.ts b/src/handlers/groq.ts index 912c16f..a8f25e7 100644 --- a/src/handlers/groq.ts +++ b/src/handlers/groq.ts @@ -1,4 +1,4 @@ -import Groq from 'groq-sdk' +import OpenAI from 'openai' import { GroqModel, ProviderCompletionParams } from '../chat' import { CompletionResponse, StreamCompletionResponse } from '../userTypes' @@ -32,10 +32,9 @@ export class GroqHandler extends BaseHandler { this.validateInputs(body) const apiKey = this.opts.apiKey ?? process.env.GROQ_API_KEY - const baseURL = this.opts.baseURL - const client = new Groq({ + const client = new OpenAI({ apiKey, - baseURL, + baseURL: 'https://api.groq.com/openai/v1', }) if (apiKey === undefined) { @@ -44,16 +43,6 @@ export class GroqHandler extends BaseHandler { ) } - return client.chat.completions.create({ - stream: body.stream, - messages: body.messages as Groq.Chat.ChatCompletionMessageParam[], - model: body.model, - temperature: body.temperature, - max_tokens: body.max_tokens, - top_p: body.top_p, - stop: body.stop, - n: body.n, - response_format: body.response_format, - }) + return client.chat.completions.create(body) } }