-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`.
- Loading branch information
1 parent
eda10b1
commit fdefd71
Showing
6 changed files
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// see https://docs.anthropic.com/en/docs/about-claude/models | ||
export const MAX_TOKENS = 8192; | ||
|
||
// limits the number of model responses that can be returned in a single request | ||
export const MAX_RESPONSE_SEGMENTS = 2; | ||
|
||
export const GROQ_MAX_TOKENS = 4096; | ||
export const GROQ_MAX_RESPONSE_SEGMENTS = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import { createAnthropic } from '@ai-sdk/anthropic'; | ||
import { createGroq } from 'groq'; | ||
|
||
export function getAnthropicModel(apiKey: string) { | ||
const anthropic = createAnthropic({ | ||
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 anthropic('claude-3-5-sonnet-20240620'); | ||
return groq('llama3.3-70b'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters