文件: app/Services/KnowledgeGraphService.php
config('services.knowledge_api.base_url')文件: app/Services/QuestionBankService.php
config('services.question_bank.base_url')文件: app/Services/PromptService.php
config('services.question_bank.base_url')文件: app/Services/HttpClientService.php
Class "App\Filament\Pages\Http" not found 错误HttpClientService 进行API调用POST /generate-intelligent-questionskp_code, skills, count, prompt_templatecd /Volumes/T9/code/math/apis/FilamentAdmin
php artisan tinker --execute="
\$service = new App\Services\KnowledgeGraphService();
\$points = \$service->listKnowledgePoints(1, 5);
echo 'Knowledge Points: ' . count(\$points) . PHP_EOL;
if (!empty(\$points)) {
echo 'First KP: ' . \$points[0]['code'] . ' - ' . \$points[0]['name'] . PHP_EOL;
}
\$skills = \$service->getSkillsByKnowledgePoint('KP7001');
echo 'Skills for KP7001: ' . count(\$skills) . PHP_EOL;
"
结果:
curl -X POST http://localhost:5015/generate-intelligent-questions \
-H "Content-Type: application/json" \
-d '{"kp_code":"KP7001","skills":["SK001"],"count":2}'
结果:
{
"success": true,
"message": "成功生成2道题目",
"data": [...],
"total": 2
}
# 知识图谱API
KNOWLEDGE_API_BASE=http://localhost:5011
# 题库API
QUESTION_BANK_API_BASE=http://localhost:5015
'knowledge_api' => [
'base_url' => env('KNOWLEDGE_API_BASE', 'http://localhost:5011'),
],
'question_bank' => [
'base_url' => env('QUESTION_BANK_API_BASE', 'http://localhost:5015'),
],
// 获取知识点列表
$kgService = app(KnowledgeGraphService::class);
$points = $kgService->listKnowledgePoints(1, 100);
// 根据知识点获取技能
$skills = $kgService->getSkillsByKnowledgePoint('KP7001');
// 生成题目
$qbService = app(QuestionBankService::class);
$result = $qbService->generateIntelligentQuestions([
'kp_code' => 'KP7001',
'skills' => ['SK001'],
'count' => 100,
'prompt_template' => '...'
]);
// 保存提示词
$promptService = app(PromptService::class);
$result = $promptService->savePrompt([
'template_name' => 'AI题目生成_增强版',
'template_content' => '...',
...
]);
访问后台
http://fa.test/admin/question-management
点击生成题目
配置参数
开始生成
查看结果
app/Services/
├── HttpClientService.php # 通用HTTP客户端
├── KnowledgeGraphService.php # 知识图谱服务
├── QuestionBankService.php # 题库服务
└── PromptService.php # 提示词服务
通过这次开发:
完成时间: 2025-11-19 14:25
状态: ✅ 完成
作者: Claude Code