mirror of
https://github.com/stackblitz/bolt.new
synced 2025-06-26 18:17:50 +00:00
Related to #4763 Add groq API support with groq SDK. * **Initialize groq instance**: Import `createGroq` from `groq` SDK and add `createGroqInstance`, `getGroqModel`, and `getGroqLlamaModel` functions in `app/lib/.server/llm/model.ts`. * **Stream text responses**: Import `getGroqModel` in `app/lib/.server/llm/stream-text.ts`, update `streamText` function to use `getGroqModel`, and set headers for the `groq` instance. * **Add constants**: Add constants for maximum tokens and response segments limits for the `groq` model in `app/lib/.server/llm/constants.ts`. * **Retrieve API key**: Update `getAPIKey` function in `app/lib/.server/llm/api-key.ts` to retrieve the API key for the `groq` model. * **Update routes**: Import `createGroq` in `app/routes/api.chat.ts` and `app/routes/api.enhancer.ts`.
20 lines
384 B
TypeScript
20 lines
384 B
TypeScript
import { createGroq } from 'groq';
|
|
|
|
export function createGroqInstance(apiKey: string) {
|
|
return createGroq({
|
|
apiKey,
|
|
});
|
|
}
|
|
|
|
export function getGroqModel(apiKey: string) {
|
|
const groq = createGroqInstance(apiKey);
|
|
|
|
return groq('groq-model');
|
|
}
|
|
|
|
export function getGroqLlamaModel(apiKey: string) {
|
|
const groq = createGroqInstance(apiKey);
|
|
|
|
return groq('llama3.3-70b');
|
|
}
|