mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-01-22 10:55:34 +00:00
Merge pull request #314 from ahsan3219/main
Huggingface Models Integrated
This commit is contained in:
commit
aac9a986cc
@ -5,6 +5,12 @@
|
||||
# You only need this environment variable set if you want to use Groq models
|
||||
GROQ_API_KEY=
|
||||
|
||||
# Get your HuggingFace API Key here -
|
||||
# https://huggingface.co/settings/tokens
|
||||
# You only need this environment variable set if you want to use HuggingFace models
|
||||
HuggingFace_API_KEY=
|
||||
|
||||
|
||||
# Get your Open AI API Key by following these instructions -
|
||||
# https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key
|
||||
# You only need this environment variable set if you want to use GPT models
|
||||
|
@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx commitlint --edit $1
|
||||
|
||||
exit 0
|
@ -72,6 +72,7 @@ pnpm install
|
||||
- Add your LLM API keys (only set the ones you plan to use):
|
||||
```bash
|
||||
GROQ_API_KEY=XXX
|
||||
HuggingFace_API_KEY=XXX
|
||||
OPENAI_API_KEY=XXX
|
||||
ANTHROPIC_API_KEY=XXX
|
||||
...
|
||||
|
@ -19,6 +19,7 @@ FROM base AS bolt-ai-production
|
||||
|
||||
# Define environment variables with default values or let them be overridden
|
||||
ARG GROQ_API_KEY
|
||||
ARG HuggingFace_API_KEY
|
||||
ARG OPENAI_API_KEY
|
||||
ARG ANTHROPIC_API_KEY
|
||||
ARG OPEN_ROUTER_API_KEY
|
||||
@ -28,6 +29,7 @@ ARG VITE_LOG_LEVEL=debug
|
||||
|
||||
ENV WRANGLER_SEND_METRICS=false \
|
||||
GROQ_API_KEY=${GROQ_API_KEY} \
|
||||
HuggingFace_KEY=${HuggingFace_API_KEY} \
|
||||
OPENAI_API_KEY=${OPENAI_API_KEY} \
|
||||
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \
|
||||
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \
|
||||
@ -48,6 +50,7 @@ FROM base AS bolt-ai-development
|
||||
|
||||
# Define the same environment variables for development
|
||||
ARG GROQ_API_KEY
|
||||
ARG HuggingFace
|
||||
ARG OPENAI_API_KEY
|
||||
ARG ANTHROPIC_API_KEY
|
||||
ARG OPEN_ROUTER_API_KEY
|
||||
@ -56,6 +59,7 @@ ARG OLLAMA_API_BASE_URL
|
||||
ARG VITE_LOG_LEVEL=debug
|
||||
|
||||
ENV GROQ_API_KEY=${GROQ_API_KEY} \
|
||||
HuggingFace_API_KEY=${HuggingFace_API_KEY} \
|
||||
OPENAI_API_KEY=${OPENAI_API_KEY} \
|
||||
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \
|
||||
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \
|
||||
|
@ -23,6 +23,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
|
||||
return env.GOOGLE_GENERATIVE_AI_API_KEY || cloudflareEnv.GOOGLE_GENERATIVE_AI_API_KEY;
|
||||
case 'Groq':
|
||||
return env.GROQ_API_KEY || cloudflareEnv.GROQ_API_KEY;
|
||||
case 'HuggingFace':
|
||||
return env.HuggingFace_API_KEY || cloudflareEnv.HuggingFace_API_KEY;
|
||||
case 'OpenRouter':
|
||||
return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY;
|
||||
case 'Deepseek':
|
||||
|
@ -56,6 +56,15 @@ export function getGroqModel(apiKey: string, model: string) {
|
||||
return openai(model);
|
||||
}
|
||||
|
||||
export function getHuggingFaceModel(apiKey: string, model: string) {
|
||||
const openai = createOpenAI({
|
||||
baseURL: 'https://api-inference.huggingface.co/v1/',
|
||||
apiKey,
|
||||
});
|
||||
|
||||
return openai(model);
|
||||
}
|
||||
|
||||
export function getOllamaModel(baseURL: string, model: string) {
|
||||
let Ollama = ollama(model, {
|
||||
numCtx: 32768,
|
||||
@ -110,6 +119,8 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
|
||||
return getOpenAIModel(apiKey, model);
|
||||
case 'Groq':
|
||||
return getGroqModel(apiKey, model);
|
||||
case 'HuggingFace':
|
||||
return getHuggingFaceModel(apiKey, model);
|
||||
case 'OpenRouter':
|
||||
return getOpenRouterModel(apiKey, model);
|
||||
case 'Google':
|
||||
|
@ -71,7 +71,19 @@ const PROVIDER_LIST: ProviderInfo[] = [
|
||||
{ name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq' }
|
||||
],
|
||||
getApiKeyLink: 'https://console.groq.com/keys'
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: 'HuggingFace',
|
||||
staticModels: [
|
||||
{ name: 'Qwen/Qwen2.5-Coder-32B-Instruct', label: 'Qwen2.5-Coder-32B-Instruct (HuggingFace)', provider: 'HuggingFace' },
|
||||
{ name: '01-ai/Yi-1.5-34B-Chat', label: 'Yi-1.5-34B-Chat (HuggingFace)', provider: 'HuggingFace' },
|
||||
{ name: 'codellama/CodeLlama-34b-Instruct-hf', label: 'CodeLlama-34b-Instruct (HuggingFace)', provider: 'HuggingFace' },
|
||||
{ name: 'NousResearch/Hermes-3-Llama-3.1-8B', label: 'Hermes-3-Llama-3.1-8B (HuggingFace)', provider: 'HuggingFace' }
|
||||
],
|
||||
getApiKeyLink: 'https://huggingface.co/settings/tokens'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'OpenAI',
|
||||
staticModels: [
|
||||
{ name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAI' },
|
||||
|
@ -14,6 +14,7 @@ services:
|
||||
# No strictly neded but serving as hints for Coolify
|
||||
- PORT=5173
|
||||
- GROQ_API_KEY=${GROQ_API_KEY}
|
||||
- HuggingFace_API_KEY=${HuggingFace_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
|
||||
@ -40,6 +41,7 @@ services:
|
||||
- WATCHPACK_POLLING=true
|
||||
- PORT=5173
|
||||
- GROQ_API_KEY=${GROQ_API_KEY}
|
||||
- HuggingFace_API_KEY=${HuggingFace_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
|
||||
|
1
worker-configuration.d.ts
vendored
1
worker-configuration.d.ts
vendored
@ -2,6 +2,7 @@ interface Env {
|
||||
ANTHROPIC_API_KEY: string;
|
||||
OPENAI_API_KEY: string;
|
||||
GROQ_API_KEY: string;
|
||||
HuggingFace_API_KEY: string;
|
||||
OPEN_ROUTER_API_KEY: string;
|
||||
OLLAMA_API_BASE_URL: string;
|
||||
OPENAI_LIKE_API_KEY: string;
|
||||
|
Loading…
Reference in New Issue
Block a user