Skip to content

Commit 1eea645

Browse files
authored
Merge pull request #841 from Arshardh/aiwspc
2 parents 0109dbe + 0f485b0 commit 1eea645

File tree

26 files changed

+6967
-1655
lines changed

26 files changed

+6967
-1655
lines changed

gateway/gateway-controller/api/openapi.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,8 +3459,6 @@ components:
34593459
type: string
34603460
description: Unique id of a deployed llm provider
34613461
example: wso2-openai-provider
3462-
accessControl:
3463-
$ref: '#/components/schemas/LLMAccessControl'
34643462
policies:
34653463
type: array
34663464
description: List of policies applied only to this operation (overrides or adds to API-level policies)

gateway/gateway-controller/pkg/api/generated/generated.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-api/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ RUN mkdir -p /app/data && \
8989
COPY src/internal/database/schema.sql ./schema.sql
9090
COPY src/internal/database/schema.postgres.sql ./schema.postgres.sql
9191
COPY src/internal/database/schema.sqlite.sql ./schema.sqlite.sql
92+
COPY src/resources/default-llm-provider-templates ./default-llm-provider-templates
9293

9394
ARG PORT
9495
EXPOSE ${PORT}
9596

9697
ENV DRIVER=sqlite3
9798
ENV LOG_LEVEL=INFO
9899
ENV DB_SCHEMA_PATH=./schema.sql
100+
ENV LLM_TEMPLATE_DEFINITIONS_PATH=./default-llm-provider-templates
99101
# For SQLite: configured via DATABASE_DB_PATH to avoid clashing with OS PATH
100102
ENV DATABASE_DB_PATH=/app/data/api_platform.db
101103
ENV PORT=${PORT}

platform-api/src/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type Server struct {
3636
Database Database `envconfig:"DATABASE"`
3737
DBSchemaPath string `envconfig:"DB_SCHEMA_PATH" default:"./internal/database/schema.sql"`
3838

39+
// LLM provider template bootstrap (used to seed defaults into the DB)
40+
LLMTemplateDefinitionsPath string `envconfig:"LLM_TEMPLATE_DEFINITIONS_PATH" default:"./resources/default-llm-provider-templates"`
41+
3942
// JWT Authentication configurations
4043
JWT JWT `envconfig:"JWT"`
4144

platform-api/src/internal/constants/error.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,21 @@ var (
123123
ErrWSO2ArtifactNotFound = errors.New("WSO2 API artifact not found")
124124
)
125125

126+
var (
127+
ErrLLMProviderTemplateExists = errors.New("llm provider template already exists")
128+
ErrLLMProviderTemplateNotFound = errors.New("llm provider template not found")
129+
ErrLLMProviderExists = errors.New("llm provider already exists")
130+
ErrLLMProviderNotFound = errors.New("llm provider not found")
131+
ErrLLMProxyExists = errors.New("llm proxy already exists")
132+
ErrLLMProxyNotFound = errors.New("llm proxy not found")
133+
)
134+
126135
var (
127136
// API Key errors
128-
ErrAPIKeyNotFound = errors.New("api key not found")
129-
ErrAPIKeyAlreadyExists = errors.New("api key already exists")
130-
ErrInvalidAPIKey = errors.New("invalid api key")
131-
ErrGatewayUnavailable = errors.New("gateway unavailable")
132-
ErrAPIKeyEventDelivery = errors.New("failed to deliver api key event to gateway")
133-
ErrAPIKeyHashingFailed = errors.New("failed to hash api key")
137+
ErrAPIKeyNotFound = errors.New("api key not found")
138+
ErrAPIKeyAlreadyExists = errors.New("api key already exists")
139+
ErrInvalidAPIKey = errors.New("invalid api key")
140+
ErrGatewayUnavailable = errors.New("gateway unavailable")
141+
ErrAPIKeyEventDelivery = errors.New("failed to deliver api key event to gateway")
142+
ErrAPIKeyHashingFailed = errors.New("failed to hash api key")
134143
)

platform-api/src/internal/database/schema.postgres.sql

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
349349
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
350350
);
351351

