-
-
Notifications
You must be signed in to change notification settings - Fork 133
adapter/groq #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dhamivibez
wants to merge
17
commits into
TanStack:main
Choose a base branch
from
dhamivibez:adapter/groq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,606
β0
Open
adapter/groq #298
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d3f5312
feat(adapter): add Groq adapter package @tanstack/ai-groq
dhamivibez 849f629
feat(types): add Groq message types and model metadata
dhamivibez 67127a8
feat(utils): add Groq utility functions and schema converter
dhamivibez b8a4b8c
feat: add Groq adapter for text generation with streaming and tool caβ¦
dhamivibez 2aca303
test: add Groq text adapter tests covering adapter creation, configurβ¦
dhamivibez 1cf7f2b
remove empty string fallback for `delta` property in text adapter.
dhamivibez 0b970cc
chore: remove packageManager field from package.json
dhamivibez 27a4e81
feat: Add README for the `@tanstack/ai-groq` package, detailing instaβ¦
dhamivibez 2531cec
refactor: remove redundant type assertions and utilize `ChatCompletioβ¦
dhamivibez 30d7754
fix: map 'length' as a finish reason in the groq text adapter.
dhamivibez 96bba18
refactor: apply 'as const' assertion to the array of supported Groq cβ¦
dhamivibez 447aa73
feat: add image input support for "LLAMA_4_SCOUT_17B_16E_INSTRUCT" inβ¦
dhamivibez 2cda3de
feat: add 'tools' feature to the `moonshotai/kimi-k2-instruct-0905` mβ¦
dhamivibez 8805822
feat: add tools support for the GPT_OSS_20B model.
dhamivibez 9fa8f0d
feat: add `json_object` support for qwen 3 32b model
dhamivibez 1ef9470
fix: skip tool calls that have not started or doesn't have an id or nβ¦
dhamivibez 373a3df
Merge branch 'main' into adapter/groq
AlemTuzlak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # @tanstack/ai-groq | ||
|
|
||
| Groq adapter for TanStack AI | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @tanstack/ai-groq | ||
| # or | ||
| pnpm add @tanstack/ai-groq | ||
| # or | ||
| yarn add @tanstack/ai-groq | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| Get your API key from [Groq Console](https://console.groq.com) and set it as an environment variable: | ||
|
|
||
| ```bash | ||
| export GROQ_API_KEY="gsk_..." | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Text/Chat Adapter | ||
|
|
||
| ```typescript | ||
| import { groqText } from '@tanstack/ai-groq' | ||
| import { generate } from '@tanstack/ai' | ||
|
|
||
| const adapter = groqText('llama-3.3-70b-versatile') | ||
|
|
||
| const result = await generate({ | ||
| adapter, | ||
| model: 'llama-3.3-70b-versatile', | ||
| messages: [ | ||
| { role: 'user', content: 'Explain quantum computing in simple terms' }, | ||
| ], | ||
| }) | ||
|
|
||
| console.log(result.text) | ||
| ``` | ||
|
|
||
| ### With Explicit API Key | ||
|
|
||
| ```typescript | ||
| import { createGroqText } from '@tanstack/ai-groq' | ||
|
|
||
| const adapter = createGroqText('llama-3.3-70b-versatile', 'gsk_api_key') | ||
| ``` | ||
|
|
||
| ## Supported Models | ||
|
|
||
| ### Chat Models | ||
|
|
||
| - `llama-3.3-70b-versatile` - Meta Llama 3.3 70B (131k context) | ||
| - `llama-3.1-8b-instant` - Meta Llama 3.1 8B (131k context) | ||
| - `meta-llama/llama-4-maverick-17b-128e-instruct` - Meta Llama 4 Maverick (vision) | ||
| - `meta-llama/llama-4-scout-17b-16e-instruct` - Meta Llama 4 Scout | ||
| - `meta-llama/llama-guard-4-12b` - Meta Llama Guard 4 (content moderation, vision) | ||
| - `meta-llama/llama-prompt-guard-2-86m` - Meta Llama Prompt Guard (content moderation) | ||
| - `meta-llama/llama-prompt-guard-2-22m` - Meta Llama Prompt Guard (content moderation) | ||
| - `openai/gpt-oss-120b` - GPT OSS 120B (reasoning, tools, search) | ||
| - `openai/gpt-oss-20b` - GPT OSS 20B (reasoning, search) | ||
| - `openai/gpt-oss-safeguard-20b` - GPT OSS Safeguard 20B (content moderation, reasoning) | ||
| - `moonshotai/kimi-k2-instruct-0905` - Kimi K2 Instruct (262k context) | ||
| - `qwen/qwen3-32b` - Qwen3 32B (reasoning, tools) | ||
|
|
||
| ## Features | ||
|
|
||
| - β Streaming chat completions | ||
| - β Structured output (JSON Schema) | ||
| - β Function/tool calling | ||
| - β Multimodal input (text + images for vision models) | ||
| - β Embeddings (not supported by Groq) | ||
| - β Image generation (not supported by Groq) | ||
|
|
||
| ## Tree-Shakeable Adapters | ||
|
|
||
| This package uses tree-shakeable adapters, so you only import what you need: | ||
|
|
||
| ```typescript | ||
| // Only imports text adapter | ||
| import { groqText } from '@tanstack/ai-groq' | ||
| ``` | ||
|
|
||
| This keeps your bundle size small! | ||
|
|
||
| ## License | ||
|
|
||
| MIT | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "@tanstack/ai-groq", | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "description": "Groq adapter for TanStack AI", | ||
| "author": "", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/ai.git", | ||
| "directory": "packages/typescript/ai-groq" | ||
| }, | ||
| "module": "./dist/esm/index.js", | ||
| "types": "./dist/esm/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "import": "./dist/esm/index.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "clean": "premove ./build ./dist", | ||
| "lint:fix": "eslint ./src --fix", | ||
| "test:build": "publint --strict", | ||
| "test:eslint": "eslint ./src", | ||
| "test:lib": "vitest run", | ||
| "test:lib:dev": "pnpm test:lib --watch", | ||
| "test:types": "tsc" | ||
| }, | ||
| "keywords": [ | ||
| "ai", | ||
| "groq", | ||
| "tanstack", | ||
| "adapter" | ||
| ], | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "4.0.14", | ||
| "vite": "^7.2.7" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tanstack/ai": "workspace:^", | ||
| "zod": "^4.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "groq-sdk": "^0.37.0" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant