116 lines
5.2 KiB
SQL
116 lines
5.2 KiB
SQL
-- Insert demo AI process directly
|
|
SET @process_id = '2d883482-4df0-44d7-b6cf-8541b482afe4';
|
|
SET @version_id = '437b1e72-405e-4862-a8bc-f368e554b482';
|
|
SET @user_id = 'system';
|
|
|
|
-- Insert process
|
|
INSERT INTO ai_processes (id, name, created_by)
|
|
VALUES (@process_id, 'Register New Pet', @user_id);
|
|
|
|
-- Insert process version with compiled graph
|
|
INSERT INTO ai_process_versions (id, process_id, version, graph_json, compiled_json, created_by)
|
|
VALUES (
|
|
@version_id,
|
|
@process_id,
|
|
1,
|
|
'{}',
|
|
JSON_OBJECT(
|
|
'id', 'register_new_pet',
|
|
'name', 'Register New Pet',
|
|
'description', 'Complete pet registration workflow',
|
|
'allowCycles', false,
|
|
'startNodeId', 'start',
|
|
'endNodeIds', JSON_ARRAY('end'),
|
|
'maxIterations', 50,
|
|
'nodes', JSON_ARRAY(
|
|
JSON_OBJECT('id', 'start', 'type', 'Start', 'data', JSON_OBJECT('label', 'Start')),
|
|
JSON_OBJECT('id', 'extract_info', 'type', 'LLMDecisionNode', 'data', JSON_OBJECT(
|
|
'label', 'Extract Info',
|
|
'promptTemplate', 'Extract: petName, species, ownerFirstName, ownerLastName, ownerEmail, accountName from: {{state.message}}',
|
|
'inputKeys', JSON_ARRAY('message'),
|
|
'outputSchema', JSON_OBJECT(
|
|
'type', 'object',
|
|
'properties', JSON_OBJECT(
|
|
'petName', JSON_OBJECT('type', 'string'),
|
|
'species', JSON_OBJECT('type', 'string'),
|
|
'ownerFirstName', JSON_OBJECT('type', 'string'),
|
|
'ownerLastName', JSON_OBJECT('type', 'string'),
|
|
'ownerEmail', JSON_OBJECT('type', 'string'),
|
|
'accountName', JSON_OBJECT('type', 'string')
|
|
),
|
|
'required', JSON_ARRAY('petName', 'species', 'ownerFirstName', 'ownerLastName')
|
|
)
|
|
)),
|
|
JSON_OBJECT('id', 'find_account', 'type', 'ToolNode', 'data', JSON_OBJECT(
|
|
'label', 'Find Account',
|
|
'toolName', 'findAccount',
|
|
'argsTemplate', JSON_OBJECT('name', '{{state.accountName}}', 'email', '{{state.ownerEmail}}'),
|
|
'outputMapping', JSON_OBJECT('found', 'accountFound', 'accountId', 'accountId')
|
|
)),
|
|
JSON_OBJECT('id', 'create_account', 'type', 'ToolNode', 'data', JSON_OBJECT(
|
|
'label', 'Create Account',
|
|
'toolName', 'createAccount',
|
|
'argsTemplate', JSON_OBJECT('name', '{{state.accountName}}', 'email', '{{state.ownerEmail}}'),
|
|
'outputMapping', JSON_OBJECT('accountId', 'accountId')
|
|
)),
|
|
JSON_OBJECT('id', 'find_contact', 'type', 'ToolNode', 'data', JSON_OBJECT(
|
|
'label', 'Find Contact',
|
|
'toolName', 'findContact',
|
|
'argsTemplate', JSON_OBJECT(
|
|
'firstName', '{{state.ownerFirstName}}',
|
|
'lastName', '{{state.ownerLastName}}',
|
|
'email', '{{state.ownerEmail}}',
|
|
'accountId', '{{state.accountId}}'
|
|
),
|
|
'outputMapping', JSON_OBJECT('found', 'contactFound', 'contactId', 'contactId')
|
|
)),
|
|
JSON_OBJECT('id', 'create_contact', 'type', 'ToolNode', 'data', JSON_OBJECT(
|
|
'label', 'Create Contact',
|
|
'toolName', 'createContact',
|
|
'argsTemplate', JSON_OBJECT(
|
|
'firstName', '{{state.ownerFirstName}}',
|
|
'lastName', '{{state.ownerLastName}}',
|
|
'email', '{{state.ownerEmail}}',
|
|
'accountId', '{{state.accountId}}'
|
|
),
|
|
'outputMapping', JSON_OBJECT('contactId', 'contactId')
|
|
)),
|
|
JSON_OBJECT('id', 'create_pet', 'type', 'ToolNode', 'data', JSON_OBJECT(
|
|
'label', 'Create Pet',
|
|
'toolName', 'createPet',
|
|
'argsTemplate', JSON_OBJECT(
|
|
'name', '{{state.petName}}',
|
|
'species', '{{state.species}}',
|
|
'ownerId', '{{state.contactId}}'
|
|
),
|
|
'outputMapping', JSON_OBJECT('petId', 'petId')
|
|
)),
|
|
JSON_OBJECT('id', 'end', 'type', 'End', 'data', JSON_OBJECT('label', 'End'))
|
|
),
|
|
'edges', JSON_ARRAY(
|
|
JSON_OBJECT('id', 'e1', 'source', 'start', 'target', 'extract_info'),
|
|
JSON_OBJECT('id', 'e2', 'source', 'extract_info', 'target', 'find_account'),
|
|
JSON_OBJECT('id', 'e3', 'source', 'find_account', 'target', 'find_contact', 'condition', JSON_OBJECT('==', JSON_ARRAY(JSON_OBJECT('var', 'accountFound'), true))),
|
|
JSON_OBJECT('id', 'e4', 'source', 'find_account', 'target', 'create_account', 'condition', JSON_OBJECT('==', JSON_ARRAY(JSON_OBJECT('var', 'accountFound'), false))),
|
|
JSON_OBJECT('id', 'e5', 'source', 'create_account', 'target', 'find_contact'),
|
|
JSON_OBJECT('id', 'e6', 'source', 'find_contact', 'target', 'create_pet', 'condition', JSON_OBJECT('==', JSON_ARRAY(JSON_OBJECT('var', 'contactFound'), true))),
|
|
JSON_OBJECT('id', 'e7', 'source', 'find_contact', 'target', 'create_contact', 'condition', JSON_OBJECT('==', JSON_ARRAY(JSON_OBJECT('var', 'contactFound'), false))),
|
|
JSON_OBJECT('id', 'e8', 'source', 'create_contact', 'target', 'create_pet'),
|
|
JSON_OBJECT('id', 'e9', 'source', 'create_pet', 'target', 'end')
|
|
)
|
|
),
|
|
@user_id
|
|
);
|
|
|
|
-- Insert tool allowlist
|
|
INSERT INTO ai_tool_configs (id, tool_name, enabled)
|
|
VALUES
|
|
(UUID(), 'findAccount', true),
|
|
(UUID(), 'createAccount', true),
|
|
(UUID(), 'findContact', true),
|
|
(UUID(), 'createContact', true),
|
|
(UUID(), 'createPet', true)
|
|
ON DUPLICATE KEY UPDATE enabled = true;
|
|
|
|
SELECT 'Demo process inserted successfully!' as result;
|