feat: terraform prompt generator, provider parameter matrix, and model penalties

- Add Terraform Prompt Generator: AI-powered structured prompt generation
  with dedicated chat UI, curated model selection (7 models), conversation
  history with persistent sessions, and OCI TF resource reference context
- Provider parameter matrix: segment API params per model/provider,
  explicitly null unsupported params (freq/pres penalty, temperature)
  to prevent OCI SDK serialization errors
- Add penalties flag to model catalog: only GPT-4.1/4.1-mini/4o support
  frequency_penalty and presence_penalty
- Flat workspace enforcement: prohibit module blocks and duplicate
  variable declarations in Terraform system prompt
- Prompt Generator history: sidebar panel with session persistence,
  restore, rename/delete (agent_type tf-prompt)
This commit is contained in:
nogueiraguh
2026-03-11 13:55:59 -03:00
parent ab38e93516
commit 58d430c904
3 changed files with 355 additions and 65 deletions

View File

@@ -9,7 +9,7 @@
</p>
<p align="center">
<img src="https://img.shields.io/badge/version-2.3-C74634?style=flat-square" alt="Version">
<img src="https://img.shields.io/badge/version-2.4-C74634?style=flat-square" alt="Version">
<img src="https://img.shields.io/badge/python-3.12-3776AB?style=flat-square" alt="Python">
<img src="https://img.shields.io/badge/FastAPI-0.115-009688?style=flat-square" alt="FastAPI">
<img src="https://img.shields.io/badge/OCI-GenAI-C74634?style=flat-square" alt="OCI">
@@ -41,7 +41,8 @@ The platform combines security compliance scanning, AI-powered chat with **RAG (
- 15 chat models + 3 embedding models across 5 providers: **Meta** (Llama 4), **Google** (Gemini 2.5), **OpenAI** (GPT-5.2/5.1/5 Mini/4.1/4o, o3/o4-mini), **xAI** (Grok 4/3)
- OCID-based model resolution: catalog maps model IDs to OCI resource IDs per region for reliable API calls
- 16 OCI regions supported with auto-generated endpoints
- Full parameter control: temperature, max_tokens, top_p, top_k, frequency/presence penalty
- **Provider parameter matrix**: automatic parameter segmentation per model — reasoning models (o3/o4-mini) only get `max_completion_tokens` + `reasoning_effort`, OpenAI GPT-4.x gets freq/pres penalties, Google/Meta get `top_k`, xAI gets basic params. Unsupported parameters are explicitly nulled to prevent SDK serialization errors
- Full parameter control: temperature, max_tokens, top_p, top_k, frequency/presence penalty (when supported by model)
- Toggle MCP tools on/off per chat session
- Conversation history with session management
- On-Demand and Dedicated serving modes
@@ -71,6 +72,18 @@ The platform combines security compliance scanning, AI-powered chat with **RAG (
- **Multi-region provider management**: auto-detects provider aliases and region variables in generated code, generates `provider.tf` with credentials and correct region references (`var.region` instead of hardcoded values)
- **System prompt sync**: Terraform system prompt in code is automatically synced to DB on every restart — single source of truth
- Compact system prompt optimized for OCI Terraform provider best practices (100K max_tokens)
- **Flat workspace enforcement**: system prompt prohibits `module` blocks (workspace has no subdirectories) and enforces single-file variable declarations (`variables.tf` only)
### 📝 Terraform Prompt Generator
- **AI-powered prompt generation** for OCI infrastructure — generates structured, optimized prompts to feed into the Terraform Agent
- Dedicated chat interface (sub-menu under Terraform) matching Terraform Agent layout
- **Curated model selection**: only 7 recommended models (GPT-4.1, o3, o4-mini, GPT-5.1, GPT-5.2, Gemini 2.5 Pro, Gemini 2.5 Flash), grouped by provider
- **OCI Terraform Resource Reference**: prompt generation includes the full OCI provider resource catalog as context, ensuring accurate resource names and attributes
- **Conversation history**: persistent sessions (agent_type `tf-prompt`) with sidebar history panel, rename/delete, session restore
- **Contextual follow-up**: conversation history sent to GenAI for iterative prompt refinement
- **Copy & Send**: action buttons on assistant messages to copy the prompt or send directly to the Terraform Agent input
- Robust system prompt with OCI Provider constraints, inference rules, architecture templates, and workspace restrictions
- Example prompts as clickable buttons for quick start
### ⚡ OCI Resource Actions
- **Start/Stop Compute Instances** directly from OCI Account Explorer with one click
@@ -396,14 +409,14 @@ Allow group <group-name> to read buckets in compartment <compartment-name>
```
oci-cis-agent/
├── backend/
│ ├── app.py # FastAPI application (~5300 lines)
│ ├── app.py # FastAPI application (~5500 lines)
│ ├── cis_reports.py # Oracle CIS Benchmark checker (6660 lines, report engine)
│ ├── mcp_cis_server.py # MCP server with 12 granular CIS tools (~700 lines)
│ ├── gen_tf_reference.py # OCI Terraform provider resource catalog generator
│ ├── Dockerfile # Python 3.12 + OCI CLI + Terraform CLI
│ └── requirements.txt # Dependencies
├── frontend/
│ └── index.html # SPA with Oracle Dark Premium theme (~2820 lines)
│ └── index.html # SPA with Oracle Dark Premium theme (~2950 lines)
├── nginx/
│ └── default.conf # Reverse proxy config
├── docker-compose.yml # Orchestration
@@ -560,6 +573,7 @@ oci-cis-agent/
| POST | `/api/terraform/workspaces/{wid}/cancel` | Cancel running Terraform operation |
| DELETE | `/api/terraform/workspaces/{wid}` | Delete workspace |
| POST | `/api/terraform/refresh-reference` | Regenerate OCI Terraform resource reference (UI button) |
| POST | `/api/terraform/generate-prompt` | Generate structured Terraform prompt via AI (Prompt Generator) |
### Chat & Reports