diff --git a/core/skills/rh-qs-architect/SKILL.md b/core/skills/rh-qs-architect/SKILL.md index bec468e..8fb1142 100644 --- a/core/skills/rh-qs-architect/SKILL.md +++ b/core/skills/rh-qs-architect/SKILL.md @@ -111,23 +111,50 @@ If `decision_points` is non-empty, present each to the user. Update `.rhoai-qs/{ #### Step 5: Select ai-architecture-charts -Spawn the **chart-selector** subagent with the refined features: +**Try OpenAI Decision API first:** -```python -Agent( - description="Select ai-architecture-charts for this quickstart", - prompt=f""" -Read and follow instructions from: -core/skills/rh-qs-architect/subagents/chart-selector-prompt.md +Run the chart selector script: -input_features: {input_features} -deployment_questions: {deployment_questions} -slug: {slug} -charts_reference_path: core/skills/rh-qs-architect/references/ai-architecture-charts.md -""" +```python +result = Bash( + description="Select charts using OpenAI Decision API", + command=f"python3 core/skills/rh-qs-architect/scripts/openai_decision_chart_selector.py --slug {slug}" ) ``` +If the script succeeds (exit code 0): +1. Parse the JSON output to get `selected` and `uncertain` chart arrays +2. If `uncertain` is non-empty, present each uncertain chart to the user: + ``` + ⚠️ Uncertain chart selections - please review: + - {chart_name}: {probability} ({reason}) + + Should this chart be included? [y/n] + ``` +3. Merge user-approved uncertain charts into the selected list +4. Store the combined selection as `{selected_charts}` and continue to Step 6 + +**Fallback to LLM subagent if script fails:** + +If the script exits non-zero (OPENAI_API_KEY missing, API error, refusal, or other error): +1. Log the failure reason from stderr +2. Spawn the **chart-selector** subagent: + ```python + Agent( + description="Select ai-architecture-charts for this quickstart", + prompt=f""" + Read and follow instructions from: + core/skills/rh-qs-architect/subagents/chart-selector-prompt.md + + input_features: {input_features} + deployment_questions: {deployment_questions} + slug: {slug} + charts_reference_path: core/skills/rh-qs-architect/references/ai-architecture-charts.json + """ + ) + ``` +3. Store the subagent's returned charts as `{selected_charts}` and continue to Step 6 + #### Step 6: Map leftover features to OpenShift AI Prefer the charts selected in Step 5. For each refined PRD feature: diff --git a/core/skills/rh-qs-architect/references/ai-architecture-charts.json b/core/skills/rh-qs-architect/references/ai-architecture-charts.json new file mode 100644 index 0000000..267820d --- /dev/null +++ b/core/skills/rh-qs-architect/references/ai-architecture-charts.json @@ -0,0 +1,119 @@ +{ + "llama-stack": { + "description": "Comprehensive AI orchestration platform that provides a unified API for multiple model providers, safety shields, and AI agent capabilities.", + "provides": [ + "Multi-provider model support (local, remote, VertexAI)", + "Safety shields with Llama Guard and other safety models", + "AI agent capabilities with persistent memory", + "Automatic model discovery and URL generation" + ], + "use_when": "Comprehensive AI orchestration platform needed" + }, + "ogx-ai": { + "description": "Successor chart providing orchestration with OpenAI-compatible APIs, multi-provider model support, and MCP-style tool integration.", + "provides": [ + "OpenAI-compatible agentic API server", + "Multi-provider model support (local, remote, VertexAI)", + "Content moderation via OpenAI-compatible /v1/moderations endpoint", + "AI agent capabilities with persistent memory", + "Automatic model discovery and URL generation", + "Supersedes llama-stack for new deployments" + ], + "use_when": "Agentic orchestration with OpenAI compatibility needed" + }, + "llm-service": { + "description": "High-performance model serving using vLLM runtime with OpenShift AI/KServe integration supporting GPU and CPU deployment modes.", + "provides": [ + "vLLM-based model serving with OpenAI-compatible API", + "Support for any vLLM-compatible models and sizes", + "GPU/CPU deployment flexibility", + "Tool calling and function execution support", + "OpenShift AI/KServe integration" + ], + "use_when": "On-cluster GPU model serving required" + }, + "pgvector": { + "description": "PostgreSQL with pgvector extension enabling high-performance vector database capabilities for embeddings in AI/ML applications.", + "provides": [ + "Vector similarity search (cosine, L2, inner product)", + "Multiple index types (IVFFlat, HNSW)", + "Support for various embedding dimensions", + "ACID compliance with PostgreSQL reliability" + ], + "use_when": "Vector database for RAG/semantic retrieval needed" + }, + "minio": { + "description": "S3-compatible object storage server for documents, models, and data in AI/ML pipelines with scalable storage and web console management.", + "provides": [ + "S3-compatible API", + "Web-based management console", + "Bucket policies and lifecycle management", + "Sample file upload functionality" + ], + "use_when": "Object storage for documents/models/data needed" + }, + "oracle-db": { + "description": "Oracle Database Free 23ai with AI Vector features providing enterprise-grade database capabilities with built-in vector operations.", + "provides": [ + "Native vector operations and similarity search", + "JSON duality and graph analytics", + "Enterprise database reliability", + "AI-optimized storage and indexing", + "TPC-DS automated data population via Kubernetes Job", + "Configurable scale factors and schema management", + "Automated security configuration for AI MCP server integration" + ], + "use_when": "Enterprise database with AI vector features needed" + }, + "ingestion-pipeline": { + "description": "Comprehensive data ingestion pipeline processing documents from various sources and storing vector embeddings for semantic search and RAG.", + "provides": [ + "Multi-source data ingestion (S3/MinIO, GitHub, URLs)", + "Document chunking and embedding generation", + "REST API for pipeline management", + "Integration with vector databases" + ], + "use_when": "Automated document ingestion and embedding pipeline needed" + }, + "configure-pipeline": { + "description": "Jupyter notebook environment for RAG configuration and pipeline setup with interactive tools and MinIO integration for data access.", + "provides": [ + "Pre-configured Jupyter environment", + "RAG pipeline configuration tools", + "MinIO integration for data access", + "Template and configuration management" + ], + "use_when": "Interactive RAG configuration and pipeline setup needed" + }, + "mcp-servers": { + "description": "Model Context Protocol servers providing external tools and capabilities to AI models for interacting with external systems and APIs.", + "provides": [ + "Weather information services", + "Server-Sent Events (SSE) endpoints", + "Custom tool development framework", + "Integration with LlamaStack and OGX agents" + ], + "use_when": "External tools and capabilities for AI agents needed" + }, + "oracle-sqlcl": { + "description": "MCP server exposing Oracle SQLcl capabilities to AI agents via Toolhive, enabling database tooling and interactions from AI platforms.", + "provides": [ + "Execute SQL/PLSQL against Oracle databases via Model Context Protocol", + "Integrates with Toolhive Operator (CRDs and operator managed as chart dependencies)", + "Oracle connection managed via Kubernetes secrets and configurable service" + ], + "use_when": "Oracle database tooling for AI agents needed" + }, + "keycloak": { + "description": "Identity and access management solution providing authentication and authorization for AI applications via OAuth2, OpenID Connect, and SAML.", + "provides": [ + "Official Keycloak container images", + "OAuth2, OpenID Connect, and SAML protocols", + "Built-in PostgreSQL database (via pgvector subchart) or external database support", + "OpenShift Routes and Kubernetes Ingress support", + "Production-ready configuration with health checks and metrics", + "Flexible authentication and authorization policies" + ], + "use_when": "Identity and access management for AI applications needed" + } +} diff --git a/core/skills/rh-qs-architect/references/ai-architecture-charts.md b/core/skills/rh-qs-architect/references/ai-architecture-charts.md deleted file mode 100644 index 6ba4731..0000000 --- a/core/skills/rh-qs-architect/references/ai-architecture-charts.md +++ /dev/null @@ -1,130 +0,0 @@ -# ai-architecture-charts - -Repository: https://github.com/rh-ai-quickstart/ai-architecture-charts -Helm repo: https://rh-ai-quickstart.github.io/ai-architecture-charts - -Use during `rh-qs-architect` to select subcharts; `rh-qs-deploy` wires them as Helm dependencies. - -## Architecture Components - -### Core AI Services - -#### LlamaStack (`llama-stack`) -Comprehensive AI orchestration platform that provides a unified API for multiple model providers, safety shields, and AI agent capabilities. Supports local models (via LLM Service), remote vLLM endpoints, and VertexAI integration. - -**Key Features:** -- Multi-provider model support (local, remote, VertexAI) -- Safety shields with Llama Guard and other safety models -- AI agent capabilities with persistent memory -- Automatic model discovery and URL generation - -#### OGX (`ogx-ai`) -Successor chart for OGX (formerly Llama Stack). Provides the same orchestration role as the llama-stack chart with OpenAI-compatible APIs, multi-provider model support, and MCP-style tool integration. Use **ogx-ai** for new deployments; **llama-stack** remains available for backwards compatibility. - -**Key Features:** -- OpenAI-compatible agentic API server -- Multi-provider model support (local, remote, VertexAI) -- Content moderation via OpenAI-compatible `/v1/moderations` endpoint -- AI agent capabilities with persistent memory -- Automatic model discovery and URL generation - -#### LLM Service (`llm-service`) -High-performance model serving infrastructure using vLLM runtime with OpenShift AI/KServe integration. Supports GPU and CPU deployment modes with any models compatible with vLLM. - -**Key Features:** -- vLLM-based model serving with OpenAI-compatible API -- Support for any vLLM-compatible models and sizes -- GPU/CPU deployment flexibility -- Tool calling and function execution support - -### Data & Storage Services - -#### PGVector (`pgvector`) -PostgreSQL with pgvector extension providing high-performance vector database capabilities for storing and querying embeddings in AI/ML applications. - -**Key Features:** -- Vector similarity search (cosine, L2, inner product) -- Multiple index types (IVFFlat, HNSW) -- Support for various embedding dimensions -- ACID compliance with PostgreSQL reliability - -#### MinIO (`minio`) -S3-compatible object storage server for documents, models, and data in AI/ML pipelines. Provides scalable storage with web console management. - -**Key Features:** -- S3-compatible API -- Web-based management console -- Bucket policies and lifecycle management -- Sample file upload functionality - -#### Oracle 23ai (`oracle-db`) -Oracle Database Free 23ai with AI Vector features, providing enterprise-grade database capabilities with built-in vector operations for AI applications. - -**Key Features:** -- Native vector operations and similarity search -- JSON duality and graph analytics -- Enterprise database reliability -- AI-optimized storage and indexing - -**TPC-DS Data Population Job:** -The Oracle 23ai chart includes an automated TPC-DS data population job that creates comprehensive test datasets for AI/ML applications. This Kubernetes Job replaces manual database setup scripts with a cloud-native approach: - -- **Purpose**: Automatically populates the Oracle database with standardized TPC-DS benchmark data (25 tables with synthetic retail/e-commerce data) -- **Scale Factor**: Configurable data volume (default generates ~1GB of test data) -- **Schema Management**: Creates both SYSTEM and Sales schemas with proper data distribution -- **Security**: Applies read-only restrictions to the Sales user for safe AI MCP server integration -- **Automation**: Eliminates manual database setup, ensuring consistent test data across deployments -- **Integration**: Provides realistic datasets for RAG applications, vector search testing, and AI agent development - -The job runs automatically when `tpcds.enabled=true` and handles the complete lifecycle from database readiness verification to data loading and security configuration. - -### Pipeline & Processing Services - -#### Ingestion Pipeline (`ingestion-pipeline`) -Comprehensive data ingestion pipeline that processes documents from various sources (S3, GitHub, URLs) and stores vector embeddings for semantic search and RAG applications. - -**Key Features:** -- Multi-source data ingestion (S3/MinIO, GitHub, URLs) -- Document chunking and embedding generation -- REST API for pipeline management -- Integration with vector databases - -#### Configure Pipeline (`configure-pipeline`) -Jupyter notebook environment for RAG configuration and pipeline setup. Provides interactive tools for configuring and testing AI pipelines. - -**Key Features:** -- Pre-configured Jupyter environment -- RAG pipeline configuration tools -- MinIO integration for data access -- Template and configuration management - -### Integration & Tools - -#### MCP Servers (`mcp-servers`) -Model Context Protocol servers that provide external tools and capabilities to AI models, enabling AI agents to interact with external systems and APIs. - -**Key Features:** -- Weather information services -- Server-Sent Events (SSE) endpoints -- Custom tool development framework -- Integration with LlamaStack and OGX agents - -#### Oracle SQLcl MCP (`oracle-sqlcl`) -MCP server that exposes Oracle SQLcl capabilities to AI agents via Toolhive, enabling database tooling and interactions from LlamaStack, OGX, and compatible clients. - -**Key Features:** -- Execute SQL/PLSQL against Oracle databases via Model Context Protocol -- Integrates with Toolhive Operator (CRDs and operator managed as chart dependencies) -- Oracle connection managed via Kubernetes secrets and configurable service - -### Security & Identity - -#### Keycloak (`keycloak`) -Identity and access management solution providing authentication and authorization for AI applications. Supports OAuth2, OpenID Connect, and SAML protocols. - -**Key Features:** -- Official Keycloak container images -- Built-in PostgreSQL database (via pgvector subchart) or external database support -- OpenShift Routes and Kubernetes Ingress support -- Production-ready configuration with health checks and metrics -- Flexible authentication and authorization policies diff --git a/core/skills/rh-qs-architect/scripts/openai_decision_chart_selector.py b/core/skills/rh-qs-architect/scripts/openai_decision_chart_selector.py new file mode 100755 index 0000000..ef49856 --- /dev/null +++ b/core/skills/rh-qs-architect/scripts/openai_decision_chart_selector.py @@ -0,0 +1,404 @@ +#!/usr/bin/env python3 +""" +OpenAI Decision API chart selector for AI Quickstarts. +Evaluates 11 charts in parallel using predicate questions. +""" + +import argparse +import json +import os +import sys +from pathlib import Path + +try: + from openai import OpenAI + import openai +except ImportError: + print("Error: openai package not installed. Run: pip install openai", file=sys.stderr) + sys.exit(1) + +import yaml + +# Constants +CHARTS_JSON_PATH = "core/skills/rh-qs-architect/references/ai-architecture-charts.json" +DEFAULT_INCLUDE_THRESHOLD = 0.7 +DEFAULT_REVIEW_THRESHOLD = 0.4 + + +def load_prd_features(path: Path) -> dict: + """Load prd-features.yaml and return input_features and deployment_questions.""" + try: + with open(path) as f: + data = yaml.safe_load(f) + return { + "input_features": data.get("input_features", {}), + "deployment_questions": data.get("deployment_questions", []) + } + except FileNotFoundError: + print(f"Error: prd-features.yaml not found at {path}", file=sys.stderr) + sys.exit(1) + except Exception as e: + print(f"Error loading prd-features.yaml: {e}", file=sys.stderr) + sys.exit(1) + + +def load_chart_capabilities(path: Path) -> dict: + """Load ai-architecture-charts.json.""" + try: + with open(path) as f: + return json.load(f) + except FileNotFoundError: + print(f"Error: ai-architecture-charts.json not found at {path}", file=sys.stderr) + sys.exit(1) + except Exception as e: + print(f"Error loading ai-architecture-charts.json: {e}", file=sys.stderr) + sys.exit(1) + + +def build_input_context(input_features: dict, deployment_questions: list, chart_capabilities: dict) -> str: + """Build input context JSON string for Decision API. + + Includes chart descriptions, capabilities (provides), and use_when guidance. + """ + context = { + "input_features": input_features, + "deployment_questions": deployment_questions, + "chart_capabilities": chart_capabilities + } + return json.dumps(context, indent=2) + + +def get_predicate_questions() -> list: + """Define 11 predicate questions for chart selection.""" + return [ + { + "type": "predicate", + "name": "needs_llama_stack", + "instructions": """Based on the llama-stack chart description and capabilities, does this quickstart need it? + +NOTE: llama-stack is available for backwards compatibility. For new deployments, prefer ogx-ai. + +Evaluate TRUE if: +- The quickstart requires multi-provider model access, safety shields, or comprehensive AI orchestration platform capabilities that LlamaStack provides +- The input_features or deployment_questions explicitly require LlamaStack-specific features +- This is an existing quickstart already using llama-stack + +Evaluate FALSE if: +- The quickstart doesn't need these capabilities +- Uses a simpler orchestration approach +- This is a new deployment (prefer ogx-ai) +- Already uses OGX (which supersedes LlamaStack for new deployments) +- No orchestration framework mentioned""" + }, + { + "type": "predicate", + "name": "needs_ogx", + "instructions": """Based on the ogx-ai chart description and capabilities, does this quickstart need it? + +NOTE: ogx-ai is the successor to llama-stack. Use for new deployments. + +Evaluate TRUE if: +- The ai_pattern includes 'agents' or 'tool-calling' +- The tech_stack includes 'OGX' +- deployment_questions mention agent orchestration or tool integration +- Components include 'agents' or similar +- This is a new deployment requiring orchestration + +Evaluate FALSE if: +- No agent orchestration needs +- Uses a custom framework without OGX +- Already using LlamaStack (backward compatibility case)""" + }, + { + "type": "predicate", + "name": "needs_llm_service", + "instructions": """Based on the llm-service chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart requires GPU/CPU model serving +- tech_stack includes 'vLLM' or 'model-serving' +- ai_pattern includes 'text-generation', 'classification', or other LLM-based patterns +- deployment_questions mention model serving strategy +- components include 'ml-serving' + +Evaluate FALSE if: +- Uses external model APIs only (e.g., OpenAI, VertexAI) +- Doesn't serve models locally +- No LLM inference needed""" + }, + { + "type": "predicate", + "name": "needs_pgvector", + "instructions": """Based on the pgvector chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The ai_pattern includes 'rag', 'semantic-search', or 'retrieval' +- data_layer includes 'vector-store' +- tech_stack includes 'pgvector' +- deployment_questions mention vector search or embeddings + +Evaluate FALSE if: +- No vector search or RAG capabilities needed +- Uses a different vector database (e.g., Oracle with vector features) +- No semantic retrieval required""" + }, + { + "type": "predicate", + "name": "needs_minio", + "instructions": """Based on the minio chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart needs S3-compatible storage for documents, models, or datasets +- tech_stack includes 'minio' or 's3' +- data_layer includes 'object-storage' +- deployment_questions mention object storage strategy +- components include 'storage' + +Evaluate FALSE if: +- No object storage needs +- Uses external S3/cloud storage +- Only needs relational database storage""" + }, + { + "type": "predicate", + "name": "needs_oracle_db", + "instructions": """Based on the oracle-db chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart specifically requires Oracle database with vector operations +- tech_stack includes 'oracle' or 'Oracle' +- data_layer includes 'enterprise-db' or 'tpc-ds' +- deployment_questions mention Oracle-specific features + +Evaluate FALSE if: +- Uses PostgreSQL or another database +- Doesn't need Oracle-specific features +- No enterprise database requirements""" + }, + { + "type": "predicate", + "name": "needs_ingestion_pipeline", + "instructions": """Based on the ingestion-pipeline chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart requires automated document ingestion from S3/GitHub/URLs +- deployment_questions mention data ingestion pipeline or automated ingestion +- ai_pattern includes 'rag' AND data needs to be ingested (not just queried) +- components include 'ingestion' or 'pipeline' + +Evaluate FALSE if: +- Manual data upload only +- Application handles ingestion directly in code +- No automated ingestion needs""" + }, + { + "type": "predicate", + "name": "needs_configure_pipeline", + "instructions": """Based on the configure-pipeline chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart benefits from Jupyter-based RAG configuration tools +- platform includes 'interactive' or components include 'notebook' +- deployment_questions mention interactive pipeline setup or experimentation +- ai_pattern includes 'experimentation' + +Evaluate FALSE if: +- RAG configuration is coded directly in the application +- No RAG needed +- No interactive development environment required""" + }, + { + "type": "predicate", + "name": "needs_mcp_servers", + "instructions": """Based on the mcp-servers chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart's agents require external tools (weather, custom MCP servers) +- deployment_questions mention tool integration, external tools, or MCP +- ai_pattern includes 'tool-calling' or 'agents' AND external tools are mentioned +- components include 'mcp' or 'tools' + +Evaluate FALSE if: +- Agents use only built-in tools +- No agent capabilities needed +- No external tool integration required""" + }, + { + "type": "predicate", + "name": "needs_oracle_sqlcl", + "instructions": """Based on the oracle-sqlcl chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart's agents need to execute SQL/PLSQL against Oracle databases +- tech_stack includes 'oracle' AND ai_pattern includes 'agents' or 'tool-calling' +- deployment_questions specifically mention Oracle database interaction for agents +- ai_pattern includes 'text-to-sql' AND tech_stack includes 'oracle' + +Evaluate FALSE if: +- No Oracle database +- Agents don't need database tooling +- Uses PostgreSQL or other databases""" + }, + { + "type": "predicate", + "name": "needs_keycloak", + "instructions": """Based on the keycloak chart description and capabilities, does this quickstart need it? + +Evaluate TRUE if: +- The quickstart requires OAuth2, OpenID Connect, SAML, or multi-user authentication +- tech_stack includes 'keycloak' +- platform includes 'multi-user' +- components include 'auth' or 'authentication' +- deployment_questions mention IAM, authentication, or authorization + +Evaluate FALSE if: +- Single-user demo +- No authentication needed +- Uses external IdP (identity provider)""" + } + ] + + +def call_decision_api(client: OpenAI, input_context: str, questions: list) -> dict: + """Call OpenAI Decision API and return the response.""" + try: + decision = client.decisions.create( + model="gpt-6-luna", + input=input_context, + questions=questions + ) + return decision + except openai.APIError as e: + print(f"Error: OpenAI API error: {e}", file=sys.stderr) + sys.exit(1) + except Exception as e: + print(f"Error: Unexpected error calling Decision API: {e}", file=sys.stderr) + sys.exit(1) + + +def process_answers(answers: list, include_threshold: float, review_threshold: float) -> tuple: + """ + Process Decision API answers and return (selected_charts, uncertain_charts). + + Applies thresholds and enforces mutual exclusion (ogx over llama-stack). + """ + selected = [] + uncertain = [] + + for answer in answers: + if answer.type == "refusal": + print(f"Error: Question {answer.name} was refused by Decision API", file=sys.stderr) + sys.exit(1) + + chart_name = answer.name.replace("needs_", "") + chart_name = chart_name.replace("_", "-") # needs_llm_service -> llm-service + probability = answer.probability + + if probability >= include_threshold: + selected.append({ + "name": chart_name, + "reason": f"Selected with {probability:.2f} probability" + }) + elif probability >= review_threshold: + uncertain.append({ + "name": chart_name, + "reason": f"Uncertain with {probability:.2f} probability" + }) + + # Enforce mutual exclusion: ogx over llama-stack + selected_names = [c["name"] for c in selected] + if "ogx-ai" in selected_names and "llama-stack" in selected_names: + selected = [c for c in selected if c["name"] != "llama-stack"] + + return selected, uncertain + + +def print_chart_probabilities(answers: list, questions: list) -> None: + """Print each chart's Decision API probability to stderr for debugging.""" + probabilities = { + answer.name: answer.probability + for answer in answers + if answer.type != "refusal" + } + + print("Chart probabilities (0-1):", file=sys.stderr) + for question in questions: + question_name = question["name"] + chart_name = question_name.replace("needs_", "", 1).replace("_", "-") + probability = probabilities.get(question_name) + value = f"{probability:.3f}" if probability is not None else "unavailable" + print(f" {chart_name}: {value}", file=sys.stderr) + + +def main(): + parser = argparse.ArgumentParser( + description="Select ai-architecture-charts using OpenAI Decision API" + ) + parser.add_argument("--slug", required=True, help="Quickstart slug") + parser.add_argument( + "--debug", + action="store_true", + help="Print the probability of each chart to stderr" + ) + parser.add_argument( + "--prd-features-path", + type=Path, + help="Path to prd-features.yaml (optional, computed from slug if not provided)" + ) + args = parser.parse_args() + + # Check for OPENAI_API_KEY + if not os.getenv("OPENAI_API_KEY"): + print("Error: OPENAI_API_KEY environment variable not set", file=sys.stderr) + sys.exit(1) + + # Get thresholds from env vars or defaults + include_threshold = float(os.getenv("CHART_SELECTOR_INCLUDE_THRESHOLD", DEFAULT_INCLUDE_THRESHOLD)) + review_threshold = float(os.getenv("CHART_SELECTOR_REVIEW_THRESHOLD", DEFAULT_REVIEW_THRESHOLD)) + + # Compute paths + if args.prd_features_path: + prd_features_path = args.prd_features_path + else: + prd_features_path = Path(f".rhoai-qs/{args.slug}/.qs-factory/pipeline/prd-features.yaml") + + charts_json_path = Path(CHARTS_JSON_PATH) + + # Load inputs + prd_data = load_prd_features(prd_features_path) + chart_capabilities = load_chart_capabilities(charts_json_path) + + # Build input context + input_context = build_input_context( + prd_data["input_features"], + prd_data["deployment_questions"], + chart_capabilities + ) + + # Get predicate questions + questions = get_predicate_questions() + + # Call Decision API + client = OpenAI() + decision = call_decision_api(client, input_context, questions) + + if args.debug: + print_chart_probabilities(decision.answers, questions) + + # Process answers + selected_charts, uncertain_charts = process_answers( + decision.answers, + include_threshold, + review_threshold + ) + + # Output JSON + output = { + "selected": selected_charts, + "uncertain": uncertain_charts + } + print(json.dumps(output, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/core/skills/rh-qs-architect/subagents/chart-selector-prompt.md b/core/skills/rh-qs-architect/subagents/chart-selector-prompt.md index 37a4370..aed7286 100644 --- a/core/skills/rh-qs-architect/subagents/chart-selector-prompt.md +++ b/core/skills/rh-qs-architect/subagents/chart-selector-prompt.md @@ -16,11 +16,14 @@ This is a **capability-matching task**. For each chart, understand what it provi - `{input_features}`: the 5-key feature object (`components`, `tech_stack`, `ai_pattern`, `platform`, `data_layer`) - `{deployment_questions}`: list of how-to deployment questions from the extractor - `{slug}`: the quickstart slug — the PRD lives at `.rhoai-qs/{slug}/.qs-factory/prds/prd.md` (fallback if features don't provide enough context) -- `{charts_reference_path}`: path to `references/ai-architecture-charts.md` +- `{charts_reference_path}`: path to `references/ai-architecture-charts.json` ### Step 1: Read the charts reference -Read the file at `{charts_reference_path}`. It describes each available chart's purpose and key capabilities. Note the Helm directory name in backticks next to each chart title — that is the value for `charts[].name`. +Read the file at `{charts_reference_path}`. It contains a JSON object where each key is a chart name (the Helm directory name) with: +- `description`: one-line overview of what the chart provides +- `provides`: array of specific capabilities +- `use_when`: guidance on when to use this chart ### Step 2: Match by capability @@ -33,6 +36,8 @@ For **each** chart in the reference: When two charts cover the same primary role, follow the reference's guidance on which to use. Treat `deployment_questions` as signal for deployment/wiring needs, not automatic includes. +**If the reference lacks detail for a specific chart**, consult the source repository: https://github.com/rh-ai-quickstart/ai-architecture-charts + ### Step 3: Resolve ambiguous matches If capability fit is borderline, read the PRD at `.rhoai-qs/{slug}/.qs-factory/prds/prd.md` for additional context. Only read the PRD when the features and deployment questions do not provide enough signal.