μμ€ν ν둬ννΈμ λν μ€μλλ₯Ό λΆμνλ RAG κΈ°λ° μ±λ΄μ λλ€. μ¬λ¬ LLM νλ‘λ°μ΄λλ₯Ό μ§μνλ©°, AI μλ΅μ΄ μ§μ λ κ°μ΄λλΌμΈμ μΌλ§λ μ λ°λ₯΄λμ§ νκ°ν©λλ€.
- λ€μν LLM νλ‘λ°μ΄λ μ§μ (Upstage Solar, OpenAI, Anthropic Claude, Google Gemini, Ollama)
- AI κΈ°λ° μλ κ°μ΄λλΌμΈ μΆμΆ
- μ€μκ° μ€μλ λΆμ λ° μ€μ½μ΄λ§
- ChromaDB κΈ°λ° RAG ν΅ν©
- μλ κ°μ΄λλΌμΈ κ΄λ¦¬
- μλ/μλ ν둬ννΈ λ²μ κ΄λ¦¬ λ° μ¬νκ° λμ보λ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β ββββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
β β System Prompt β β RAG Chatbot β β Compliance ββ
β β Editor β β Interface β β Dashboard ββ
β ββββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTP/REST API
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API Routes β β
β β /api/chat/message β β
β β /api/chat/extract-guidelines β β
β β /api/compliance/{id} β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββΌβββββββββββββββββββββββ β
β βΌ βΌ βΌ β
β βββββββββββ ββββββββββββββββ ββββββββββββ β
β β RAG β β Compliance β β LLM β β
β β Service β β Checker β β Provider β β
β βββββββββββ ββββββββββββββββ ββββββββββββ β
β β β β
β βΌ β β
β βββββββββββ β β
β βChromaDB β β β
β β Vector β β β
β β DB β β β
β βββββββββββ β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββ
β
βββββββββββββββββββββββββββββββββΌββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Upstage Solar β β OpenAI β β Anthropic β
β (Default) β β β β Claude β
βββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββ ββββββββββββββββ
β Ollama β βGoogle Gemini β
β β β β
βββββββββββββββββ ββββββββββββββββ
- React with TypeScript
- Vite for fast development
- Recharts for compliance visualization
- Axios for API communication
- FastAPI for high-performance REST API
- ChromaDB for vector storage and RAG
- SQLite (
backend/data/app.db) for prompt/evaluation persistence - Sentence Transformers for embeddings
- Pydantic for data validation
- Multiple LLM Providers:
- Upstage Solar API
- OpenAI API
- Anthropic Claude API
- Google Gemini API
- Ollama (local)
- Python 3.11+
- Node.js 18+
- npm
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the backend directory:
# LLM Provider (ollama, openai, upstage, anthropic, gemini)
LLM_PROVIDER=upstage
# Ollama (if using LLM_PROVIDER=ollama)
OLLAMA_MODEL=llama3.2
OLLAMA_HOST=http://localhost:11434
# OpenAI (if using LLM_PROVIDER=openai)
OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-3.5-turbo
# Upstage Solar (if using LLM_PROVIDER=upstage)
UPSTAGE_API_KEY=your-upstage-api-key
UPSTAGE_MODEL=solar-pro2
# Anthropic (if using LLM_PROVIDER=anthropic)
ANTHROPIC_API_KEY=your-anthropic-api-key
ANTHROPIC_MODEL=claude-3-haiku-20240307
# Google Gemini (if using LLM_PROVIDER=gemini)
GOOGLE_API_KEY=your-google-api-key
GEMINI_MODEL=gemini-1.5-flash
# ChromaDB
CHROMA_DB_PATH=./data/chroma
# API
API_HOST=0.0.0.0
API_PORT=8000cd frontend
npm install./start-all.shThis will:
- Start the backend server on http://localhost:8000
- Start the frontend server on http://localhost:3000
- Automatically open your browser
- Display real-time logs
Backend:
cd backend
source venv/bin/activate
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend:
cd frontend
npm run dev-
Select LLM Provider: Choose your preferred LLM from the dropdown (Upstage, OpenAI, etc.)
-
Configure System Prompt:
- Enter your system prompt in the text area
- Click "LLM Guidelines Extraction" to automatically extract guidelines
- Or manually add guidelines using the "+ Add Manually" button
-
Chat with the Bot:
- Type your message in the chat interface
- The AI will respond based on your system prompt
-
View Compliance Analysis:
- See real-time compliance scoring
- Review detailed analysis for each guideline
- Check which guidelines were followed/not followed with evidence
-
Improve + Re-evaluate Prompts:
- μ°μΈ‘ ν¨λμ βμλ κ°μ + μ¬νκ°β λ²νΌμ λλ₯΄λ©΄
/api/prompts/improveκ° νΈμΆλμ΄ μλ‘μ΄ μμ€ν ν둬ννΈ λ²μ μ μμ±νκ³ , κΈ°λ³Έ μλλ¦¬μ€ 4μ’ (λΆλ² μμ² κ±°μ , κ°μΈμ 보 μμ² κ±°μ , λ§€μΆ μΈμ¬μ΄νΈ μμ½, CS λ³΄κ³ μ ν€)μ μλ μ¬νκ°ν©λλ€. - μμ±λ λ²μ κ³Ό μ¬νκ° κ²°κ³Όλ Prompt Dashboardμμ μ¦μ νμΈν μ μμ΅λλ€.
- μ°μΈ‘ ν¨λμ βμλ κ°μ + μ¬νκ°β λ²νΌμ λλ₯΄λ©΄
Once the backend is running, visit:
- API Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
POST /api/chat/message- Send a chat message and get compliance analysisPOST /api/chat/extract-guidelines- Extract guidelines from system prompt using LLMGET /api/compliance/{compliance_id}- Get detailed compliance analysisPOST /api/chat/upload-document- Upload documents to RAG knowledge base
prompt-compliance-rag/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI application entry point
β β βββ dependencies.py # Dependency injection
β β βββ models/
β β β βββ schemas.py # Pydantic models
β β βββ routes/
β β β βββ chat.py # Chat and guideline endpoints
β β β βββ compliance.py # Compliance analysis endpoints
β β βββ services/
β β βββ compliance_checker.py # Compliance analysis logic
β β βββ llm_provider.py # Multi-LLM abstraction
β β βββ rag_service.py # RAG with ChromaDB
β βββ requirements.txt
β βββ .env
βββ frontend/
β βββ src/
β β βββ App.tsx # Main application component
β β βββ components/
β β β βββ ChatInterface.tsx
β β β βββ ComplianceDashboard.tsx
β β β βββ SystemPromptEditor.tsx
β β βββ services/
β β β βββ api.ts # API client
β β βββ types/
β β βββ index.ts # TypeScript types
β βββ package.json
β βββ vite.config.ts
βββ start-all.sh # Convenience script to start all services
βββ README.md
You can switch LLM providers in two ways:
-
Environment Variable (default for all requests): Edit
backend/.envand changeLLM_PROVIDER -
Per-Request (runtime selection): Use the LLM provider dropdown in the UI
Use the /api/chat/upload-document endpoint:
curl -X POST http://localhost:8000/api/chat/upload-document \
-H "Content-Type: application/json" \
-d '{
"content": "Your document content here",
"metadata": {"source": "custom"}
}'- Version Store: λͺ¨λ ν둬ννΈ λ²μ μ SQLite(
backend/data/app.db)μ μ μ₯λλ©°,/api/prompts/historyλ‘ νμΈν μ μμ΅λλ€. - κ°μ API:
POST /api/prompts/improveμrun_reevaluation: trueλ₯Ό ν¬ν¨νλ©΄ μλλ¦¬μ€ μ 체 μλ μ¬νκ°κ° μ€νλμ΄reevaluationνλλ‘ κ²°κ³Όκ° λ°νλ©λλ€. - μλλ¦¬μ€ κ΅¬μ± (
backend/app/config/scenarios.json):- Safety refusal (λΆλ² νμ κ±°μ )
- PII refusal (κ°μΈμ 보 μμ² κ±°μ )
- Data insight summary (λ§€μΆ λ°μ΄ν° μμ½ + μμΈ λΆμ)
- Customer-service report tone (CS λ³΄κ³ μ μ΄μ/μμΈ/μ‘°μΉ)
- μλΉμ€ κΈ°λ:
./start-all.shμ€ν ν http://localhost:8000, http://localhost:3000 μ μ. - ν둬ννΈ νΈμ§: μ’μΈ‘ System Prompt Editorμμ λλ©μΈ μ§μΉ¨ μ λ ₯ β κ°μ΄λλΌμΈ μΆμΆ λ²νΌμΌλ‘ ꡬ쑰ν.
- λν/μ€μλ νμΈ: Chat ν¨λμμ λ©μμ§ μ μ‘ β μ€μλ λμ보λλ‘ μ¦μ μ€μ½μ΄ νμΈ.
- μλ κ°μ μ€ν: νλ‘¬νΈ λμ보λ 'μλ κ°μ + μ¬νκ°' λ²νΌ ν΄λ¦ λλ
curl -X POST http://localhost:8000/api/prompts/improve -H 'Content-Type: application/json' -d '{\"run_reevaluation\": true}'. - κ²°κ³Ό λΆμ: Prompt Dashboard μΉ΄λ νΉμ
GET /api/evaluation/recent?limit=6μΌλ‘ μ΅κ·Ό νκ° νμΈ. - μλλ¦¬μ€ νμ₯:
app/config/scenarios.jsonμ μΆκ° μλλ¦¬μ€ μ μ β μλ² μ¬μμ.
Copyright (c) 2026 jinsoo96. All rights reserved.