352+
-- LLM Provider Templates table
353+
CREATE TABLE IF NOT EXISTS llm_provider_templates (
354+
uuid VARCHAR(40) PRIMARY KEY,
355+
organization_uuid VARCHAR(40) NOT NULL,
356+
handle VARCHAR(255) NOT NULL,
357+
name VARCHAR(253) NOT NULL,
358+
description VARCHAR(1023),
359+
created_by VARCHAR(255),
360+
configuration TEXT NOT NULL,
361+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
362+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
363+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
364+
UNIQUE(organization_uuid, handle)
365+
);
366+
367+
-- LLM Providers table
368+
CREATE TABLE IF NOT EXISTS llm_providers (
369+
uuid VARCHAR(40) PRIMARY KEY,
370+
organization_uuid VARCHAR(40) NOT NULL,
371+
handle VARCHAR(255) NOT NULL,
372+
name VARCHAR(100) NOT NULL,
373+
description VARCHAR(1023),
374+
created_by VARCHAR(255),
375+
version VARCHAR(30) NOT NULL,
376+
context VARCHAR(200) DEFAULT '/',
377+
vhost VARCHAR(253),
378+
template VARCHAR(255) NOT NULL,
379+
upstream_url TEXT NOT NULL,
380+
upstream_auth TEXT,
381+
openapi_spec TEXT,
382+
model_list TEXT,
383+
rate_limiting TEXT,
384+
access_control TEXT,
385+
policies TEXT,
386+
security TEXT,
387+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
388+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
389+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
390+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
391+
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
392+
UNIQUE(organization_uuid, handle)
393+
);
394+
395+
-- LLM Proxies table
396+
CREATE TABLE IF NOT EXISTS llm_proxies (
397+
uuid VARCHAR(40) PRIMARY KEY,
398+
organization_uuid VARCHAR(40) NOT NULL,
399+
project_uuid VARCHAR(40) NOT NULL,
400+
handle VARCHAR(255) NOT NULL,
401+
name VARCHAR(253) NOT NULL,
402+
description VARCHAR(1023),
403+
created_by VARCHAR(255),
404+
version VARCHAR(30) NOT NULL,
405+
context VARCHAR(200) DEFAULT '/',
406+
vhost VARCHAR(253),
407+
provider VARCHAR(255) NOT NULL,
408+
openapi_spec TEXT,
409+
policies TEXT,
410+
security TEXT,
411+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
412+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
413+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
414+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
415+
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
416+
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
417+
UNIQUE(organization_uuid, handle)
418+
);
419+
352420
-- Indexes for better performance
353421
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
354422
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
@@ -379,3 +447,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
379447
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
380448
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
381449
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
450+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
451+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
452+
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
453+
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
454+
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
455+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
456+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
457+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
458+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);

platform-api/src/internal/database/schema.sql

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
348348
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
349349
);
350350

351+
-- LLM Provider Templates table
352+
CREATE TABLE IF NOT EXISTS llm_provider_templates (
353+
uuid VARCHAR(40) PRIMARY KEY,
354+
organization_uuid VARCHAR(40) NOT NULL,
355+
handle VARCHAR(255) NOT NULL,
356+
name VARCHAR(253) NOT NULL,
357+
description VARCHAR(1023),
358+
created_by VARCHAR(255),
359+
configuration TEXT NOT NULL,
360+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
361+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
362+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
363+
UNIQUE(organization_uuid, handle)
364+
);
365+
366+
-- LLM Providers table
367+
CREATE TABLE IF NOT EXISTS llm_providers (
368+
uuid VARCHAR(40) PRIMARY KEY,
369+
organization_uuid VARCHAR(40) NOT NULL,
370+
handle VARCHAR(255) NOT NULL,
371+
name VARCHAR(100) NOT NULL,
372+
description VARCHAR(1023),
373+
created_by VARCHAR(255),
374+
version VARCHAR(30) NOT NULL,
375+
context VARCHAR(200) DEFAULT '/',
376+
vhost VARCHAR(253),
377+
template VARCHAR(255) NOT NULL,
378+
upstream_url TEXT NOT NULL,
379+
upstream_auth TEXT,
380+
openapi_spec TEXT,
381+
model_list TEXT,
382+
rate_limiting TEXT,
383+
access_control TEXT,
384+
policies TEXT,
385+
security TEXT,
386+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
387+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
388+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
389+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
390+
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
391+
UNIQUE(organization_uuid, handle)
392+
);
393+
394+
-- LLM Proxies table
395+
CREATE TABLE IF NOT EXISTS llm_proxies (
396+
uuid VARCHAR(40) PRIMARY KEY,
397+
organization_uuid VARCHAR(40) NOT NULL,
398+
project_uuid VARCHAR(40) NOT NULL,
399+
handle VARCHAR(255) NOT NULL,
400+
name VARCHAR(253) NOT NULL,
401+
description VARCHAR(1023),
402+
created_by VARCHAR(255),
403+
version VARCHAR(30) NOT NULL,
404+
context VARCHAR(200) DEFAULT '/',
405+
vhost VARCHAR(253),
406+
provider VARCHAR(255) NOT NULL,
407+
openapi_spec TEXT,
408+
policies TEXT,
409+
security TEXT,
410+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
411+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
412+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
413+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
414+
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
415+
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
416+
UNIQUE(organization_uuid, handle)
417+
);
418+
351419
-- Indexes for better performance
352420
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
353421
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
@@ -377,3 +445,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
377445
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
378446
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
379447
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
448+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
449+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
450+
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
451+
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
452+
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
453+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
454+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
455+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
456+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);

