118 lines
4.8 KiB
PHP
118 lines
4.8 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace Database\Seeders;
|
||
|
||
use App\Enums\EntityStatus;
|
||
use App\Enums\SourceLevel;
|
||
use App\Models\AiModel;
|
||
use App\Models\Article;
|
||
use App\Models\Category;
|
||
use App\Models\Guide;
|
||
use App\Models\Source;
|
||
use App\Models\Tool;
|
||
use App\Services\ModelScoringService;
|
||
use Illuminate\Database\Seeder;
|
||
use Illuminate\Support\Str;
|
||
|
||
class DatabaseSeeder extends Seeder
|
||
{
|
||
public function run(): void
|
||
{
|
||
$categories = collect([
|
||
['type' => 'tool', 'name' => '写作与办公', 'slug' => 'writing-office'],
|
||
['type' => 'tool', 'name' => '图像与设计', 'slug' => 'image-design'],
|
||
['type' => 'model', 'name' => '大语言模型', 'slug' => 'llm'],
|
||
['type' => 'model', 'name' => '多模态模型', 'slug' => 'multimodal'],
|
||
['type' => 'news', 'name' => '行业动态', 'slug' => 'industry-news'],
|
||
['type' => 'guide', 'name' => '新手入门', 'slug' => 'beginner-guide'],
|
||
])->map(fn (array $payload) => Category::query()->updateOrCreate(['slug' => $payload['slug']], $payload));
|
||
|
||
$source = Source::query()->updateOrCreate(
|
||
['domain' => 'openai.com'],
|
||
[
|
||
'name' => 'OpenAI',
|
||
'type' => 'official',
|
||
'trust_level' => SourceLevel::Official,
|
||
'is_whitelisted' => true,
|
||
'crawl_allowed' => false,
|
||
],
|
||
);
|
||
|
||
$tool = Tool::query()->updateOrCreate(
|
||
['slug' => 'chat-assistant-pro'],
|
||
[
|
||
'category_id' => $categories->firstWhere('slug', 'writing-office')?->id,
|
||
'source_id' => $source->id,
|
||
'name' => 'Chat Assistant Pro',
|
||
'summary' => '用于写作、表格处理和知识问答的AI助手。',
|
||
'description' => '支持文案生成、会议纪要整理和多语言翻译。',
|
||
'pricing_type' => 'freemium',
|
||
'platform' => 'web',
|
||
'language' => 'zh-CN/en-US',
|
||
'has_api' => true,
|
||
'source_level' => SourceLevel::Official,
|
||
'status' => EntityStatus::Published,
|
||
'published_at' => now()->subDays(7),
|
||
'last_verified_at' => now()->subDays(1),
|
||
],
|
||
);
|
||
|
||
$model = AiModel::query()->updateOrCreate(
|
||
['slug' => 'omni-text-1'],
|
||
[
|
||
'category_id' => $categories->firstWhere('slug', 'llm')?->id,
|
||
'source_id' => $source->id,
|
||
'name' => 'Omni Text 1',
|
||
'provider' => 'OpenAI',
|
||
'summary' => '高质量通用文本生成模型,适合内容生产与客服场景。',
|
||
'description' => '可用于摘要、问答、分类、结构化抽取。',
|
||
'modality' => 'text',
|
||
'deployment_mode' => 'api',
|
||
'effectiveness_score' => 90,
|
||
'price_score' => 72,
|
||
'speed_score' => 80,
|
||
'status' => EntityStatus::Published,
|
||
'published_at' => now()->subDays(6),
|
||
'last_verified_at' => now()->subDays(1),
|
||
'source_level' => SourceLevel::Official,
|
||
],
|
||
);
|
||
|
||
$modelScoringService = app(ModelScoringService::class);
|
||
$modelScoringService->apply($model);
|
||
$model->save();
|
||
|
||
Article::query()->updateOrCreate(
|
||
['slug' => 'ai-product-weekly-sample'],
|
||
[
|
||
'category_id' => $categories->firstWhere('slug', 'industry-news')?->id,
|
||
'source_id' => $source->id,
|
||
'title' => 'AI产品周报示例:本周模型与工具更新',
|
||
'excerpt' => '汇总本周AI模型升级、工具发布与重要行业动向。',
|
||
'body' => Str::repeat('这是资讯示例内容,用于演示发布流程与SEO模板。', 20),
|
||
'source_name' => 'OpenAI',
|
||
'source_url' => 'https://openai.com',
|
||
'source_level' => SourceLevel::Official,
|
||
'status' => EntityStatus::Published,
|
||
'published_at' => now()->subDays(5),
|
||
'last_verified_at' => now()->subDays(1),
|
||
],
|
||
);
|
||
|
||
Guide::query()->updateOrCreate(
|
||
['slug' => 'first-ai-workflow'],
|
||
[
|
||
'category_id' => $categories->firstWhere('slug', 'beginner-guide')?->id,
|
||
'title' => '第一套AI工作流:从需求到输出',
|
||
'excerpt' => '给跨界学习者的AI工作流入门教程。',
|
||
'body' => Str::repeat('这是教程示例内容,覆盖提示词、质量校验和结果复用。', 25),
|
||
'difficulty' => 'beginner',
|
||
'status' => EntityStatus::Published,
|
||
'published_at' => now()->subDays(4),
|
||
],
|
||
);
|
||
}
|
||
}
|