You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
1.2 KiB

-- 04-model-provider.sql
-- OpenAI-API-Compatible 模型供应商管理
-- 支持 LLM / Embedding / Rerank 三种模型类型,每种独立配置
CREATE TABLE IF NOT EXISTS model_providers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100) NOT NULL,
provider_type VARCHAR(50) NOT NULL,
base_url VARCHAR(500),
api_key TEXT,
extra_config JSONB DEFAULT '{}',
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS model_instances (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
provider_id UUID NOT NULL REFERENCES model_providers(id) ON DELETE CASCADE,
model_name VARCHAR(100) NOT NULL,
model_type VARCHAR(30) NOT NULL,
display_name VARCHAR(200),
capabilities JSONB DEFAULT '{}',
default_params JSONB DEFAULT '{}',
is_default BOOLEAN DEFAULT FALSE,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_model_instances_type ON model_instances(model_type, is_active);
CREATE INDEX IF NOT EXISTS idx_model_instances_provider ON model_instances(provider_id);