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

@@ -131,44 +131,6 @@ class TerminalResource extends Resource
->columns(2)
->description('配置终端的语音唤醒能力'),
Forms\Components\Section::make('知识库关联')
->schema([
Forms\Components\Repeater::make('knowledgeBaseAssociations')
->label('关联知识库')
->relationship('knowledgeBases')
->schema([
Forms\Components\Select::make('id')
->label('知识库')
->options(\App\Models\KnowledgeBase::where('status', 'active')->pluck('name', 'id'))
->required()
->searchable()
->distinct()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
->helperText('选择要关联的知识库'),
Forms\Components\TextInput::make('priority')
->label('优先级')
->numeric()
->default(0)
->required()
->minValue(0)
->helperText('数字越小优先级越高0为最高优先级'),
])
->columns(2)
->reorderable()
->reorderableWithButtons()
->addActionLabel('添加知识库')
->reorderableWithDragAndDrop(false)
->itemLabel(
fn(array $state): ?string =>
\App\Models\KnowledgeBase::find($state['id'])?->name ?? '未选择'
)
->collapsed()
->collapsible()
->helperText('可以关联多个知识库,并设置优先级。拖动或使用按钮调整顺序。'),
])
->description('配置终端可以访问的知识库及其优先级'),
Forms\Components\Section::make('指引关联')
->schema([
Forms\Components\Repeater::make('guideAssociations')
@@ -215,17 +177,13 @@ class TerminalResource extends Resource
->label('提示词模板')
->language('markdown')
->fontSize('14px')
->helperText('编辑AI提示词模板支持使用变量如 {user}, {station}, {time} 等')
->helperText('编辑AI提示词模板支持使用占位符 {station_id}, {user}, {time}由HMI端替换')
->placeholderText('请输入AI提示词模板...')
->disablePreview()
->columnSpan(2),
Forms\Components\Grid::make(1)
->schema([
Forms\Components\Placeholder::make('template_selector')
->label('模板库')
->content(fn() => view('filament.components.prompt-template-selector')),
Forms\Components\Placeholder::make('variable_helper')
->label('变量参考')
->content(fn() => view('filament.components.prompt-variable-helper')),
@@ -233,7 +191,7 @@ class TerminalResource extends Resource
->columnSpan(1),
]),
])
->description('配置终端的AI提示词模板用于指导AI助手的行为')
->description('配置终端的AI提示词模板占位符由HMI端替换')
->collapsible(),
Forms\Components\Section::make('状态信息')

View File

@@ -53,23 +53,6 @@ class ViewTerminal extends ViewRecord
->openUrlInNewTab(),
]),
Infolists\Components\Section::make('知识库关联')
->schema([
Infolists\Components\RepeatableEntry::make('knowledgeBases')
->label('关联的知识库')
->schema([
Infolists\Components\TextEntry::make('name')
->label('知识库名称'),
Infolists\Components\TextEntry::make('pivot.priority')
->label('优先级')
->badge()
->color('success'),
])
->columns(2)
->placeholder('未关联任何知识库'),
])
->collapsible(),
Infolists\Components\Section::make('AI提示词配置')
->schema([
Infolists\Components\TextEntry::make('prompt.prompt_template')