Custom Prompt Registry System Development

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1 servicesAll 1566 services
Custom Prompt Registry System Development
Medium
~2-3 business days
FAQ
AI Development Areas
AI Solution Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822

Development of a custom prompt management system (Prompt Registry)

A custom Prompt Registry is needed when ready-made solutions (PromptLayer, Humanloop) do not meet requirements: specific authentication, integration with corporate SSO, on-premise data storage, custom evaluation metrics, or atypical workflow.

Data schema

-- PostgreSQL схема
CREATE TABLE prompts (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    description TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    created_by VARCHAR(255) NOT NULL,
    tags TEXT[]
);

CREATE TABLE prompt_versions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    prompt_id UUID REFERENCES prompts(id),
    version_number INTEGER NOT NULL,
    content TEXT NOT NULL,
    content_hash VARCHAR(64) NOT NULL,  -- SHA256
    model VARCHAR(100) NOT NULL,
    temperature FLOAT DEFAULT 0.0,
    max_tokens INTEGER DEFAULT 1000,
    variables JSONB DEFAULT '[]',
    metadata JSONB DEFAULT '{}',
    created_at TIMESTAMPTZ DEFAULT NOW(),
    created_by VARCHAR(255) NOT NULL,
    UNIQUE(prompt_id, version_number)
);

CREATE TABLE prompt_deployments (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    prompt_version_id UUID REFERENCES prompt_versions(id),
    environment VARCHAR(50) NOT NULL,  -- dev/staging/production
    deployed_at TIMESTAMPTZ DEFAULT NOW(),
    deployed_by VARCHAR(255) NOT NULL,
    is_active BOOLEAN DEFAULT TRUE,
    rollback_of UUID  -- Ссылка на предыдущую версию при откате
);

CREATE TABLE prompt_executions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    prompt_version_id UUID REFERENCES prompt_versions(id),
    executed_at TIMESTAMPTZ DEFAULT NOW(),
    input_variables JSONB,
    rendered_prompt TEXT,
    response TEXT,
    input_tokens INTEGER,
    output_tokens INTEGER,
    latency_ms INTEGER,
    cost_usd FLOAT,
    quality_score FLOAT  -- Оценка качества (если доступна)
);

FastAPI service

from fastapi import FastAPI, HTTPException, Depends
from pydantic import BaseModel
import asyncpg

app = FastAPI(title="Prompt Registry API")

class PromptCreateRequest(BaseModel):
    name: str
    content: str
    model: str = "gpt-4o"
    temperature: float = 0.0
    description: str = None

@app.post("/prompts/{name}/versions")
async def create_version(
    name: str,
    request: PromptCreateRequest,
    db = Depends(get_db)
):
    # Проверка дубликата (одинаковый hash)
    content_hash = hashlib.sha256(request.content.encode()).hexdigest()
    existing = await db.fetchrow(
        "SELECT id FROM prompt_versions pv JOIN prompts p ON p.id = pv.prompt_id "
        "WHERE p.name = $1 AND pv.content_hash = $2",
        name, content_hash
    )
    if existing:
        raise HTTPException(400, "Identical prompt version already exists")

    # Создание версии
    version = await db.fetchrow("""
        INSERT INTO prompt_versions (prompt_id, version_number, content,
            content_hash, model, temperature)
        SELECT p.id,
               COALESCE(MAX(pv.version_number), 0) + 1,
               $2, $3, $4, $5
        FROM prompts p
        LEFT JOIN prompt_versions pv ON pv.prompt_id = p.id
        WHERE p.name = $1
        GROUP BY p.id
        RETURNING id, version_number
    """, name, request.content, content_hash, request.model, request.temperature)

    return {"version_id": str(version['id']), "version": version['version_number']}

@app.get("/prompts/{name}/latest")
async def get_latest(name: str, environment: str = "production", db = Depends(get_db)):
    prompt = await db.fetchrow("""
        SELECT pv.content, pv.model, pv.temperature, pv.variables, pv.version_number
        FROM prompt_versions pv
        JOIN prompt_deployments pd ON pd.prompt_version_id = pv.id
        JOIN prompts p ON p.id = pv.prompt_id
        WHERE p.name = $1 AND pd.environment = $2 AND pd.is_active = TRUE
        ORDER BY pd.deployed_at DESC LIMIT 1
    """, name, environment)

    if not prompt:
        raise HTTPException(404, f"No deployed prompt '{name}' in {environment}")
    return dict(prompt)

Python client

class PromptClient:
    def __init__(self, registry_url: str, api_key: str):
        self.url = registry_url
        self.headers = {"X-API-Key": api_key}
        self._cache = {}

    def get_and_render(self, name: str, variables: dict,
                       environment: str = "production") -> str:
        cache_key = f"{name}:{environment}"
        if cache_key not in self._cache:
            resp = requests.get(
                f"{self.url}/prompts/{name}/latest",
                params={"environment": environment},
                headers=self.headers
            )
            self._cache[cache_key] = resp.json()

        template = self._cache[cache_key]['content']
        for var, value in variables.items():
            template = template.replace(f"{{{{{var}}}}}", str(value))
        return template

A custom registry provides full control over data, the ability to integrate with any authentication system, and a custom retention policy for execution logs.