ai-robot-core/ai-service
MerCry 4de51bb18a [AC-AISVC-RES-01~15] test(retrieval): 新增策略路由单元测试
- 新增 test_routing_config.py 路由配置测试
  - TestStrategyType: 策略类型枚举测试
  - TestRagRuntimeMode: 运行模式枚举测试
  - TestRoutingConfig: 路由配置测试
  - TestStrategyContext: 策略上下文测试
  - TestStrategyResult: 策略结果测试

- 新增 test_strategy_router.py 策略路由器测试
  - TestRollbackRecord: 回滚记录测试
  - TestRollbackManager: 回滚管理器测试
  - TestDefaultPipeline: 默认管道测试
  - TestEnhancedPipeline: 增强管道测试
  - TestStrategyRouter: 策略路由器测试

- 新增 test_mode_router.py 模式路由器测试
  - TestComplexityAnalyzer: 复杂度分析器测试
  - TestModeRouteResult: 模式路由结果测试
  - TestModeRouter: 模式路由器测试
- 新增 test_strategy_integration.py 集成层测试
  - TestRetrievalStrategyResult: 集成结果测试
  - TestRetrievalStrategyIntegration: 集成器测试

- 79 个测试用例全部通过
2026-03-10 21:08:49 +08:00
..
app [AC-AISVC-RES-01~15] feat(api): 新增策略管理 API端点 2026-03-10 21:08:07 +08:00
docs/progress feat(v0.7.0): 验收通过 - Dashboard统计增强、流程测试、对话追踪 2026-02-28 12:52:50 +08:00
exports feat(v0.7.0): 验收通过 - Dashboard统计增强、流程测试、对话追踪 2026-02-28 12:52:50 +08:00
migrations test: add unit tests and utility scripts for intent routing, slot management, and KB search [AC-TEST] 2026-03-10 12:10:22 +08:00
scripts test: add unit tests and utility scripts for intent routing, slot management, and KB search [AC-TEST] 2026-03-10 12:10:22 +08:00
tests [AC-AISVC-RES-01~15] test(retrieval): 新增策略路由单元测试 2026-03-10 21:08:49 +08:00
tools chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00
.dockerignore feat: 添加Docker容器部署配置 [AC-AISVC-01] 2026-02-26 01:22:30 +08:00
Dockerfile fix: Docker构建时复制README.md文件 [AC-AISVC-01] 2026-02-26 02:13:26 +08:00
README.md feat(AISVC-T7): 嵌入模型可插拔设计与文档解析支持 [AC-AISVC-29, AC-AISVC-30, AC-AISVC-31, AC-AISVC-32, AC-AISVC-33, AC-AISVC-34, AC-AISVC-35, AC-AISVC-36, AC-AISVC-37, AC-AISVC-38, AC-AISVC-39, AC-AISVC-40, AC-AISVC-41] 2026-02-24 23:08:08 +08:00
check_kb_collections.py chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00
check_qdrant.py chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00
pyproject.toml feat(v0.7.0): 验收通过 - Dashboard统计增强、流程测试、对话追踪 2026-02-28 12:52:50 +08:00
test_kb_metadata_search.py chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00
test_kb_search_with_metadata.py chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00
test_metadata_filter_only.py chore: add utility scripts and tool definitions for KB search and metadata testing [AC-UTILS] 2026-03-10 12:11:55 +08:00

README.md

AI Service

Python AI Service for intelligent chat with RAG support.

Features

  • Multi-tenant isolation via X-Tenant-Id header
  • SSE streaming support via Accept: text/event-stream
  • RAG-powered responses with confidence scoring

Prerequisites

  • PostgreSQL 12+
  • Qdrant vector database
  • Python 3.10+

Installation

pip install -e ".[dev]"

Database Initialization

# Create database and tables
python scripts/init_db.py --create-db

# Or just create tables (database must exist)
python scripts/init_db.py

Option 2: Using SQL script

# Connect to PostgreSQL and run
psql -U postgres -f scripts/init_db.sql

Configuration

Create a .env file in the project root:

AI_SERVICE_DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/ai_service
AI_SERVICE_QDRANT_URL=http://localhost:6333
AI_SERVICE_LLM_API_KEY=your-api-key
AI_SERVICE_LLM_BASE_URL=https://api.openai.com/v1
AI_SERVICE_LLM_MODEL=gpt-4o-mini
AI_SERVICE_DEBUG=true

Running

uvicorn app.main:app --host 0.0.0.0 --port 8000

API Endpoints

Chat API

  • POST /ai/chat - Generate AI reply (supports SSE streaming)
  • GET /ai/health - Health check

Admin API

  • GET /admin/kb/documents - List documents
  • POST /admin/kb/documents - Upload document
  • GET /admin/kb/index/jobs/{jobId} - Get indexing job status
  • DELETE /admin/kb/documents/{docId} - Delete document
  • POST /admin/rag/experiments/run - Run RAG experiment
  • GET /admin/sessions - List chat sessions
  • GET /admin/sessions/{sessionId} - Get session details