Skip to content
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

✨ feat: Add Fireworks AI Model Provider #3392

Merged
merged 32 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5ba4faf
✨ feat: Add Fireworks AI Model Provider
hezhijie0327 Aug 3, 2024
04e3436
💄 style: add FireworksAI self-models
hezhijie0327 Aug 4, 2024
c8422f4
🐛 fix: support function call
hezhijie0327 Aug 4, 2024
4f65076
Revert "🐛 fix: support function call" (#48)
hezhijie0327 Aug 4, 2024
d33a5a4
💄 style: update model info
hezhijie0327 Aug 4, 2024
4ff60a3
🐛 fix: disable stream if contains tools
hezhijie0327 Aug 4, 2024
85952a0
👷 build: add ENV for Fireworks AI provider
hezhijie0327 Aug 4, 2024
a968889
Merge branch 'main' into fireworksai
hezhijie0327 Aug 5, 2024
300991c
Merge branch 'lobehub:main' into fireworksai
hezhijie0327 Aug 17, 2024
990d3c5
👷 build: update ENV
hezhijie0327 Aug 17, 2024
64932a3
✨ feat: support proxy url
hezhijie0327 Aug 17, 2024
4abe240
🐛 fix: fix typo
hezhijie0327 Aug 17, 2024
c624615
Merge branch 'main' into fireworksai
hezhijie0327 Aug 18, 2024
ff2c206
Merge branch 'main' into fireworksai
hezhijie0327 Aug 18, 2024
fba0c6a
Merge branch 'main' into fireworksai
hezhijie0327 Aug 27, 2024
059c648
Update providers.tsx
hezhijie0327 Aug 28, 2024
8f3499c
♻️ refactor: cleanup
hezhijie0327 Aug 28, 2024
814bce2
Merge branch 'main' into fireworksai
hezhijie0327 Aug 28, 2024
adb3354
🔨 chore: remove proxyUrl for FireworksAI
hezhijie0327 Aug 30, 2024
e2828e9
Merge branch 'main' into fireworksai
hezhijie0327 Sep 1, 2024
ff254ee
Merge branch 'main' into fireworksai
hezhijie0327 Sep 1, 2024
90d33d6
Merge branch 'main' into fireworksai
hezhijie0327 Sep 1, 2024
c4fd739
Merge branch 'main' into fireworksai
hezhijie0327 Sep 6, 2024
e12fc05
🐛 fix: tools calling issue in Fireworks AI
hezhijie0327 Sep 7, 2024
2ebfd8c
🔨 chore: remove work around method for tool calling
hezhijie0327 Sep 7, 2024
8c9eb74
🔨 chore: rollback changes
hezhijie0327 Sep 10, 2024
0a88ec8
Merge branch 'main' into fireworksai
hezhijie0327 Sep 10, 2024
d14d30b
🐛 fix: fix CI error
hezhijie0327 Sep 10, 2024
a98e07b
💄 style: update model list
hezhijie0327 Sep 10, 2024
f2ba16c
Merge branch 'main' into fireworksai
hezhijie0327 Sep 10, 2024
e3291d4
🔨 chore: fix rebase conflicts
hezhijie0327 Sep 10, 2024
34506d8
Merge branch 'main' into fireworksai
hezhijie0327 Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ ENV \
BAICHUAN_API_KEY="" \
# DeepSeek
DEEPSEEK_API_KEY="" \
# Fireworks AI
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
# Google
GOOGLE_API_KEY="" GOOGLE_PROXY_URL="" \
# Groq
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ ENV \
BAICHUAN_API_KEY="" \
# DeepSeek
DEEPSEEK_API_KEY="" \
# Fireworks AI
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
# Google
GOOGLE_API_KEY="" GOOGLE_PROXY_URL="" \
# Groq
Expand Down
2 changes: 2 additions & 0 deletions src/app/(main)/settings/llm/ProviderList/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AnthropicProviderCard,
BaichuanProviderCard,
DeepSeekProviderCard,
FireworksAIProviderCard,
GoogleProviderCard,
GroqProviderCard,
MinimaxProviderCard,
Expand Down Expand Up @@ -47,6 +48,7 @@ export const useProviderList = (): ProviderItem[] => {
OpenRouterProviderCard,
NovitaProviderCard,
TogetherAIProviderCard,
FireworksAIProviderCard,
QwenProviderCard,
DeepSeekProviderCard,
MinimaxProviderCard,
Expand Down
7 changes: 7 additions & 0 deletions src/app/api/chat/agentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {

return { apiKey };
}
case ModelProvider.FireworksAI: {
const { FIREWORKSAI_API_KEY } = getLLMConfig();

const apiKey = apiKeyManager.pick(payload?.apiKey || FIREWORKSAI_API_KEY);

return { apiKey };
}
case ModelProvider.ZeroOne: {
const { ZEROONE_API_KEY } = getLLMConfig();

Expand Down
8 changes: 8 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const getLLMConfig = () => {
TOGETHERAI_API_KEY: z.string().optional(),
TOGETHERAI_MODEL_LIST: z.string().optional(),

ENABLED_FIREWORKSAI: z.boolean(),
FIREWORKSAI_API_KEY: z.string().optional(),
FIREWORKSAI_MODEL_LIST: z.string().optional(),

ENABLED_AWS_BEDROCK: z.boolean(),
AWS_BEDROCK_MODEL_LIST: z.string().optional(),
AWS_REGION: z.string().optional(),
Expand Down Expand Up @@ -149,6 +153,10 @@ export const getLLMConfig = () => {
TOGETHERAI_API_KEY: process.env.TOGETHERAI_API_KEY,
TOGETHERAI_MODEL_LIST: process.env.TOGETHERAI_MODEL_LIST,

ENABLED_FIREWORKSAI: !!process.env.FIREWORKSAI_API_KEY,
FIREWORKSAI_API_KEY: process.env.FIREWORKSAI_API_KEY,
FIREWORKSAI_MODEL_LIST: process.env.FIREWORKSAI_MODEL_LIST,

ENABLED_MOONSHOT: !!process.env.MOONSHOT_API_KEY,
MOONSHOT_API_KEY: process.env.MOONSHOT_API_KEY,
MOONSHOT_PROXY_URL: process.env.MOONSHOT_PROXY_URL,
Expand Down
143 changes: 143 additions & 0 deletions src/config/modelProviders/fireworksai.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { ModelProviderCard } from '@/types/llm';

// ref https://fireworks.ai/models?show=Serverless
// ref https://fireworks.ai/pricing
const FireworksAI: ModelProviderCard = {
chatModels: [
{
description: 'Fireworks latest and most performant function-calling model. Firefunction-v2 is based on Llama-3 and trained to excel at function-calling as well as chat and instruction-following. See blog post for more details https://fireworks.ai/blog/firefunction-v2-launch-post',
displayName: 'Firefunction V2',
enabled: true,
functionCall: true,
id: 'accounts/fireworks/models/firefunction-v2',
tokens: 8192,
},
{
description: 'Fireworks open-source function calling model.',
displayName: 'Firefunction V1',
functionCall: true,
id: 'accounts/fireworks/models/firefunction-v1',
tokens: 32_768,
},
{
description: 'Vision-language model allowing both image and text as inputs (single image is recommended), trained on OSS model generated training data and open sourced on huggingface at fireworks-ai/FireLLaVA-13b',
displayName: 'FireLLaVA-13B',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/firellava-13b',
tokens: 4096,
vision: true,
},
{
displayName: 'Llama 3.1 8B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/llama-v3p1-8b-instruct',
tokens: 131_072,
},
{
displayName: 'Llama 3.1 70B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/llama-v3p1-70b-instruct',
tokens: 131_072,
},
{
displayName: 'Llama 3.1 405B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/llama-v3p1-405b-instruct',
tokens: 131_072,
},
{
displayName: 'Llama 3 8B Instruct',
functionCall: false,
id: 'accounts/fireworks/models/llama-v3-8b-instruct',
tokens: 8192,
},
{
displayName: 'Llama 3 70B Instruct',
functionCall: false,
id: 'accounts/fireworks/models/llama-v3-70b-instruct',
tokens: 8192,
},
{
displayName: 'Llama 3 8B Instruct (HF version)',
functionCall: false,
id: 'accounts/fireworks/models/llama-v3-8b-instruct-hf',
tokens: 8192,
},
{
displayName: 'Llama 3 70B Instruct (HF version)',
functionCall: false,
id: 'accounts/fireworks/models/llama-v3-70b-instruct-hf',
tokens: 8192,
},
{
displayName: 'Gemma 2 9B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/gemma2-9b-it',
tokens: 8192,
},
{
displayName: 'Mixtral MoE 8x7B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/mixtral-8x7b-instruct',
tokens: 32_768,
},
{
displayName: 'Mixtral MoE 8x22B Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/mixtral-8x22b-instruct',
tokens: 65_536,
},
{
displayName: 'Mixtral MoE 8x7B Instruct (HF version)',
functionCall: false,
id: 'accounts/fireworks/models/mixtral-8x7b-instruct-hf',
tokens: 32_768,
},
{
displayName: 'Phi 3 Vision Instruct',
enabled: true,
functionCall: false,
id: 'accounts/fireworks/models/phi-3-vision-128k-instruct',
tokens: 8192,
vision: true,
},
{
displayName: 'Yi-Large',
enabled: true,
functionCall: false,
id: 'accounts/yi-01-ai/models/yi-large',
tokens: 32_768,
},
{
displayName: 'StarCoder 7B',
functionCall: false,
id: 'accounts/fireworks/models/starcoder-7b',
tokens: 8192,
},
{
displayName: 'StarCoder 15.5B',
functionCall: false,
id: 'accounts/fireworks/models/starcoder-16b',
tokens: 8192,
},
{
displayName: 'MythoMax L2 13b',
functionCall: false,
id: 'accounts/fireworks/models/mythomax-l2-13b',
tokens: 4096,
},
],
checkModel: 'accounts/fireworks/models/firefunction-v2',
id: 'fireworksai',
modelList: { showModelFetcher: true },
name: 'Fireworks AI',
};

export default FireworksAI;
4 changes: 4 additions & 0 deletions src/config/modelProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AzureProvider from './azure';
import BaichuanProvider from './baichuan';
import BedrockProvider from './bedrock';
import DeepSeekProvider from './deepseek';
import FireworksAIProvider from './fireworksai';
import GoogleProvider from './google';
import GroqProvider from './groq';
import MinimaxProvider from './minimax';
Expand Down Expand Up @@ -39,6 +40,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
OllamaProvider.chatModels,
OpenRouterProvider.chatModels,
TogetherAIProvider.chatModels,
FireworksAIProvider.chatModels,
PerplexityProvider.chatModels,
AnthropicProvider.chatModels,
ZeroOneProvider.chatModels,
Expand All @@ -61,6 +63,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
GoogleProvider,
OpenRouterProvider,
TogetherAIProvider,
FireworksAIProvider,
BedrockProvider,
PerplexityProvider,
MinimaxProvider,
Expand Down Expand Up @@ -93,6 +96,7 @@ export { default as AzureProviderCard } from './azure';
export { default as BaichuanProviderCard } from './baichuan';
export { default as BedrockProviderCard } from './bedrock';
export { default as DeepSeekProviderCard } from './deepseek';
export { default as FireworksAIProviderCard } from './fireworksai';
export { default as GoogleProviderCard } from './google';
export { default as GroqProviderCard } from './groq';
export { default as MinimaxProviderCard } from './minimax';
Expand Down
5 changes: 5 additions & 0 deletions src/const/settings/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
BaichuanProviderCard,
BedrockProviderCard,
DeepSeekProviderCard,
FireworksAIProviderCard,
GoogleProviderCard,
GroqProviderCard,
MinimaxProviderCard,
Expand Down Expand Up @@ -51,6 +52,10 @@ export const DEFAULT_LLM_CONFIG: UserModelProviderConfig = {
enabled: false,
enabledModels: filterEnabledModels(DeepSeekProviderCard),
},
fireworksai: {
enabled: false,
enabledModels: filterEnabledModels(FireworksAIProviderCard),
},
google: {
enabled: false,
enabledModels: filterEnabledModels(GoogleProviderCard),
Expand Down
7 changes: 7 additions & 0 deletions src/libs/agent-runtime/AgentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LobeAzureOpenAI } from './azureOpenai';
import { LobeBaichuanAI } from './baichuan';
import { LobeBedrockAI, LobeBedrockAIParams } from './bedrock';
import { LobeDeepSeekAI } from './deepseek';
import { LobeFireworksAI } from './fireworksai';
import { LobeGoogleAI } from './google';
import { LobeGroq } from './groq';
import { LobeMinimaxAI } from './minimax';
Expand Down Expand Up @@ -120,6 +121,7 @@ class AgentRuntime {
baichuan: Partial<ClientOptions>;
bedrock: Partial<LobeBedrockAIParams>;
deepseek: Partial<ClientOptions>;
fireworksai: Partial<ClientOptions>;
google: { apiKey?: string; baseURL?: string };
groq: Partial<ClientOptions>;
minimax: Partial<ClientOptions>;
Expand Down Expand Up @@ -224,6 +226,11 @@ class AgentRuntime {
break;
}

case ModelProvider.FireworksAI: {
runtimeModel = new LobeFireworksAI(params.fireworksai);
break
}

case ModelProvider.ZeroOne: {
runtimeModel = new LobeZeroOneAI(params.zeroone);
break;
Expand Down
Loading
Loading