feat: add Together AI integration and provider implementation guide

- Create detailed provider implementation guide with:
  - Architecture overview and implementation steps
  - Configuration patterns and best practices
  - Testing checklist and Docker integration guide
  - Example using Together AI implementation
- Add Together AI as new provider with:
  - Environment variables and Docker configuration
  - Support for Qwen, Llama, and Mixtral models
  - API key and base URL management
  - OpenAI-compatible API integration
This commit is contained in:
Martin Ouimet 2024-11-23 00:20:35 -05:00
parent 7fc8e40c03
commit 76cc7a8139
7 changed files with 43 additions and 0 deletions

View File

@ -38,12 +38,18 @@ OLLAMA_API_BASE_URL=
# You only need this environment variable set if you want to use OpenAI Like models # You only need this environment variable set if you want to use OpenAI Like models
OPENAI_LIKE_API_BASE_URL= OPENAI_LIKE_API_BASE_URL=
# You only need this environment variable set if you want to use Together AI models
TOGETHER_API_BASE_URL=
# You only need this environment variable set if you want to use DeepSeek models through their API # You only need this environment variable set if you want to use DeepSeek models through their API
DEEPSEEK_API_KEY= DEEPSEEK_API_KEY=
# Get your OpenAI Like API Key # Get your OpenAI Like API Key
OPENAI_LIKE_API_KEY= OPENAI_LIKE_API_KEY=
# Get your Together API Key
TOGATHER_API_KEY=
# Get your Mistral API Key by following these instructions - # Get your Mistral API Key by following these instructions -
# https://console.mistral.ai/api-keys/ # https://console.mistral.ai/api-keys/
# You only need this environment variable set if you want to use Mistral models # You only need this environment variable set if you want to use Mistral models

View File

@ -25,6 +25,8 @@ ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY ARG OPEN_ROUTER_API_KEY
ARG GOOGLE_GENERATIVE_AI_API_KEY ARG GOOGLE_GENERATIVE_AI_API_KEY
ARG OLLAMA_API_BASE_URL ARG OLLAMA_API_BASE_URL
ARG TOGETHER_API_KEY
ARG TOGETHER_API_BASE_URL
ARG VITE_LOG_LEVEL=debug ARG VITE_LOG_LEVEL=debug
ARG DEFAULT_NUM_CTX ARG DEFAULT_NUM_CTX
@ -36,6 +38,8 @@ ENV WRANGLER_SEND_METRICS=false \
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \ OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \
GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} \ GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} \
OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} \ OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} \
TOGETHER_API_KEY=${TOGETHER_API_KEY} \
TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL} \
VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \ VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \
DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX} DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX}
@ -58,6 +62,8 @@ ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY ARG OPEN_ROUTER_API_KEY
ARG GOOGLE_GENERATIVE_AI_API_KEY ARG GOOGLE_GENERATIVE_AI_API_KEY
ARG OLLAMA_API_BASE_URL ARG OLLAMA_API_BASE_URL
ARG TOGETHER_API_KEY
ARG TOGETHER_API_BASE_URL
ARG VITE_LOG_LEVEL=debug ARG VITE_LOG_LEVEL=debug
ARG DEFAULT_NUM_CTX ARG DEFAULT_NUM_CTX
@ -68,6 +74,8 @@ ENV GROQ_API_KEY=${GROQ_API_KEY} \
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \ OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \
GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} \ GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} \
OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} \ OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} \
TOGETHER_API_KEY=${TOGETHER_API_KEY} \
TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL} \
VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \ VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \
DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX} DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX}

View File

