add graph_id

This commit is contained in:
2026-02-11 17:17:03 +08:00
parent 6db1353e79
commit 421158060c

View File

@@ -4,6 +4,7 @@
CREATE TABLE IF NOT EXISTS prompt_sets ( CREATE TABLE IF NOT EXISTS prompt_sets (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
pipeline_id VARCHAR(64) NOT NULL, pipeline_id VARCHAR(64) NOT NULL,
graph_id VARCHAR(64),
name VARCHAR(128) NOT NULL, name VARCHAR(128) NOT NULL,
description TEXT DEFAULT '', description TEXT DEFAULT '',
is_active BOOLEAN DEFAULT false, is_active BOOLEAN DEFAULT false,
@@ -12,6 +13,13 @@ CREATE TABLE IF NOT EXISTS prompt_sets (
list Varchar(255) DEFAULT '' -- tool_set list for client_tool_manager list Varchar(255) DEFAULT '' -- tool_set list for client_tool_manager
); );
-- Backward-compatible migration for existing deployments.
ALTER TABLE prompt_sets
ADD COLUMN IF NOT EXISTS graph_id VARCHAR(64);
UPDATE prompt_sets
SET graph_id = pipeline_id
WHERE graph_id IS NULL;
-- Fast lookup of the active set for a pipeline -- Fast lookup of the active set for a pipeline
CREATE INDEX IF NOT EXISTS idx_prompt_sets_pipeline_active CREATE INDEX IF NOT EXISTS idx_prompt_sets_pipeline_active
ON prompt_sets(pipeline_id, is_active); ON prompt_sets(pipeline_id, is_active);
@@ -32,8 +40,9 @@ CREATE INDEX IF NOT EXISTS idx_prompt_templates_set_id
-- Seed: initial prompt set for lang_agent/graphs/routing.py -- Seed: initial prompt set for lang_agent/graphs/routing.py
-- The pipeline_id can be used by RoutingConfig.pipeline_id to load these prompts. -- The pipeline_id can be used by RoutingConfig.pipeline_id to load these prompts.
INSERT INTO prompt_sets (pipeline_id, name, description, is_active, list) INSERT INTO prompt_sets (pipeline_id, graph_id, name, description, is_active, list)
SELECT SELECT
'routing',
'routing', 'routing',
'default', 'default',
'Initial prompt set for RoutingGraph nodes', 'Initial prompt set for RoutingGraph nodes',
@@ -65,8 +74,9 @@ DO UPDATE SET
-- Seed: initial prompt set for lang_agent/graphs/react.py -- Seed: initial prompt set for lang_agent/graphs/react.py
-- ReactGraph uses prompt key "sys_prompt" (see default_key in build_prompt_store). -- ReactGraph uses prompt key "sys_prompt" (see default_key in build_prompt_store).
INSERT INTO prompt_sets (pipeline_id, name, description, is_active, list) INSERT INTO prompt_sets (pipeline_id, graph_id, name, description, is_active, list)
SELECT SELECT
'react',
'react', 'react',
'default', 'default',
'Initial prompt set for ReactGraph', 'Initial prompt set for ReactGraph',