Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DSL/CronManager/DSL/store_in_vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ store_secrets:
trigger: off
type: exec
command: "/app/scripts/store_secrets_in_vault.sh"
allowedEnvs: ['cookie', 'connectionId','llmPlatform', 'llmModel','secretKey','accessKey','deploymentName','targetUrl','apiKey','embeddingModel','embeddingPlatform','embeddingModelApiKey','deploymentEnvironment']
allowedEnvs: ['cookie', 'connectionId','llmPlatform', 'llmModel','secretKey','accessKey','deploymentName','targetUrl','apiKey','embeddingModel','embeddingPlatform','embeddingAccessKey','embeddingSecretKey','embeddingDeploymentName','embeddingTargetUri','embeddingAzureApiKey','deploymentEnvironment']
41 changes: 21 additions & 20 deletions DSL/Liquibase/changelog/rag-search-script-v1-llm-connections.sql
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
-- Schema for LLM Connections
CREATE TABLE llm_connections (
-- Metadata
id SERIAL PRIMARY KEY,
connection_name VARCHAR(255) NOT NULL DEFAULT '',
-- LLM Model Configuration
llm_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
llm_model VARCHAR(100) NOT NULL, -- e.g. GPT-4o

-- Embedding Model Configuration
embedding_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
embedding_model VARCHAR(100) NOT NULL, -- e.g. Ada-200-1

-- Budget and Usage Tracking
monthly_budget NUMERIC(12,2) NOT NULL, -- e.g. 1000.00
used_budget NUMERIC(12,2) DEFAULT 0.00, -- e.g. 250.00
warn_budget_threshold NUMERIC(5) DEFAULT 80, -- percentage to warn at
stop_budget_threshold NUMERIC(5) DEFAULT 100, -- percentage to stop at
disconnect_on_budget_exceed BOOLEAN DEFAULT TRUE,

-- Metadata
connection_status VARCHAR(50) DEFAULT 'active', -- active / inactive
created_at TIMESTAMP DEFAULT NOW(),
environment VARCHAR(50) NOT NULL,

-- Mocked Credentials and Access Info
-- LLM Model Configuration
llm_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
llm_model VARCHAR(100) NOT NULL, -- e.g. GPT-4o
-- Azure
deployment_name VARCHAR(150), -- for Azure deployments
target_uri TEXT, -- for custom endpoints
api_key TEXT, -- secured api key mocked here

-- AWS Bedrock
secret_key TEXT,
access_key TEXT,

-- Embedding Model
embedding_model_api_key TEXT
-- Embedding Model Configuration
embedding_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
embedding_model VARCHAR(100) NOT NULL, -- e.g. Ada-200-1
-- Azure
embedding_deployment_name VARCHAR(150), -- for Azure deployments
embedding_target_uri TEXT, -- for custom endpoints
embedding_azure_api_key TEXT, -- secured api key mocked here
-- AWS Bedrock
embedding_secret_key TEXT,
embedding_access_key TEXT,

-- Budget and Usage Tracking
monthly_budget NUMERIC(12,2) NOT NULL, -- e.g. 1000.00
used_budget NUMERIC(12,2) DEFAULT 0.00, -- e.g. 250.00
warn_budget_threshold NUMERIC(5) DEFAULT 80, -- percentage to warn at
stop_budget_threshold NUMERIC(5) DEFAULT 100, -- percentage to stop at
disconnect_on_budget_exceed BOOLEAN DEFAULT TRUE
);

