Huggingface Models Integrated

This commit is contained in:
ahsan3219 2024-11-18 04:49:02 +05:00
parent b7d609d315
commit 7bf9c5c1b6
10 changed files with 9295 additions and 9 deletions

View File

@ -5,6 +5,12 @@
# You only need this environment variable set if you want to use Groq models # You only need this environment variable set if you want to use Groq models
GROQ_API_KEY= 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 - # 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 # 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 # You only need this environment variable set if you want to use GPT models

View File

@ -1,7 +0,0 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
npx commitlint --edit $1
exit 0

View File

@ -72,6 +72,7 @@ pnpm install
- Add your LLM API keys (only set the ones you plan to use): - Add your LLM API keys (only set the ones you plan to use):
```bash ```bash
GROQ_API_KEY=XXX GROQ_API_KEY=XXX
HuggingFace_API_KEY=XXX
OPENAI_API_KEY=XXX OPENAI_API_KEY=XXX
ANTHROPIC_API_KEY=XXX ANTHROPIC_API_KEY=XXX
... ...

View File

@ -19,6 +19,7 @@ FROM base AS bolt-ai-production
# Define environment variables with default values or let them be overridden # Define environment variables with default values or let them be overridden
ARG GROQ_API_KEY ARG GROQ_API_KEY
ARG HuggingFace_API_KEY
ARG OPENAI_API_KEY ARG OPENAI_API_KEY
ARG ANTHROPIC_API_KEY ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY ARG OPEN_ROUTER_API_KEY
@ -28,6 +29,7 @@ ARG VITE_LOG_LEVEL=debug
ENV WRANGLER_SEND_METRICS=false \ ENV WRANGLER_SEND_METRICS=false \
GROQ_API_KEY=${GROQ_API_KEY} \ GROQ_API_KEY=${GROQ_API_KEY} \
HuggingFace_KEY=${HuggingFace_API_KEY} \
OPENAI_API_KEY=${OPENAI_API_KEY} \ OPENAI_API_KEY=${OPENAI_API_KEY} \
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \ ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_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 # Define the same environment variables for development
ARG GROQ_API_KEY ARG GROQ_API_KEY
ARG HuggingFace
ARG OPENAI_API_KEY ARG OPENAI_API_KEY
ARG ANTHROPIC_API_KEY ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY ARG OPEN_ROUTER_API_KEY
@ -56,6 +59,7 @@ ARG OLLAMA_API_BASE_URL
ARG VITE_LOG_LEVEL=debug ARG VITE_LOG_LEVEL=debug
ENV GROQ_API_KEY=${GROQ_API_KEY} \ ENV GROQ_API_KEY=${GROQ_API_KEY} \
HuggingFace_API_KEY=${HuggingFace_API_KEY} \
OPENAI_API_KEY=${OPENAI_API_KEY} \ OPENAI_API_KEY=${OPENAI_API_KEY} \
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \ ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \ OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \

View File

@ -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; return env.GOOGLE_GENERATIVE_AI_API_KEY || cloudflareEnv.GOOGLE_GENERATIVE_AI_API_KEY;
case 'Groq': case 'Groq':
return env.GROQ_API_KEY || cloudflareEnv.GROQ_API_KEY; return env.GROQ_API_KEY || cloudflareEnv.GROQ_API_KEY;
case 'HuggingFace':
return env.HuggingFace_API_KEY || cloudflareEnv.HuggingFace_API_KEY;
case 'OpenRouter': case 'OpenRouter':
return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY; return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY;
case 'Deepseek': case 'Deepseek':

View File

@ -56,6 +56,15 @@ export function getGroqModel(apiKey: string, model: string) {
return openai(model); 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) { export function getOllamaModel(baseURL: string, model: string) {
let Ollama = ollama(model, { let Ollama = ollama(model, {
numCtx: 32768, numCtx: 32768,
@ -110,6 +119,8 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
return getOpenAIModel(apiKey, model); return getOpenAIModel(apiKey, model);
case 'Groq': case 'Groq':
return getGroqModel(apiKey, model); return getGroqModel(apiKey, model);
case 'HuggingFace':
return getHuggingFaceModel(apiKey, model);
case 'OpenRouter': case 'OpenRouter':
return getOpenRouterModel(apiKey, model); return getOpenRouterModel(apiKey, model);
case 'Google': case 'Google':

View File

@ -71,7 +71,19 @@ const PROVIDER_LIST: ProviderInfo[] = [
{ name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq' } { name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq' }
], ],
getApiKeyLink: 'https://console.groq.com/keys' 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', name: 'OpenAI',
staticModels: [ staticModels: [
{ name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAI' }, { name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAI' },

View File

@ -14,6 +14,7 @@ services:
# No strictly neded but serving as hints for Coolify # No strictly neded but serving as hints for Coolify
- PORT=5173 - PORT=5173
- GROQ_API_KEY=${GROQ_API_KEY} - GROQ_API_KEY=${GROQ_API_KEY}
- HuggingFace_API_KEY=${HuggingFace_API_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
@ -40,6 +41,7 @@ services:
- WATCHPACK_POLLING=true - WATCHPACK_POLLING=true
- PORT=5173 - PORT=5173
- GROQ_API_KEY=${GROQ_API_KEY} - GROQ_API_KEY=${GROQ_API_KEY}
- HuggingFace_API_KEY=${HuggingFace_API_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}

View File

@ -2,6 +2,7 @@ interface Env {
ANTHROPIC_API_KEY: string; ANTHROPIC_API_KEY: string;
OPENAI_API_KEY: string; OPENAI_API_KEY: string;
GROQ_API_KEY: string; GROQ_API_KEY: string;
HuggingFace_API_KEY: string;
OPEN_ROUTER_API_KEY: string; OPEN_ROUTER_API_KEY: string;
OLLAMA_API_BASE_URL: string; OLLAMA_API_BASE_URL: string;
OPENAI_LIKE_API_KEY: string; OPENAI_LIKE_API_KEY: string;

9254
yarn.lock Normal file

File diff suppressed because it is too large Load Diff