ai-robot-core/ai-service
MerCry b3680bda8a [AC-LLM-MULTI] feat(llm): 实现 LLM 多用途配置功能
- 新增 LLMUsageType 枚举支持 chat 和 kb_processing 两种用途
- 扩展 LLMConfig 支持按用途类型存储不同配置
- 更新 LLMClient 接口支持 Any 类型的消息内容
- 新增管理后台 API 支持获取用途类型列表和按用途获取配置
- 更新前端 LLM 配置页面支持多用途配置切换
2026-03-11 18:56:01 +08:00
..
app [AC-LLM-MULTI] feat(llm): 实现 LLM 多用途配置功能 2026-03-11 18:56:01 +08:00
docs/progress [AC-AISVC-RES-01~15] docs(progress): 新增策略路由进度文档 2026-03-10 21:09:23 +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