CREATE TABLE inference_results (
Expand Down
6 changes: 5 additions & 1 deletion DSL/Resql/rag-search/POST/get-llm-connection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ SELECT
secret_key,
access_key,
-- Embedding model credentials
embedding_model_api_key
embedding_access_key,
embedding_secret_key,
embedding_deployment_name,
embedding_target_uri,
embedding_azure_api_key
FROM llm_connections
WHERE id = :connection_id
AND connection_status <> 'deleted';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SELECT
connection_status,
created_at,
CEIL(COUNT(*) OVER() / :page_size::DECIMAL) AS totalPages,
-- Calculate budget status based on usage percentage and configured thresholds
CASE
WHEN used_budget IS NULL OR used_budget = 0 OR (used_budget::DECIMAL / monthly_budget::DECIMAL) < (warn_budget_threshold::DECIMAL / 100.0) THEN 'within_budget'
WHEN stop_budget_threshold != 0 AND (used_budget::DECIMAL / monthly_budget::DECIMAL) >= (stop_budget_threshold::DECIMAL / 100.0) THEN 'over_budget'
Expand Down
54 changes: 54 additions & 0 deletions DSL/Resql/rag-search/POST/get-production-connection-filtered.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
SELECT
id,
connection_name,
llm_platform,
llm_model,
embedding_platform,
embedding_model,
monthly_budget,
warn_budget_threshold,
stop_budget_threshold,
disconnect_on_budget_exceed,
used_budget,
environment,
connection_status,
created_at,
deployment_name,
target_uri,
api_key,
secret_key,
access_key,
embedding_secret_key,
embedding_access_key,
embedding_deployment_name,
embedding_target_uri,
embedding_azure_api_key,
-- Calculate budget status based on usage percentage and configured thresholds
CASE
WHEN used_budget IS NULL OR used_budget = 0 OR (used_budget::DECIMAL / monthly_budget::DECIMAL) < (warn_budget_threshold::DECIMAL / 100.0) THEN 'within_budget'
WHEN stop_budget_threshold != 0 AND (used_budget::DECIMAL / monthly_budget::DECIMAL) >= (stop_budget_threshold::DECIMAL / 100.0) THEN 'over_budget'
WHEN stop_budget_threshold = 0 AND (used_budget::DECIMAL / monthly_budget::DECIMAL) >= 1 THEN 'over_budget'
WHEN (used_budget::DECIMAL / monthly_budget::DECIMAL) >= (warn_budget_threshold::DECIMAL / 100.0) THEN 'close_to_exceed'
ELSE 'within_budget'
END AS budget_status
FROM llm_connections
WHERE environment = 'production'
AND connection_status <> 'deleted'
AND (:llm_platform IS NULL OR :llm_platform = '' OR llm_platform = :llm_platform)
AND (:llm_model IS NULL OR :llm_model = '' OR llm_model = :llm_model)
AND (:embedding_platform IS NULL OR :embedding_platform = '' OR embedding_platform = :embedding_platform)
AND (:embedding_model IS NULL OR :embedding_model = '' OR embedding_model = :embedding_model)
AND (:connection_status IS NULL OR :connection_status = '' OR connection_status = :connection_status)
ORDER BY
CASE WHEN :sorting = 'connection_name asc' THEN connection_name END ASC,
CASE WHEN :sorting = 'connection_name desc' THEN connection_name END DESC,
CASE WHEN :sorting = 'llm_platform asc' THEN llm_platform END ASC,
CASE WHEN :sorting = 'llm_platform desc' THEN llm_platform END DESC,
CASE WHEN :sorting = 'llm_model asc' THEN llm_model END ASC,
CASE WHEN :sorting = 'llm_model desc' THEN llm_model END DESC,
CASE WHEN :sorting = 'monthly_budget asc' THEN monthly_budget END ASC,
CASE WHEN :sorting = 'monthly_budget desc' THEN monthly_budget END DESC,
CASE WHEN :sorting = 'created_at asc' THEN created_at END ASC,
CASE WHEN :sorting = 'created_at desc' THEN created_at END DESC,
created_at DESC -- Default fallback sorting
LIMIT 1;
18 changes: 15 additions & 3 deletions DSL/Resql/rag-search/POST/insert-llm-connection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ INSERT INTO llm_connections (
api_key,
secret_key,
access_key,
embedding_model_api_key
embedding_access_key,
embedding_secret_key,
embedding_deployment_name,
embedding_target_uri,
embedding_azure_api_key
) VALUES (
:connection_name,
:llm_platform,
Expand All @@ -35,7 +39,11 @@ INSERT INTO llm_connections (
:api_key,
:secret_key,
:access_key,
:embedding_model_api_key
:embedding_access_key,
:embedding_secret_key,
:embedding_deployment_name,
:embedding_target_uri,
:embedding_azure_api_key
) RETURNING
id,
connection_name,
Expand All @@ -55,4 +63,8 @@ INSERT INTO llm_connections (
api_key,
secret_key,
access_key,
embedding_model_api_key;
embedding_secret_key,
embedding_access_key,
embedding_deployment_name,
embedding_target_uri,
embedding_azure_api_key
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ RETURNING
target_uri,
api_key,
secret_key,
access_key,
embedding_model_api_key;
access_key;
3 changes: 1 addition & 2 deletions DSL/Resql/rag-search/POST/update-llm-connection-status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ RETURNING
target_uri,
api_key,
secret_key,
access_key,
embedding_model_api_key;
access_key;
13 changes: 11 additions & 2 deletions DSL/Resql/rag-search/POST/update-llm-connection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ SET
secret_key = :secret_key,
access_key = :access_key,
-- Embedding model credentials
embedding_model_api_key = :embedding_model_api_key
-- Embedding platform specific credentials
embedding_access_key = :embedding_access_key,
embedding_secret_key = :embedding_secret_key,
embedding_deployment_name = :embedding_deployment_name,
embedding_target_uri = :embedding_target_uri,
embedding_azure_api_key = :embedding_azure_api_key
WHERE id = :connection_id
RETURNING
id,
Expand All @@ -39,4 +44,8 @@ RETURNING
api_key,
secret_key,
access_key,
embedding_model_api_key;
embedding_secret_key,
embedding_access_key,
embedding_deployment_name,
embedding_target_uri,
embedding_azure_api_key;
46 changes: 44 additions & 2 deletions DSL/Ruuter.private/rag-search/GET/llm-connections/production.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
declaration:
call: declare
version: 0.1
description: "Get production LLM connection"
description: "Get production LLM connection with optional filters"
method: get
returns: json
namespace: rag-search
allowlist:
params:
- field: llmPlatform
type: string
description: "Filter by LLM platform"
- field: llmModel
type: string
description: "Filter by LLM model"
- field: embeddingPlatform
type: string
description: "Filter by embedding platform"
- field: embeddingModel
type: string
description: "Filter by embedding model"
- field: connectionStatus
type: string
description: "Filter by connection status"
- field: sortBy
type: string
description: "Field to sort by"
- field: sortOrder
type: string
description: "Sort order: 'asc' or 'desc'"

extract_request_data:
assign:
llmPlatform: ${incoming.params.llmPlatform ?? ""}
llmModel: ${incoming.params.llmModel ?? ""}
embeddingPlatform: ${incoming.params.embeddingPlatform ?? ""}
embeddingModel: ${incoming.params.embeddingModel ?? ""}
connectionStatus: ${incoming.params.connectionStatus ?? ""}
sortBy: ${incoming.params.sortBy ?? "created_at"}
sortOrder: ${incoming.params.sortOrder ?? "desc"}
sorting: ${sortBy + " " + sortOrder}
next: get_production_connection

get_production_connection:
call: http.post
args:
url: "[#RAG_SEARCH_RESQL]/get-production-connection"
url: "[#RAG_SEARCH_RESQL]/get-production-connection-filtered"
body:
llm_platform: ${llmPlatform}
llm_model: ${llmModel}
embedding_platform: ${embeddingPlatform}
embedding_model: ${embeddingModel}
connection_status: ${connectionStatus}
sorting: ${sorting}
result: connection_result
next: return_success

Expand Down
32 changes: 28 additions & 4 deletions DSL/Ruuter.private/rag-search/POST/llm-connections/add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,23 @@ declaration:
type: string
description: "AWS access key"
# Embedding model credentials
- field: embedding_model_api_key
# Embedding AWS Bedrock credentials
- field: embedding_access_key
type: string
description: "Embedding model API key"
description: "AWS access key for embedding model"
- field: embedding_secret_key
type: string
description: "AWS secret key for embedding model"
# Embedding Azure credentials
- field: embedding_deployment_name
type: string
description: "Azure embedding deployment name"
- field: embedding_target_uri
type: string
description: "Azure embedding endpoint URI"
- field: embedding_azure_api_key
type: string
description: "Azure embedding API key"

extract_request_data:
assign:
Expand All @@ -77,7 +91,12 @@ extract_request_data:
api_key: ${incoming.body.api_key || ""}
secret_key: ${incoming.body.secret_key || ""}
access_key: ${incoming.body.access_key || ""}
embedding_model_api_key: ${incoming.body.embedding_model_api_key || ""}
# Embedding platform specific credentials
embedding_access_key: ${incoming.body.embedding_access_key || ""}
embedding_secret_key: ${incoming.body.embedding_secret_key || ""}
embedding_deployment_name: ${incoming.body.embedding_deployment_name || ""}
embedding_target_uri: ${incoming.body.embedding_target_uri || ""}
embedding_azure_api_key: ${incoming.body.embedding_azure_api_key || ""}
created_at: ${new Date().toISOString()}
next: validate_environment

Expand Down Expand Up @@ -138,7 +157,12 @@ add_llm_connection:
api_key: ${api_key}
secret_key: ${secret_key}
access_key: ${access_key}
embedding_model_api_key: ${embedding_model_api_key}
# Embedding platform specific credentials
embedding_access_key: ${embedding_access_key}
embedding_secret_key: ${embedding_secret_key}
embedding_deployment_name: ${embedding_deployment_name}
embedding_target_uri: ${embedding_target_uri}
embedding_azure_api_key: ${embedding_azure_api_key}
result: connection_result
next: assign_connection_response

Expand Down
32 changes: 28 additions & 4 deletions DSL/Ruuter.private/rag-search/POST/llm-connections/edit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,23 @@ declaration:
- field: access_key
type: string
description: "AWS access key"
- field: embedding_model_api_key
# Embedding AWS Bedrock credentials
- field: embedding_access_key
type: string
description: "Embedding model API key"
description: "AWS access key for embedding model"
- field: embedding_secret_key
type: string
description: "AWS secret key for embedding model"
# Embedding Azure credentials
- field: embedding_deployment_name
type: string
description: "Azure embedding deployment name"
- field: embedding_target_uri
type: string
description: "Azure embedding endpoint URI"
- field: embedding_azure_api_key
type: string
description: "Azure embedding API key"

extract_request_data:
assign:
Expand All @@ -78,7 +92,12 @@ extract_request_data:
api_key: ${incoming.body.api_key || ""}
secret_key: ${incoming.body.secret_key || ""}
access_key: ${incoming.body.access_key || ""}
embedding_model_api_key: ${incoming.body.embedding_model_api_key || ""}
# Embedding platform specific credentials
embedding_access_key: ${incoming.body.embedding_access_key || ""}
embedding_secret_key: ${incoming.body.embedding_secret_key || ""}
embedding_deployment_name: ${incoming.body.embedding_deployment_name || ""}
embedding_target_uri: ${incoming.body.embedding_target_uri || ""}
embedding_azure_api_key: ${incoming.body.embedding_azure_api_key || ""}
updated_at: ${new Date().toISOString()}
next: validate_environment

Expand Down Expand Up @@ -124,7 +143,12 @@ update_llm_connection:
api_key: ${api_key}
secret_key: ${secret_key}
access_key: ${access_key}
embedding_model_api_key: ${embedding_model_api_key}
# Embedding platform specific credentials
embedding_access_key: ${embedding_access_key}
embedding_secret_key: ${embedding_secret_key}
embedding_deployment_name: ${embedding_deployment_name}
embedding_target_uri: ${embedding_target_uri}
embedding_azure_api_key: ${embedding_azure_api_key}
result: connection_result
next: return_success

Expand Down
Loading
Loading