-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(providers): add Fireworks AI provider integration #3873
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7dd6584
feat(providers): add Fireworks AI provider integration
waleedlatif1 fc2c7f3
fix(providers): remove unused logger and dead modelInfo from fireworks
waleedlatif1 15e4553
lint
waleedlatif1 4affc19
feat(providers): add Fireworks BYOK support and official icon
waleedlatif1 abae75f
fix(providers): add workspace membership check and remove shared fetc…
waleedlatif1 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
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,93 @@ | ||
| import { createLogger } from '@sim/logger' | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { getBYOKKey } from '@/lib/api-key/byok' | ||
| import { getSession } from '@/lib/auth' | ||
| import { env } from '@/lib/core/config/env' | ||
| import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils' | ||
| import { filterBlacklistedModels, isProviderBlacklisted } from '@/providers/utils' | ||
|
|
||
| const logger = createLogger('FireworksModelsAPI') | ||
|
|
||
| interface FireworksModel { | ||
| id: string | ||
| object?: string | ||
| created?: number | ||
| owned_by?: string | ||
| } | ||
|
|
||
| interface FireworksModelsResponse { | ||
| data: FireworksModel[] | ||
| object?: string | ||
| } | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| if (isProviderBlacklisted('fireworks')) { | ||
| logger.info('Fireworks provider is blacklisted, returning empty models') | ||
| return NextResponse.json({ models: [] }) | ||
| } | ||
|
|
||
| let apiKey: string | undefined | ||
|
|
||
| const workspaceId = request.nextUrl.searchParams.get('workspaceId') | ||
| if (workspaceId) { | ||
| const session = await getSession() | ||
| if (session?.user?.id) { | ||
| const permission = await getUserEntityPermissions(session.user.id, 'workspace', workspaceId) | ||
| if (permission) { | ||
| const byokResult = await getBYOKKey(workspaceId, 'fireworks') | ||
| if (byokResult) { | ||
| apiKey = byokResult.apiKey | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!apiKey) { | ||
| apiKey = env.FIREWORKS_API_KEY | ||
| } | ||
|
|
||
| if (!apiKey) { | ||
| logger.info('No Fireworks API key available, returning empty models') | ||
| return NextResponse.json({ models: [] }) | ||
| } | ||
|
|
||
| try { | ||
| const response = await fetch('https://api.fireworks.ai/inference/v1/models', { | ||
| headers: { | ||
| Authorization: `Bearer ${apiKey}`, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| cache: 'no-store', | ||
| }) | ||
waleedlatif1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (!response.ok) { | ||
| logger.warn('Failed to fetch Fireworks models', { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| }) | ||
| return NextResponse.json({ models: [] }) | ||
| } | ||
|
|
||
| const data = (await response.json()) as FireworksModelsResponse | ||
|
|
||
| const allModels: string[] = [] | ||
| for (const model of data.data ?? []) { | ||
| allModels.push(`fireworks/${model.id}`) | ||
| } | ||
|
|
||
| const uniqueModels = Array.from(new Set(allModels)) | ||
| const models = filterBlacklistedModels(uniqueModels) | ||
|
|
||
| logger.info('Successfully fetched Fireworks models', { | ||
| count: models.length, | ||
| filtered: uniqueModels.length - models.length, | ||
| }) | ||
|
|
||
| return NextResponse.json({ models }) | ||
| } catch (error) { | ||
| logger.error('Error fetching Fireworks models', { | ||
| error: error instanceof Error ? error.message : 'Unknown error', | ||
| }) | ||
| return NextResponse.json({ models: [] }) | ||
| } | ||
| } | ||
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.