app/Services/QuestionServiceApi.php
app/Filament/Resources/QuestionResource.php
app/Filament/Resources/QuestionResource/Pages/ListQuestions.php
app/Filament/Resources/QuestionResource/Pages/ViewQuestion.php
app/Filament/Resources/QuestionResource/Pages/CreateQuestion.php
config/question_bank.php
routes/api.php
编辑 .env 文件:
QUESTION_BANK_API_BASE=http://localhost:5015
# 启动知识图谱服务
cd /Volumes/T9/code/math/apis/KnowledgeServic
docker compose up -d
# 启动题库服务
cd /Volumes/T9/code/math/apis/QuestionBankService
docker compose up -d
# 启动 Laravel 后台
cd /Volumes/T9/code/math/apis/FilamentAdmin
herd serve
URL: http://filament-admin.test/admin
在题目列表页,点击 "AI 生成题目" 按钮:
在题目列表页,点击 "智能搜索":
use App\Services\QuestionServiceApi;
$service = app(QuestionServiceApi::class);
// 获取题目列表
$questions = $service->listQuestions(1, 25, ['kp_code' => 'KP1001']);
// 搜索题目
$results = $service->searchQuestions('因式分解计算', 20);
// 生成题目
$result = $service->generateQuestions([
'kp_code' => 'KP1001',
'keyword' => '因式分解',
'count' => 10,
'strategy' => 'auto',
]);
{
"data": [
{
"id": 1,
"question_code": "KP1001-AI-ABC123",
"kp_code": "KP1001",
"stem": "因式分解题目内容",
"answer": "标准答案",
"solution": "详细解析",
"difficulty": 0.6,
"source": "ai::deepseek",
"tags": "整数因数分解,提公因式策略",
"created_at": "2025-11-15T10:00:00"
}
],
"meta": {
"page": 1,
"per_page": 25,
"total": 100,
"total_pages": 4
}
}
Laravel 后台 (Herd)
↓ HTTP API 调用
题库服务 (localhost:5015)
↓ 数据查询
PostgreSQL + pgvector (localhost:5442)
↓ AI 调用
DeepSeek/Kimi API
症状:页面显示空白或错误信息
解决方案:
# 检查题库服务状态
curl http://localhost:5015/health
# 检查 Laravel 日志
tail -f storage/logs/laravel.log
# 检查 API 配置
cat .env | grep QUESTION_BANK_API_BASE
症状:数据不更新
解决方案:
# 清理 Laravel 缓存
php artisan cache:clear
php artisan config:clear
php artisan route:clear
# 手动刷新缓存(API 层)
# 修改 QuestionServiceApi 中的 cacheTtl 设置
症状:AI 生成功能报错
解决方案:
# 检查 AI API Key 配置
docker compose exec question_bank_api env | grep API_KEY
# 使用 dry_run 模式测试
python scripts/seed_ai_questions.py --keyword "因式分解" --count 5 --dry-run
题库系统
├── 题库管理
└── 知识点管理
更新日期:2025-11-15 版本:v1.0 维护者:Claude Code