mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-20 21:18:13 +02:00
feat(database-migrations): add migration to remove legacy model config tables and remove stale model connection code
This commit is contained in:
parent
50668775f8
commit
bd4a04f2e7
93 changed files with 956 additions and 11442 deletions
|
|
@ -1,105 +0,0 @@
|
|||
export interface ImageGenProvider {
|
||||
value: string;
|
||||
label: string;
|
||||
example: string;
|
||||
description: string;
|
||||
apiBase?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image generation providers supported by LiteLLM.
|
||||
* See: https://docs.litellm.ai/docs/image_generation#supported-providers
|
||||
*/
|
||||
export const IMAGE_GEN_PROVIDERS: ImageGenProvider[] = [
|
||||
{
|
||||
value: "OPENAI",
|
||||
label: "OpenAI",
|
||||
example: "dall-e-3, gpt-image-1, dall-e-2",
|
||||
description: "DALL-E and GPT Image models",
|
||||
},
|
||||
{
|
||||
value: "AZURE_OPENAI",
|
||||
label: "Azure OpenAI",
|
||||
example: "azure/dall-e-3, azure/gpt-image-1",
|
||||
description: "OpenAI image models on Azure",
|
||||
},
|
||||
{
|
||||
value: "GOOGLE",
|
||||
label: "Google AI Studio",
|
||||
example: "gemini/imagen-3.0-generate-002",
|
||||
description: "Google AI Studio image generation",
|
||||
},
|
||||
{
|
||||
value: "VERTEX_AI",
|
||||
label: "Google Vertex AI",
|
||||
example: "vertex_ai/imagegeneration@006",
|
||||
description: "Vertex AI image generation models",
|
||||
},
|
||||
{
|
||||
value: "BEDROCK",
|
||||
label: "AWS Bedrock",
|
||||
example: "bedrock/stability.stable-diffusion-xl-v0",
|
||||
description: "Stable Diffusion on AWS Bedrock",
|
||||
},
|
||||
{
|
||||
value: "RECRAFT",
|
||||
label: "Recraft",
|
||||
example: "recraft/recraftv3",
|
||||
description: "AI-powered design and image generation",
|
||||
},
|
||||
{
|
||||
value: "OPENROUTER",
|
||||
label: "OpenRouter",
|
||||
example: "openrouter/google/gemini-2.5-flash-image",
|
||||
description: "Image generation via OpenRouter",
|
||||
},
|
||||
{
|
||||
value: "XINFERENCE",
|
||||
label: "Xinference",
|
||||
example: "xinference/stable-diffusion-xl",
|
||||
description: "Self-hosted Stable Diffusion models",
|
||||
},
|
||||
{
|
||||
value: "NSCALE",
|
||||
label: "Nscale",
|
||||
example: "nscale/flux.1-schnell",
|
||||
description: "Nscale image generation",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Image generation models organized by provider.
|
||||
*/
|
||||
export interface ImageGenModel {
|
||||
value: string;
|
||||
label: string;
|
||||
provider: string;
|
||||
}
|
||||
|
||||
export const IMAGE_GEN_MODELS: ImageGenModel[] = [
|
||||
// OpenAI
|
||||
{ value: "gpt-image-1", label: "GPT Image 1", provider: "OPENAI" },
|
||||
{ value: "dall-e-3", label: "DALL-E 3", provider: "OPENAI" },
|
||||
{ value: "dall-e-2", label: "DALL-E 2", provider: "OPENAI" },
|
||||
// Azure OpenAI
|
||||
{ value: "azure/dall-e-3", label: "DALL-E 3 (Azure)", provider: "AZURE_OPENAI" },
|
||||
{ value: "azure/gpt-image-1", label: "GPT Image 1 (Azure)", provider: "AZURE_OPENAI" },
|
||||
// Recraft
|
||||
{ value: "recraft/recraftv3", label: "Recraft V3", provider: "RECRAFT" },
|
||||
// Bedrock
|
||||
{
|
||||
value: "bedrock/stability.stable-diffusion-xl-v0",
|
||||
label: "Stable Diffusion XL",
|
||||
provider: "BEDROCK",
|
||||
},
|
||||
// Vertex AI
|
||||
{
|
||||
value: "vertex_ai/imagegeneration@006",
|
||||
label: "Imagen 3",
|
||||
provider: "VERTEX_AI",
|
||||
},
|
||||
];
|
||||
|
||||
export function getImageGenModelsByProvider(provider: string): ImageGenModel[] {
|
||||
return IMAGE_GEN_MODELS.filter((m) => m.provider === provider);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,197 +0,0 @@
|
|||
export interface LLMProvider {
|
||||
value: string;
|
||||
label: string;
|
||||
example: string;
|
||||
description: string;
|
||||
apiBase?: string;
|
||||
}
|
||||
|
||||
export const LLM_PROVIDERS: LLMProvider[] = [
|
||||
{
|
||||
value: "OPENAI",
|
||||
label: "OpenAI",
|
||||
example: "gpt-4o, gpt-4o-mini, o1, o3-mini",
|
||||
description: "Industry-leading GPT models",
|
||||
},
|
||||
{
|
||||
value: "ANTHROPIC",
|
||||
label: "Anthropic",
|
||||
example: "claude-3-5-sonnet, claude-3-opus, claude-4-sonnet",
|
||||
description: "Claude models with strong reasoning",
|
||||
},
|
||||
{
|
||||
value: "GOOGLE",
|
||||
label: "Google (Gemini)",
|
||||
example: "gemini-2.5-flash, gemini-2.5-pro, gemini-1.5-pro",
|
||||
description: "Gemini models with multimodal capabilities",
|
||||
},
|
||||
{
|
||||
value: "AZURE_OPENAI",
|
||||
label: "Azure OpenAI",
|
||||
example: "azure/gpt-4o, azure/gpt-4o-mini",
|
||||
description: "OpenAI models on Azure",
|
||||
},
|
||||
{
|
||||
value: "BEDROCK",
|
||||
label: "AWS Bedrock",
|
||||
example: "anthropic.claude-3-5-sonnet, meta.llama3-70b",
|
||||
description: "Foundation models on AWS",
|
||||
},
|
||||
{
|
||||
value: "VERTEX_AI",
|
||||
label: "Google Vertex AI",
|
||||
example: "vertex_ai/claude-3-5-sonnet, vertex_ai/gemini-2.5-pro",
|
||||
description: "Models on Google Cloud Vertex AI",
|
||||
},
|
||||
{
|
||||
value: "GROQ",
|
||||
label: "Groq",
|
||||
example: "groq/llama-3.3-70b-versatile, groq/mixtral-8x7b",
|
||||
description: "Ultra-fast inference",
|
||||
},
|
||||
{
|
||||
value: "COHERE",
|
||||
label: "Cohere",
|
||||
example: "command-a-03-2025, command-r-plus",
|
||||
description: "Enterprise NLP models",
|
||||
},
|
||||
{
|
||||
value: "MISTRAL",
|
||||
label: "Mistral AI",
|
||||
example: "mistral-large-latest, mistral-medium-latest",
|
||||
description: "European open-source models",
|
||||
},
|
||||
{
|
||||
value: "DEEPSEEK",
|
||||
label: "DeepSeek",
|
||||
example: "deepseek-chat, deepseek-reasoner",
|
||||
description: "High-performance reasoning models",
|
||||
apiBase: "https://api.deepseek.com",
|
||||
},
|
||||
{
|
||||
value: "XAI",
|
||||
label: "xAI (Grok)",
|
||||
example: "grok-4, grok-3, grok-3-mini",
|
||||
description: "Grok models from xAI",
|
||||
},
|
||||
{
|
||||
value: "OPENROUTER",
|
||||
label: "OpenRouter",
|
||||
example: "openrouter/anthropic/claude-4-opus",
|
||||
description: "Unified API for multiple providers",
|
||||
},
|
||||
{
|
||||
value: "TOGETHER_AI",
|
||||
label: "Together AI",
|
||||
example: "together_ai/meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
||||
description: "Fast open-source models",
|
||||
},
|
||||
{
|
||||
value: "FIREWORKS_AI",
|
||||
label: "Fireworks AI",
|
||||
example: "fireworks_ai/accounts/fireworks/models/llama-v3p3-70b-instruct",
|
||||
description: "Scalable inference platform",
|
||||
},
|
||||
{
|
||||
value: "REPLICATE",
|
||||
label: "Replicate",
|
||||
example: "replicate/meta/llama-3-70b-instruct",
|
||||
description: "ML model hosting platform",
|
||||
},
|
||||
{
|
||||
value: "PERPLEXITY",
|
||||
label: "Perplexity",
|
||||
example: "perplexity/sonar-pro, perplexity/sonar-reasoning",
|
||||
description: "Search-augmented models",
|
||||
},
|
||||
{
|
||||
value: "OLLAMA",
|
||||
label: "Ollama",
|
||||
example: "ollama/llama3.1, ollama/mistral",
|
||||
description: "Run models locally",
|
||||
apiBase: "http://localhost:11434",
|
||||
},
|
||||
{
|
||||
value: "ALIBABA_QWEN",
|
||||
label: "Alibaba Qwen",
|
||||
example: "dashscope/qwen-plus, dashscope/qwen-turbo",
|
||||
description: "Qwen series models",
|
||||
apiBase: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||
},
|
||||
{
|
||||
value: "MOONSHOT",
|
||||
label: "Moonshot (Kimi)",
|
||||
example: "moonshot/kimi-latest, moonshot/kimi-k2-thinking",
|
||||
description: "Kimi AI models",
|
||||
apiBase: "https://api.moonshot.cn/v1",
|
||||
},
|
||||
{
|
||||
value: "ZHIPU",
|
||||
label: "Zhipu (GLM)",
|
||||
example: "glm-4.6, glm-4.6:exacto",
|
||||
description: "GLM series models",
|
||||
apiBase: "https://open.bigmodel.cn/api/paas/v4",
|
||||
},
|
||||
{
|
||||
value: "ANYSCALE",
|
||||
label: "Anyscale",
|
||||
example: "anyscale/meta-llama/Meta-Llama-3-70B-Instruct",
|
||||
description: "Ray-based inference platform",
|
||||
},
|
||||
{
|
||||
value: "DEEPINFRA",
|
||||
label: "DeepInfra",
|
||||
example: "deepinfra/meta-llama/Meta-Llama-3.3-70B-Instruct",
|
||||
description: "Serverless GPU inference",
|
||||
},
|
||||
{
|
||||
value: "CEREBRAS",
|
||||
label: "Cerebras",
|
||||
example: "cerebras/llama-3.3-70b, cerebras/qwen-3-32b",
|
||||
description: "Fastest inference with Wafer-Scale Engine",
|
||||
},
|
||||
{
|
||||
value: "SAMBANOVA",
|
||||
label: "SambaNova",
|
||||
example: "sambanova/Meta-Llama-3.3-70B-Instruct",
|
||||
description: "AI inference platform",
|
||||
},
|
||||
{
|
||||
value: "AI21",
|
||||
label: "AI21 Labs",
|
||||
example: "jamba-1.5-large, jamba-1.5-mini",
|
||||
description: "Jamba series models",
|
||||
},
|
||||
{
|
||||
value: "CLOUDFLARE",
|
||||
label: "Cloudflare Workers AI",
|
||||
example: "cloudflare/@cf/meta/llama-2-7b-chat",
|
||||
description: "AI on Cloudflare edge network",
|
||||
},
|
||||
{
|
||||
value: "DATABRICKS",
|
||||
label: "Databricks",
|
||||
example: "databricks/databricks-meta-llama-3-3-70b-instruct",
|
||||
description: "Databricks Model Serving",
|
||||
},
|
||||
{
|
||||
value: "GITHUB_MODELS",
|
||||
label: "GitHub Models",
|
||||
example: "openai/gpt-5, meta/llama-3.1-405b-instruct",
|
||||
description: "AI models from GitHub Marketplace",
|
||||
apiBase: "https://models.github.ai/inference",
|
||||
},
|
||||
{
|
||||
value: "MINIMAX",
|
||||
label: "MiniMax",
|
||||
example: "MiniMax-M3, MiniMax-M2.7",
|
||||
description: "High-performance models with up to 512K context",
|
||||
apiBase: "https://api.minimax.io/v1",
|
||||
},
|
||||
{
|
||||
value: "CUSTOM",
|
||||
label: "Custom Provider",
|
||||
example: "your-custom-model",
|
||||
description: "Custom OpenAI-compatible endpoint",
|
||||
},
|
||||
];
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
import type { LLMModel } from "./llm-models";
|
||||
|
||||
export interface VisionProviderInfo {
|
||||
value: string;
|
||||
label: string;
|
||||
example: string;
|
||||
description: string;
|
||||
apiBase?: string;
|
||||
}
|
||||
|
||||
export const VISION_PROVIDERS: VisionProviderInfo[] = [
|
||||
{
|
||||
value: "OPENAI",
|
||||
label: "OpenAI",
|
||||
example: "gpt-4o, gpt-4o-mini",
|
||||
description: "GPT-4o vision models",
|
||||
},
|
||||
{
|
||||
value: "ANTHROPIC",
|
||||
label: "Anthropic",
|
||||
example: "claude-sonnet-4-20250514",
|
||||
description: "Claude vision models",
|
||||
},
|
||||
{
|
||||
value: "GOOGLE",
|
||||
label: "Google AI Studio",
|
||||
example: "gemini-2.5-flash, gemini-2.0-flash",
|
||||
description: "Gemini vision models",
|
||||
},
|
||||
{
|
||||
value: "AZURE_OPENAI",
|
||||
label: "Azure OpenAI",
|
||||
example: "azure/gpt-4o",
|
||||
description: "OpenAI vision models on Azure",
|
||||
},
|
||||
{
|
||||
value: "VERTEX_AI",
|
||||
label: "Google Vertex AI",
|
||||
example: "vertex_ai/gemini-2.5-flash",
|
||||
description: "Gemini vision models on Vertex AI",
|
||||
},
|
||||
{
|
||||
value: "BEDROCK",
|
||||
label: "AWS Bedrock",
|
||||
example: "bedrock/anthropic.claude-sonnet-4-20250514-v1:0",
|
||||
description: "Vision models on AWS Bedrock",
|
||||
},
|
||||
{
|
||||
value: "XAI",
|
||||
label: "xAI",
|
||||
example: "grok-2-vision",
|
||||
description: "Grok vision models",
|
||||
},
|
||||
{
|
||||
value: "OPENROUTER",
|
||||
label: "OpenRouter",
|
||||
example: "openrouter/openai/gpt-4o",
|
||||
description: "Vision models via OpenRouter",
|
||||
},
|
||||
{
|
||||
value: "OLLAMA",
|
||||
label: "Ollama",
|
||||
example: "llava, bakllava",
|
||||
description: "Local vision models via Ollama",
|
||||
apiBase: "http://localhost:11434",
|
||||
},
|
||||
{
|
||||
value: "GROQ",
|
||||
label: "Groq",
|
||||
example: "llama-4-scout-17b-16e-instruct",
|
||||
description: "Vision models on Groq",
|
||||
},
|
||||
{
|
||||
value: "TOGETHER_AI",
|
||||
label: "Together AI",
|
||||
example: "meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
||||
description: "Vision models on Together AI",
|
||||
},
|
||||
{
|
||||
value: "FIREWORKS_AI",
|
||||
label: "Fireworks AI",
|
||||
example: "fireworks_ai/phi-3-vision-128k-instruct",
|
||||
description: "Vision models on Fireworks AI",
|
||||
},
|
||||
{
|
||||
value: "DEEPSEEK",
|
||||
label: "DeepSeek",
|
||||
example: "deepseek-chat",
|
||||
description: "DeepSeek vision models",
|
||||
apiBase: "https://api.deepseek.com",
|
||||
},
|
||||
{
|
||||
value: "MISTRAL",
|
||||
label: "Mistral",
|
||||
example: "pixtral-large-latest",
|
||||
description: "Pixtral vision models",
|
||||
},
|
||||
{
|
||||
value: "CUSTOM",
|
||||
label: "Custom Provider",
|
||||
example: "custom/my-vision-model",
|
||||
description: "Custom OpenAI-compatible vision endpoint",
|
||||
},
|
||||
];
|
||||
|
||||
export const VISION_MODELS: LLMModel[] = [
|
||||
{ value: "gpt-4o", label: "GPT-4o", provider: "OPENAI", contextWindow: "128K" },
|
||||
{ value: "gpt-4o-mini", label: "GPT-4o Mini", provider: "OPENAI", contextWindow: "128K" },
|
||||
{ value: "gpt-4-turbo", label: "GPT-4 Turbo", provider: "OPENAI", contextWindow: "128K" },
|
||||
{
|
||||
value: "claude-sonnet-4-20250514",
|
||||
label: "Claude Sonnet 4",
|
||||
provider: "ANTHROPIC",
|
||||
contextWindow: "200K",
|
||||
},
|
||||
{
|
||||
value: "claude-3-7-sonnet-20250219",
|
||||
label: "Claude 3.7 Sonnet",
|
||||
provider: "ANTHROPIC",
|
||||
contextWindow: "200K",
|
||||
},
|
||||
{
|
||||
value: "claude-3-5-sonnet-20241022",
|
||||
label: "Claude 3.5 Sonnet",
|
||||
provider: "ANTHROPIC",
|
||||
contextWindow: "200K",
|
||||
},
|
||||
{
|
||||
value: "claude-3-opus-20240229",
|
||||
label: "Claude 3 Opus",
|
||||
provider: "ANTHROPIC",
|
||||
contextWindow: "200K",
|
||||
},
|
||||
{
|
||||
value: "claude-3-haiku-20240307",
|
||||
label: "Claude 3 Haiku",
|
||||
provider: "ANTHROPIC",
|
||||
contextWindow: "200K",
|
||||
},
|
||||
{ value: "gemini-2.5-flash", label: "Gemini 2.5 Flash", provider: "GOOGLE", contextWindow: "1M" },
|
||||
{ value: "gemini-2.5-pro", label: "Gemini 2.5 Pro", provider: "GOOGLE", contextWindow: "1M" },
|
||||
{ value: "gemini-2.0-flash", label: "Gemini 2.0 Flash", provider: "GOOGLE", contextWindow: "1M" },
|
||||
{ value: "gemini-1.5-pro", label: "Gemini 1.5 Pro", provider: "GOOGLE", contextWindow: "1M" },
|
||||
{ value: "gemini-1.5-flash", label: "Gemini 1.5 Flash", provider: "GOOGLE", contextWindow: "1M" },
|
||||
{
|
||||
value: "pixtral-large-latest",
|
||||
label: "Pixtral Large",
|
||||
provider: "MISTRAL",
|
||||
contextWindow: "128K",
|
||||
},
|
||||
{ value: "pixtral-12b-2409", label: "Pixtral 12B", provider: "MISTRAL", contextWindow: "128K" },
|
||||
{ value: "grok-2-vision-1212", label: "Grok 2 Vision", provider: "XAI", contextWindow: "32K" },
|
||||
{ value: "llava", label: "LLaVA", provider: "OLLAMA" },
|
||||
{ value: "bakllava", label: "BakLLaVA", provider: "OLLAMA" },
|
||||
{ value: "llava-llama3", label: "LLaVA Llama 3", provider: "OLLAMA" },
|
||||
{
|
||||
value: "llama-4-scout-17b-16e-instruct",
|
||||
label: "Llama 4 Scout 17B",
|
||||
provider: "GROQ",
|
||||
contextWindow: "128K",
|
||||
},
|
||||
{
|
||||
value: "meta-llama/Llama-4-Scout-17B-16E-Instruct",
|
||||
label: "Llama 4 Scout 17B",
|
||||
provider: "TOGETHER_AI",
|
||||
contextWindow: "128K",
|
||||
},
|
||||
];
|
||||
|
|
@ -1,476 +0,0 @@
|
|||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* LiteLLM Provider enum - all supported LLM providers
|
||||
*/
|
||||
export const liteLLMProviderEnum = z.enum([
|
||||
"OPENAI",
|
||||
"ANTHROPIC",
|
||||
"GOOGLE",
|
||||
"AZURE_OPENAI",
|
||||
"BEDROCK",
|
||||
"VERTEX_AI",
|
||||
"GROQ",
|
||||
"COHERE",
|
||||
"MISTRAL",
|
||||
"DEEPSEEK",
|
||||
"XAI",
|
||||
"OPENROUTER",
|
||||
"TOGETHER_AI",
|
||||
"FIREWORKS_AI",
|
||||
"REPLICATE",
|
||||
"PERPLEXITY",
|
||||
"OLLAMA",
|
||||
"ALIBABA_QWEN",
|
||||
"MOONSHOT",
|
||||
"ZHIPU",
|
||||
"ANYSCALE",
|
||||
"DEEPINFRA",
|
||||
"CEREBRAS",
|
||||
"SAMBANOVA",
|
||||
"AI21",
|
||||
"CLOUDFLARE",
|
||||
"DATABRICKS",
|
||||
"COMETAPI",
|
||||
"HUGGINGFACE",
|
||||
"GITHUB_MODELS",
|
||||
"MINIMAX",
|
||||
"CUSTOM",
|
||||
]);
|
||||
|
||||
export type LiteLLMProvider = z.infer<typeof liteLLMProviderEnum>;
|
||||
|
||||
/**
|
||||
* NewLLMConfig - combines model settings with prompt configuration
|
||||
*/
|
||||
export const newLLMConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string().max(100),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
|
||||
// Model Configuration
|
||||
provider: liteLLMProviderEnum,
|
||||
custom_provider: z.string().max(100).nullable().optional(),
|
||||
model_name: z.string().max(100),
|
||||
api_key: z.string(),
|
||||
api_base: z.string().max(500).nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
|
||||
// Prompt Configuration
|
||||
system_instructions: z.string().default(""),
|
||||
use_default_system_instructions: z.boolean().default(true),
|
||||
citations_enabled: z.boolean().default(true),
|
||||
|
||||
// Metadata
|
||||
created_at: z.string(),
|
||||
search_space_id: z.number(),
|
||||
user_id: z.string(),
|
||||
|
||||
// Capability flag — derived server-side at the route boundary from
|
||||
// LiteLLM's authoritative model map. There is no DB column. Default
|
||||
// `true` is the conservative-allow stance for unknown / unmapped
|
||||
// BYOK rows; the streaming-task safety net is the only place a
|
||||
// `false` actually blocks a request.
|
||||
supports_image_input: z.boolean().default(true),
|
||||
});
|
||||
|
||||
/**
|
||||
* Public version without api_key (for list views)
|
||||
*/
|
||||
export const newLLMConfigPublic = newLLMConfig.omit({ api_key: true });
|
||||
|
||||
/**
|
||||
* Create NewLLMConfig
|
||||
*
|
||||
* `supports_image_input` is omitted because it is derived server-side
|
||||
* from LiteLLM's model map at read time — there is no DB column to
|
||||
* persist a client-supplied value into.
|
||||
*/
|
||||
export const createNewLLMConfigRequest = newLLMConfig.omit({
|
||||
id: true,
|
||||
created_at: true,
|
||||
user_id: true,
|
||||
supports_image_input: true,
|
||||
});
|
||||
|
||||
export const createNewLLMConfigResponse = newLLMConfig;
|
||||
|
||||
/**
|
||||
* Get NewLLMConfigs list
|
||||
*/
|
||||
export const getNewLLMConfigsRequest = z.object({
|
||||
search_space_id: z.number(),
|
||||
skip: z.number().optional(),
|
||||
limit: z.number().optional(),
|
||||
});
|
||||
|
||||
export const getNewLLMConfigsResponse = z.array(newLLMConfig);
|
||||
|
||||
/**
|
||||
* Get single NewLLMConfig
|
||||
*/
|
||||
export const getNewLLMConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
export const getNewLLMConfigResponse = newLLMConfig;
|
||||
|
||||
/**
|
||||
* Update NewLLMConfig
|
||||
*/
|
||||
export const updateNewLLMConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
data: newLLMConfig
|
||||
.omit({
|
||||
id: true,
|
||||
created_at: true,
|
||||
search_space_id: true,
|
||||
user_id: true,
|
||||
// Derived server-side; not part of the writable surface.
|
||||
supports_image_input: true,
|
||||
})
|
||||
.partial(),
|
||||
});
|
||||
|
||||
export const updateNewLLMConfigResponse = newLLMConfig;
|
||||
|
||||
/**
|
||||
* Delete NewLLMConfig
|
||||
*/
|
||||
export const deleteNewLLMConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
export const deleteNewLLMConfigResponse = z.object({
|
||||
message: z.string(),
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Get default system instructions
|
||||
*/
|
||||
export const getDefaultSystemInstructionsResponse = z.object({
|
||||
default_system_instructions: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Global NewLLMConfig - from YAML, has negative IDs
|
||||
* ID 0 is reserved for "Auto" mode which uses LiteLLM Router for load balancing
|
||||
*/
|
||||
export const globalNewLLMConfig = z.object({
|
||||
id: z.number(), // 0 for Auto mode, negative IDs for global configs
|
||||
name: z.string(),
|
||||
description: z.string().nullable().optional(),
|
||||
|
||||
// Model Configuration (no api_key)
|
||||
provider: z.string(), // String because YAML doesn't enforce enum, "AUTO" for Auto mode
|
||||
custom_provider: z.string().nullable().optional(),
|
||||
model_name: z.string(),
|
||||
api_base: z.string().nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
|
||||
// Prompt Configuration
|
||||
system_instructions: z.string().default(""),
|
||||
use_default_system_instructions: z.boolean().default(true),
|
||||
citations_enabled: z.boolean().default(true),
|
||||
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false), // True only for Auto mode (ID 0)
|
||||
|
||||
// Token quota and billing policy
|
||||
billing_tier: z.string().default("free"),
|
||||
is_premium: z.boolean().default(false),
|
||||
anonymous_enabled: z.boolean().default(false),
|
||||
seo_enabled: z.boolean().default(false),
|
||||
seo_slug: z.string().nullable().optional(),
|
||||
seo_title: z.string().nullable().optional(),
|
||||
seo_description: z.string().nullable().optional(),
|
||||
quota_reserve_tokens: z.number().nullable().optional(),
|
||||
// Capability flag — true when the model can accept image inputs.
|
||||
// Resolved server-side (OpenRouter dynamic configs use the OR
|
||||
// `architecture.input_modalities` field; YAML / BYOK use LiteLLM's
|
||||
// authoritative `supports_vision` map). The chat selector renders
|
||||
// an amber "No image" hint when this is false and there are
|
||||
// pending image attachments, but does not block selection — the
|
||||
// backend safety net only rejects when LiteLLM *explicitly* marks
|
||||
// the model as text-only, so unknown / new models still flow
|
||||
// through. Default `true` matches that conservative-allow stance.
|
||||
supports_image_input: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const getGlobalNewLLMConfigsResponse = z.array(globalNewLLMConfig);
|
||||
|
||||
// =============================================================================
|
||||
// Image Generation Config (separate table from NewLLMConfig)
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* ImageGenProvider enum - only providers that support image generation
|
||||
* See: https://docs.litellm.ai/docs/image_generation#supported-providers
|
||||
*/
|
||||
export const imageGenProviderEnum = z.enum([
|
||||
"OPENAI",
|
||||
"AZURE_OPENAI",
|
||||
"GOOGLE",
|
||||
"VERTEX_AI",
|
||||
"BEDROCK",
|
||||
"RECRAFT",
|
||||
"OPENROUTER",
|
||||
"XINFERENCE",
|
||||
"NSCALE",
|
||||
]);
|
||||
|
||||
export type ImageGenProvider = z.infer<typeof imageGenProviderEnum>;
|
||||
|
||||
/**
|
||||
* ImageGenerationConfig - user-created image gen model configs
|
||||
* Separate from NewLLMConfig: no system_instructions, no citations_enabled.
|
||||
*/
|
||||
export const imageGenerationConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string().max(100),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
provider: imageGenProviderEnum,
|
||||
custom_provider: z.string().max(100).nullable().optional(),
|
||||
model_name: z.string().max(100),
|
||||
api_key: z.string(),
|
||||
api_base: z.string().max(500).nullable().optional(),
|
||||
api_version: z.string().max(50).nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
created_at: z.string(),
|
||||
search_space_id: z.number(),
|
||||
user_id: z.string(),
|
||||
});
|
||||
|
||||
export const createImageGenConfigRequest = imageGenerationConfig.omit({
|
||||
id: true,
|
||||
created_at: true,
|
||||
user_id: true,
|
||||
});
|
||||
|
||||
export const createImageGenConfigResponse = imageGenerationConfig;
|
||||
|
||||
export const getImageGenConfigsResponse = z.array(imageGenerationConfig);
|
||||
|
||||
export const updateImageGenConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
data: imageGenerationConfig
|
||||
.omit({ id: true, created_at: true, search_space_id: true, user_id: true })
|
||||
.partial(),
|
||||
});
|
||||
|
||||
export const updateImageGenConfigResponse = imageGenerationConfig;
|
||||
|
||||
export const deleteImageGenConfigResponse = z.object({
|
||||
message: z.string(),
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Global Image Generation Config - from YAML, has negative IDs
|
||||
* ID 0 is reserved for "Auto" mode (LiteLLM Router load balancing)
|
||||
*/
|
||||
export const globalImageGenConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable().optional(),
|
||||
provider: z.string(),
|
||||
custom_provider: z.string().nullable().optional(),
|
||||
model_name: z.string(),
|
||||
api_base: z.string().nullable().optional(),
|
||||
api_version: z.string().nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false),
|
||||
billing_tier: z.string().default("free"),
|
||||
// Mirrors `globalNewLLMConfig.is_premium` so the new-chat selector's
|
||||
// Free/Premium badge logic lights up automatically for image-gen too.
|
||||
is_premium: z.boolean().default(false),
|
||||
quota_reserve_micros: z.number().nullable().optional(),
|
||||
});
|
||||
|
||||
export const getGlobalImageGenConfigsResponse = z.array(globalImageGenConfig);
|
||||
|
||||
// =============================================================================
|
||||
// Vision LLM Config (separate table for vision-capable models)
|
||||
// =============================================================================
|
||||
|
||||
export const visionProviderEnum = z.enum([
|
||||
"OPENAI",
|
||||
"ANTHROPIC",
|
||||
"GOOGLE",
|
||||
"AZURE_OPENAI",
|
||||
"VERTEX_AI",
|
||||
"BEDROCK",
|
||||
"XAI",
|
||||
"OPENROUTER",
|
||||
"OLLAMA",
|
||||
"GROQ",
|
||||
"TOGETHER_AI",
|
||||
"FIREWORKS_AI",
|
||||
"DEEPSEEK",
|
||||
"MISTRAL",
|
||||
"CUSTOM",
|
||||
]);
|
||||
|
||||
export type VisionProvider = z.infer<typeof visionProviderEnum>;
|
||||
|
||||
export const visionLLMConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string().max(100),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
provider: visionProviderEnum,
|
||||
custom_provider: z.string().max(100).nullable().optional(),
|
||||
model_name: z.string().max(100),
|
||||
api_key: z.string(),
|
||||
api_base: z.string().max(500).nullable().optional(),
|
||||
api_version: z.string().max(50).nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
created_at: z.string(),
|
||||
search_space_id: z.number(),
|
||||
user_id: z.string(),
|
||||
});
|
||||
|
||||
export const createVisionLLMConfigRequest = visionLLMConfig.omit({
|
||||
id: true,
|
||||
created_at: true,
|
||||
user_id: true,
|
||||
});
|
||||
|
||||
export const createVisionLLMConfigResponse = visionLLMConfig;
|
||||
|
||||
export const getVisionLLMConfigsResponse = z.array(visionLLMConfig);
|
||||
|
||||
export const updateVisionLLMConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
data: visionLLMConfig
|
||||
.omit({ id: true, created_at: true, search_space_id: true, user_id: true })
|
||||
.partial(),
|
||||
});
|
||||
|
||||
export const updateVisionLLMConfigResponse = visionLLMConfig;
|
||||
|
||||
export const deleteVisionLLMConfigResponse = z.object({
|
||||
message: z.string(),
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
export const globalVisionLLMConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable().optional(),
|
||||
provider: z.string(),
|
||||
custom_provider: z.string().nullable().optional(),
|
||||
model_name: z.string(),
|
||||
api_base: z.string().nullable().optional(),
|
||||
api_version: z.string().nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false),
|
||||
billing_tier: z.string().default("free"),
|
||||
// Mirrors `globalNewLLMConfig.is_premium` so the new-chat selector's
|
||||
// Free/Premium badge logic lights up automatically for vision too.
|
||||
is_premium: z.boolean().default(false),
|
||||
quota_reserve_tokens: z.number().nullable().optional(),
|
||||
input_cost_per_token: z.number().nullable().optional(),
|
||||
output_cost_per_token: z.number().nullable().optional(),
|
||||
});
|
||||
|
||||
export const getGlobalVisionLLMConfigsResponse = z.array(globalVisionLLMConfig);
|
||||
|
||||
// =============================================================================
|
||||
// LLM Preferences (Role Assignments)
|
||||
// =============================================================================
|
||||
|
||||
export const llmPreferences = z.object({
|
||||
agent_llm_id: z.union([z.number(), z.null()]).optional(),
|
||||
image_generation_config_id: z.union([z.number(), z.null()]).optional(),
|
||||
vision_llm_config_id: z.union([z.number(), z.null()]).optional(),
|
||||
agent_llm: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
image_generation_config: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
vision_llm_config: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Get LLM preferences
|
||||
*/
|
||||
export const getLLMPreferencesRequest = z.object({
|
||||
search_space_id: z.number(),
|
||||
});
|
||||
|
||||
export const getLLMPreferencesResponse = llmPreferences;
|
||||
|
||||
/**
|
||||
* Update LLM preferences
|
||||
*/
|
||||
export const updateLLMPreferencesRequest = z.object({
|
||||
search_space_id: z.number(),
|
||||
data: llmPreferences.pick({
|
||||
agent_llm_id: true,
|
||||
image_generation_config_id: true,
|
||||
vision_llm_config_id: true,
|
||||
}),
|
||||
});
|
||||
|
||||
export const updateLLMPreferencesResponse = llmPreferences;
|
||||
|
||||
// =============================================================================
|
||||
// Model List (dynamic catalogue from OpenRouter API)
|
||||
// =============================================================================
|
||||
|
||||
export const modelListItem = z.object({
|
||||
value: z.string(),
|
||||
label: z.string(),
|
||||
provider: z.string(),
|
||||
context_window: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const getModelListResponse = z.array(modelListItem);
|
||||
|
||||
export type ModelListItem = z.infer<typeof modelListItem>;
|
||||
export type GetModelListResponse = z.infer<typeof getModelListResponse>;
|
||||
|
||||
// =============================================================================
|
||||
// Type Exports
|
||||
// =============================================================================
|
||||
|
||||
export type NewLLMConfig = z.infer<typeof newLLMConfig>;
|
||||
export type NewLLMConfigPublic = z.infer<typeof newLLMConfigPublic>;
|
||||
export type CreateNewLLMConfigRequest = z.infer<typeof createNewLLMConfigRequest>;
|
||||
export type CreateNewLLMConfigResponse = z.infer<typeof createNewLLMConfigResponse>;
|
||||
export type GetNewLLMConfigsRequest = z.infer<typeof getNewLLMConfigsRequest>;
|
||||
export type GetNewLLMConfigsResponse = z.infer<typeof getNewLLMConfigsResponse>;
|
||||
export type GetNewLLMConfigRequest = z.infer<typeof getNewLLMConfigRequest>;
|
||||
export type GetNewLLMConfigResponse = z.infer<typeof getNewLLMConfigResponse>;
|
||||
export type UpdateNewLLMConfigRequest = z.infer<typeof updateNewLLMConfigRequest>;
|
||||
export type UpdateNewLLMConfigResponse = z.infer<typeof updateNewLLMConfigResponse>;
|
||||
export type DeleteNewLLMConfigRequest = z.infer<typeof deleteNewLLMConfigRequest>;
|
||||
export type DeleteNewLLMConfigResponse = z.infer<typeof deleteNewLLMConfigResponse>;
|
||||
export type GetDefaultSystemInstructionsResponse = z.infer<
|
||||
typeof getDefaultSystemInstructionsResponse
|
||||
>;
|
||||
export type GlobalNewLLMConfig = z.infer<typeof globalNewLLMConfig>;
|
||||
export type GetGlobalNewLLMConfigsResponse = z.infer<typeof getGlobalNewLLMConfigsResponse>;
|
||||
export type ImageGenerationConfig = z.infer<typeof imageGenerationConfig>;
|
||||
export type CreateImageGenConfigRequest = z.infer<typeof createImageGenConfigRequest>;
|
||||
export type CreateImageGenConfigResponse = z.infer<typeof createImageGenConfigResponse>;
|
||||
export type GetImageGenConfigsResponse = z.infer<typeof getImageGenConfigsResponse>;
|
||||
export type UpdateImageGenConfigRequest = z.infer<typeof updateImageGenConfigRequest>;
|
||||
export type UpdateImageGenConfigResponse = z.infer<typeof updateImageGenConfigResponse>;
|
||||
export type DeleteImageGenConfigResponse = z.infer<typeof deleteImageGenConfigResponse>;
|
||||
export type GlobalImageGenConfig = z.infer<typeof globalImageGenConfig>;
|
||||
export type GetGlobalImageGenConfigsResponse = z.infer<typeof getGlobalImageGenConfigsResponse>;
|
||||
export type VisionLLMConfig = z.infer<typeof visionLLMConfig>;
|
||||
export type CreateVisionLLMConfigRequest = z.infer<typeof createVisionLLMConfigRequest>;
|
||||
export type CreateVisionLLMConfigResponse = z.infer<typeof createVisionLLMConfigResponse>;
|
||||
export type GetVisionLLMConfigsResponse = z.infer<typeof getVisionLLMConfigsResponse>;
|
||||
export type UpdateVisionLLMConfigRequest = z.infer<typeof updateVisionLLMConfigRequest>;
|
||||
export type UpdateVisionLLMConfigResponse = z.infer<typeof updateVisionLLMConfigResponse>;
|
||||
export type DeleteVisionLLMConfigResponse = z.infer<typeof deleteVisionLLMConfigResponse>;
|
||||
export type GlobalVisionLLMConfig = z.infer<typeof globalVisionLLMConfig>;
|
||||
export type GetGlobalVisionLLMConfigsResponse = z.infer<typeof getGlobalVisionLLMConfigsResponse>;
|
||||
export type LLMPreferences = z.infer<typeof llmPreferences>;
|
||||
export type GetLLMPreferencesRequest = z.infer<typeof getLLMPreferencesRequest>;
|
||||
export type GetLLMPreferencesResponse = z.infer<typeof getLLMPreferencesResponse>;
|
||||
export type UpdateLLMPreferencesRequest = z.infer<typeof updateLLMPreferencesRequest>;
|
||||
export type UpdateLLMPreferencesResponse = z.infer<typeof updateLLMPreferencesResponse>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue