Backend (FastAPI + SQLAlchemy + Claude API + RAG): - Config management with Pydantic v2 - Database engine with connection pooling and SQL injection prevention - AI engine with Claude API integration (support custom base URL) - RAG engine with ChromaDB and sentence-transformers - Requirement analysis service - Config generation service - Executor engine with SQL validation - REST API endpoints: /analyze, /generate, /execute Frontend (Vue 3 + Element Plus + Pinia): - Complete 3-step workflow: analyze → generate → execute - Step indicator with progress visualization - Analysis result display with field table - SQL preview with monospace font - Execute confirmation dialog with safety warning - Execution result display - State management with Pinia - API service integration Security: - SQL injection prevention with parameterized queries - Dangerous SQL operation blocking - Database password URL encoding - Transaction auto-rollback - Pydantic config validation Features: - Natural language requirement analysis - Automated SQL configuration generation - Safe execution with human review - LAN access support - Custom Claude API endpoint support Documentation: - README with quick start guide - Quick start guide - LAN access configuration - Dependency fixes guide - Claude API configuration - Git operation guide - Implementation report Dependencies fixed: - numpy<2.0.0 for chromadb compatibility - sentence-transformers==2.7.0 for huggingface_hub compatibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
89 lines
2.4 KiB
Python
89 lines
2.4 KiB
Python
"""Request models for ERP AI Assistant API.
|
|
|
|
This module defines Pydantic models for API request validation.
|
|
"""
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class AnalyzeRequest(BaseModel):
|
|
"""Request model for requirement analysis.
|
|
|
|
Attributes:
|
|
input_type: Type of input - 'natural_language' or 'structured'
|
|
content: Requirement content text
|
|
session_id: Optional session ID for context continuity
|
|
"""
|
|
|
|
input_type: str = Field(
|
|
...,
|
|
description="输入类型: natural_language | structured"
|
|
)
|
|
content: str = Field(..., description="需求内容")
|
|
session_id: Optional[str] = Field(None, description="会话ID")
|
|
|
|
model_config = {
|
|
"json_schema_extra": {
|
|
"examples": [
|
|
{
|
|
"input_type": "natural_language",
|
|
"content": "创建一个销售订单管理页面",
|
|
"session_id": "session-123"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
class GenerateRequest(BaseModel):
|
|
"""Request model for config generation.
|
|
|
|
Attributes:
|
|
session_id: Session ID from previous analysis
|
|
requirements: Structured requirements from analysis
|
|
"""
|
|
|
|
session_id: str = Field(..., description="会话ID")
|
|
requirements: dict = Field(..., description="结构化需求")
|
|
|
|
model_config = {
|
|
"json_schema_extra": {
|
|
"examples": [
|
|
{
|
|
"session_id": "session-123",
|
|
"requirements": {
|
|
"功能名称": "销售订单管理",
|
|
"功能类型": "列表页面"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
|
|
class ExecuteRequest(BaseModel):
|
|
"""Request model for config execution.
|
|
|
|
Attributes:
|
|
session_id: Session ID for tracking
|
|
confirmed: User confirmation flag
|
|
backup_enabled: Whether to create backup before execution
|
|
"""
|
|
|
|
session_id: str = Field(..., description="会话ID")
|
|
confirmed: bool = Field(False, description="用户确认标识")
|
|
backup_enabled: bool = Field(True, description="是否启用备份")
|
|
|
|
model_config = {
|
|
"json_schema_extra": {
|
|
"examples": [
|
|
{
|
|
"session_id": "session-123",
|
|
"confirmed": True,
|
|
"backup_enabled": True
|
|
}
|
|
]
|
|
}
|
|
} |