platform-api/src/internal/database/schema.sqlite.sql

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,74 @@ CREATE TABLE IF NOT EXISTS api_publications (
349349
UNIQUE (api_uuid, devportal_uuid, organization_uuid)
350350
);
351351

352+
-- LLM Provider Templates table
353+
CREATE TABLE IF NOT EXISTS llm_provider_templates (
354+
uuid VARCHAR(40) PRIMARY KEY,
355+
organization_uuid VARCHAR(40) NOT NULL,
356+
handle VARCHAR(255) NOT NULL,
357+
name VARCHAR(253) NOT NULL,
358+
description VARCHAR(1023),
359+
created_by VARCHAR(255),
360+
configuration TEXT NOT NULL,
361+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
362+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
363+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
364+
UNIQUE(organization_uuid, handle)
365+
);
366+
367+
-- LLM Providers table
368+
CREATE TABLE IF NOT EXISTS llm_providers (
369+
uuid VARCHAR(40) PRIMARY KEY,
370+
organization_uuid VARCHAR(40) NOT NULL,
371+
handle VARCHAR(255) NOT NULL,
372+
name VARCHAR(100) NOT NULL,
373+
description VARCHAR(1023),
374+
created_by VARCHAR(255),
375+
version VARCHAR(30) NOT NULL,
376+
context VARCHAR(200) DEFAULT '/',
377+
vhost VARCHAR(253),
378+
template VARCHAR(255) NOT NULL,
379+
upstream_url TEXT NOT NULL,
380+
upstream_auth TEXT,
381+
openapi_spec TEXT,
382+
model_list TEXT,
383+
rate_limiting TEXT,
384+
access_control TEXT,
385+
policies TEXT,
386+
security TEXT,
387+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
388+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
389+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
390+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
391+
FOREIGN KEY (organization_uuid, template) REFERENCES llm_provider_templates(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
392+
UNIQUE(organization_uuid, handle)
393+
);
394+
395+
-- LLM Proxies table
396+
CREATE TABLE IF NOT EXISTS llm_proxies (
397+
uuid VARCHAR(40) PRIMARY KEY,
398+
organization_uuid VARCHAR(40) NOT NULL,
399+
project_uuid VARCHAR(40) NOT NULL,
400+
handle VARCHAR(255) NOT NULL,
401+
name VARCHAR(253) NOT NULL,
402+
description VARCHAR(1023),
403+
created_by VARCHAR(255),
404+
version VARCHAR(30) NOT NULL,
405+
context VARCHAR(200) DEFAULT '/',
406+
vhost VARCHAR(253),
407+
provider VARCHAR(255) NOT NULL,
408+
openapi_spec TEXT,
409+
policies TEXT,
410+
security TEXT,
411+
status VARCHAR(20) NOT NULL DEFAULT 'CREATED',
412+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
413+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
414+
FOREIGN KEY (organization_uuid) REFERENCES organizations(uuid) ON DELETE CASCADE,
415+
FOREIGN KEY (project_uuid) REFERENCES projects(uuid) ON DELETE CASCADE,
416+
FOREIGN KEY (organization_uuid, provider) REFERENCES llm_providers(organization_uuid, handle) ON UPDATE CASCADE ON DELETE RESTRICT,
417+
UNIQUE(organization_uuid, handle)
418+
);
419+
352420
-- Indexes for better performance
353421
CREATE INDEX IF NOT EXISTS idx_projects_organization_id ON projects(organization_uuid);
354422
CREATE INDEX IF NOT EXISTS idx_organizations_handle ON organizations(handle);
@@ -378,3 +446,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_devportals_default_per_org ON devportals(o
378446
CREATE INDEX IF NOT EXISTS idx_api_associations_api_resource_type ON api_associations(api_uuid, association_type, organization_uuid);
379447
CREATE INDEX IF NOT EXISTS idx_api_associations_resource ON api_associations(association_type, resource_uuid, organization_uuid);
380448
CREATE INDEX IF NOT EXISTS idx_api_associations_org ON api_associations(organization_uuid);
449+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_org ON llm_provider_templates(organization_uuid);
450+
CREATE INDEX IF NOT EXISTS idx_llm_provider_templates_handle ON llm_provider_templates(organization_uuid, handle);
451+
CREATE INDEX IF NOT EXISTS idx_llm_providers_org ON llm_providers(organization_uuid);
452+
CREATE INDEX IF NOT EXISTS idx_llm_providers_handle ON llm_providers(organization_uuid, handle);
453+
CREATE INDEX IF NOT EXISTS idx_llm_providers_template ON llm_providers(organization_uuid, template);
454+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_org ON llm_proxies(organization_uuid);
455+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_project ON llm_proxies(organization_uuid, project_uuid);
456+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_handle ON llm_proxies(organization_uuid, handle);
457+
CREATE INDEX IF NOT EXISTS idx_llm_proxies_provider ON llm_proxies(organization_uuid, provider);

0 commit comments

Comments
 (0)