feat: prompt from station
This commit is contained in:
@@ -30,6 +30,7 @@ class TerminalFactory extends Factory
|
||||
'ip_address' => fake()->localIpv4(),
|
||||
'station_id' => null,
|
||||
'diagram_urls' => [['title' => '组态', 'url' => fake()->url()]],
|
||||
'prompt_template' => null,
|
||||
'voice_wakeup_enabled' => false,
|
||||
'voice_wakeup_word' => null,
|
||||
'is_online' => fake()->boolean(70), // 70%概率在线
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('terminal_prompts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('terminal_id')->comment('终端ID');
|
||||
$table->text('prompt_template')->comment('提示词模板');
|
||||
$table->json('variables')->nullable()->comment('变量配置');
|
||||
$table->timestamps();
|
||||
|
||||
// 添加外键约束
|
||||
$table->foreign('terminal_id')
|
||||
->references('id')
|
||||
->on('terminals')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('terminal_prompts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('terminals', function (Blueprint $table) {
|
||||
$table->text('prompt_template')->nullable()->comment('AI提示词模板');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('terminals', function (Blueprint $table) {
|
||||
$table->dropColumn('prompt_template');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,6 @@ namespace Database\Seeders;
|
||||
use App\Models\KnowledgeBase;
|
||||
use App\Models\Station;
|
||||
use App\Models\Terminal;
|
||||
use App\Models\TerminalPrompt;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TerminalSeeder extends Seeder
|
||||
@@ -27,10 +26,6 @@ class TerminalSeeder extends Seeder
|
||||
'BL16U1' => '192.168.1.39',
|
||||
];
|
||||
|
||||
$defaultPrompt = <<<'PROMPT'
|
||||
你是{station_name}光束线的AI助手(终端: {terminal_name} / {terminal_code})。当前时间是{time}。请根据用户{user}的问题,提供准确的光束线操作指导、实验支持和技术咨询。你可以回答关于光束线参数、实验流程、设备状态、安全规范等方面的问题。
|
||||
PROMPT;
|
||||
|
||||
// 创建通用知识库(全局,不关联线站)
|
||||
$this->command->info('创建通用知识库...');
|
||||
KnowledgeBase::create(['name' => '通用知识库', 'description' => '全站通用的规章制度和管理文档', 'status' => 'active']);
|
||||
@@ -53,6 +48,7 @@ PROMPT;
|
||||
'code' => "SCREEN-{$beamline}",
|
||||
'ip_address' => $ipAddress,
|
||||
'station_id' => $station->id,
|
||||
'prompt_template' => "你是{$beamline}光束线的AI助手(终端: {terminal_name} / {terminal_code})。当前时间是{time}。请根据用户{user}的问题,提供准确的光束线操作指导、实验支持和技术咨询。",
|
||||
'diagram_urls' => [
|
||||
['title' => 'BL16U1', 'url' => 'https://ssrf.9z.work/scada/BL16U1.svg'],
|
||||
['title' => 'BL16U1前端布局图', 'url' => 'https://ssrf.9z.work/scada/BL16U1-1.svg']
|
||||
@@ -62,12 +58,6 @@ PROMPT;
|
||||
? now()
|
||||
: now()->subHours(rand(1, 24)),
|
||||
]);
|
||||
|
||||
TerminalPrompt::create([
|
||||
'terminal_id' => $terminal->id,
|
||||
'prompt_template' => $defaultPrompt,
|
||||
'variables' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
$this->command->info('线站/知识库/终端创建完成!');
|
||||
|
||||
Reference in New Issue
Block a user