@ -35,6 +35,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
return env.MISTRAL_API_KEY || cloudflareEnv.MISTRAL_API_KEY; return env.MISTRAL_API_KEY || cloudflareEnv.MISTRAL_API_KEY;
case 'OpenAILike': case 'OpenAILike':
return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_API_KEY; return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_API_KEY;
case 'Together':
return env.TOGETHER_API_KEY || cloudflareEnv.TOGETHER_API_KEY;
case 'xAI': case 'xAI':
return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY; return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY;
case 'Cohere': case 'Cohere':
@ -48,6 +50,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
export function getBaseURL(cloudflareEnv: Env, provider: string) { export function getBaseURL(cloudflareEnv: Env, provider: string) {
switch (provider) { switch (provider) {
case 'Together':
return env.TOGETHER_API_BASE_URL || cloudflareEnv.TOGETHER_API_BASE_URL;
case 'OpenAILike': case 'OpenAILike':
return env.OPENAI_LIKE_API_BASE_URL || cloudflareEnv.OPENAI_LIKE_API_BASE_URL; return env.OPENAI_LIKE_API_BASE_URL || cloudflareEnv.OPENAI_LIKE_API_BASE_URL;
case 'LMStudio': case 'LMStudio':

View File

@ -146,6 +146,8 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
return getGoogleModel(apiKey, model); return getGoogleModel(apiKey, model);
case 'OpenAILike': case 'OpenAILike':
return getOpenAILikeModel(baseURL, apiKey, model); return getOpenAILikeModel(baseURL, apiKey, model);
case 'Together':
return getOpenAILikeModel(baseURL, apiKey, model);
case 'Deepseek': case 'Deepseek':
return getDeepseekModel(apiKey, model); return getDeepseekModel(apiKey, model);
case 'Mistral': case 'Mistral':

View File

@ -259,6 +259,23 @@ const PROVIDER_LIST: ProviderInfo[] = [
labelForGetApiKey: 'Get LMStudio', labelForGetApiKey: 'Get LMStudio',
icon: 'i-ph:cloud-arrow-down', icon: 'i-ph:cloud-arrow-down',
}, },
{
name: 'Together',
staticModels: [
{ name: 'Qwen/Qwen2.5-Coder-32B-Instruct', label: 'Qwen/Qwen2.5-Coder-32B-Instruct', provider: 'Together', maxTokenAllowed: 8000, },
{
name: 'meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo',
label: 'meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo',
provider: 'Together',
maxTokenAllowed: 8000,
},
{ name: 'mistralai/Mixtral-8x7B-Instruct-v0.1', label: 'Mixtral 8x7B Instruct', provider: 'Together', maxTokenAllowed: 8192 },
],
getApiKeyLink: 'https://api.together.xyz/settings/api-keys',
},
]; ];
export const DEFAULT_PROVIDER = PROVIDER_LIST[0]; export const DEFAULT_PROVIDER = PROVIDER_LIST[0];

View File

@ -20,6 +20,8 @@ services:
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
- GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} - GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY}
- OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} - OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL}
- TOGETHER_API_KEY=${TOGETHER_API_KEY}
- TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL}
- VITE_LOG_LEVEL=${VITE_LOG_LEVEL:-debug} - VITE_LOG_LEVEL=${VITE_LOG_LEVEL:-debug}
- DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX:-32768} - DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX:-32768}
- RUNNING_IN_DOCKER=true - RUNNING_IN_DOCKER=true
@ -48,6 +50,8 @@ services:
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
- GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} - GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY}
- OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} - OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL}
- TOGETHER_API_KEY=${TOGETHER_API_KEY}
- TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL}
- VITE_LOG_LEVEL=${VITE_LOG_LEVEL:-debug} - VITE_LOG_LEVEL=${VITE_LOG_LEVEL:-debug}
- DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX:-32768} - DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX:-32768}
- RUNNING_IN_DOCKER=true - RUNNING_IN_DOCKER=true

View File

@ -7,6 +7,8 @@ interface Env {
OLLAMA_API_BASE_URL: string; OLLAMA_API_BASE_URL: string;
OPENAI_LIKE_API_KEY: string; OPENAI_LIKE_API_KEY: string;
OPENAI_LIKE_API_BASE_URL: string; OPENAI_LIKE_API_BASE_URL: string;
TOGETHER_API_KEY: string;
TOGETHER_API_BASE_URL: string;
DEEPSEEK_API_KEY: string; DEEPSEEK_API_KEY: string;
LMSTUDIO_API_BASE_URL: string; LMSTUDIO_API_BASE_URL: string;
GOOGLE_GENERATIVE_AI_API_KEY: string; GOOGLE_GENERATIVE_AI_API_KEY: string;