feat: 删除 知识库-终端 关联, 简化 prompt 配置

This commit is contained in:
2026-03-23 15:27:06 +08:00
parent 81a22a2b54
commit 89af7c17f1
23 changed files with 102 additions and 1633 deletions

View File

@@ -6,34 +6,26 @@ use App\Http\Controllers\Controller;
use App\Models\Guide;
use App\Models\GuidePage;
use App\Services\KnowledgeContextService;
use App\Services\PromptTemplateService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TerminalApiController extends Controller
{
public function __construct(
private PromptTemplateService $promptService,
private KnowledgeContextService $knowledgeService,
) {}
/**
* GET /api/terminal/config
* 返回终端配置含渲染后的system prompt
* 返回终端配置
*/
public function config(Request $request): JsonResponse
{
$terminal = $request->attributes->get('terminal');
$terminal->load(['prompt', 'knowledgeBases']);
$terminal->load('prompt');
// 渲染system prompt
$systemPrompt = '';
if ($terminal->prompt && $terminal->prompt->prompt_template) {
$systemPrompt = $this->promptService->replaceVariables(
$terminal->prompt->prompt_template,
$terminal
);
}
// 返回原始提示词模板占位符由HMI端替换
$systemPrompt = $terminal->prompt?->prompt_template ?? '';
// 获取终端关联的已发布指引数量
$guideCount = $terminal->guides()->published()->count();
@@ -56,7 +48,7 @@ class TerminalApiController extends Controller
}
/**
* GET /api/terminal/knowledge?query=xxx
* GET /api/knowledge?query=xxx
* RAG知识搜索由AI tool_call触发
*/
public function knowledge(Request $request): JsonResponse
@@ -65,10 +57,7 @@ class TerminalApiController extends Controller
'query' => 'required|string|max:500',
]);
$terminal = $request->attributes->get('terminal');
$terminal->load('knowledgeBases');
$result = $this->knowledgeService->search($terminal, $request->input('query'));
$result = $this->knowledgeService->search($request->input('query'));
return response()->json($result);
}