[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"app-docs-nav-sai":3,"app-docs-sai":23,"mdc-9y5675-key":27},{"code":4,"message":5,"data":6},200,"success",{"appname":7,"title":8,"navigation":9},"sai","SAI知识库助手",[10],{"title":11,"icon":12,"children":13},"使用文档","i-lucide-rocket",[14,17,20],{"title":15,"path":16},"安装说明","/docs/sai@26",{"title":18,"path":19},"非阻塞模式","/docs/sai@27",{"title":21,"path":22},"免费大模型","/docs/sai@28",{"code":4,"message":5,"data":24},{"title":15,"description":25,"body":26},null,"## 介绍\n\n基于 `saiadmin` 开发的AI助手\n\n## 支持版本\n\n`saiadmin6.x`\n\n## 安装\n\n直接在插件市场下载压缩包并安装\n\n## 配置\n\n知识库数据向量化，需要用到 `队列处理` ，我们使用的是官方的 `webman/redis-queue` 组件，需要手动配置一下\n\n找到 `server\\config\\plugin\\webman\\redis-queue\\process.php` ， 加入以下配置\n\n```php\n\u003C?php\nreturn [\n    'consumer'  => [\n        'handler'     => Webman\\RedisQueue\\Process\\Consumer::class,\n        'count'       => 8, // 可以设置多进程同时消费\n        'constructor' => [\n            // 消费者类目录\n            'consumer_dir' => app_path() . '/queue/redis',\n            'consumer_dir' => base_path() . '/plugin/sai/queue/redis', // SAI 插件配置的队列\n        ]\n    ]\n];\n```\n\n知识库支持 `本地` 和 `PostgreSQL` 两种方式, 默认使用 Eloquent ORM\n\n1、 本地非常简单，只需要在配置的时候加入一个目录，目录保存到本地 `runtime` 下\n\n2、 PGSQL配置\n\n找到 `server\\config\\database.php` , 加入 `pgsql` 配置\n\n```php\n\u003C?php\n'pgsql' => [\n    'driver' => 'pgsql',\n    'host' => '127.0.0.1',\n    'port' => 5432,\n    'database' => 'postgres',\n    'username' => 'postgres',\n    'password' => 'postgres',\n    'charset' => 'utf8',\n    'prefix' => '',\n    'schema' => 'public',\n    'sslmode' => 'prefer',\n    'pool' => [ // 连接池配置，仅支持swoole/swow驱动\n        'max_connections' => 5, // 最大连接数\n        'min_connections' => 1, // 最小连接数\n        'wait_timeout' => 3,    // 从连接池获取连接等待的最大时间，超时后会抛出异常\n        'idle_timeout' => 60,   // 连接池中连接最大空闲时间，超时后会关闭回收，直到连接数为min_connections\n        'heartbeat_interval' => 50, // 连接池心跳检测时间，单位秒，建议小于60秒\n    ],\n]\n```\n\n\n向量处理过程中，系统会自动创建表\n```\nCREATE TABLE document_chunks (\n    id BIGSERIAL PRIMARY KEY,\n    document_id INTEGER NOT NULL,\n    knowledge_id INTEGER NOT NULL,\n    content TEXT NOT NULL,\n    embedding vector({$this->vectorDimension}),\n    metadata JSONB DEFAULT '{}',\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n)\n```",{"data":28,"body":29},{},{"type":30,"children":31},"root",[32,40,55,60,69,74,79,84,105,118,131,152,165,170,190,198,203,213],{"type":33,"tag":34,"props":35,"children":37},"element","h2",{"id":36},"介绍",[38],{"type":39,"value":36},"text",{"type":33,"tag":41,"props":42,"children":43},"p",{},[44,46,53],{"type":39,"value":45},"基于 ",{"type":33,"tag":47,"props":48,"children":50},"code",{"className":49},[],[51],{"type":39,"value":52},"saiadmin",{"type":39,"value":54}," 开发的AI助手",{"type":33,"tag":34,"props":56,"children":58},{"id":57},"支持版本",[59],{"type":39,"value":57},{"type":33,"tag":41,"props":61,"children":62},{},[63],{"type":33,"tag":47,"props":64,"children":66},{"className":65},[],[67],{"type":39,"value":68},"saiadmin6.x",{"type":33,"tag":34,"props":70,"children":72},{"id":71},"安装",[73],{"type":39,"value":71},{"type":33,"tag":41,"props":75,"children":76},{},[77],{"type":39,"value":78},"直接在插件市场下载压缩包并安装",{"type":33,"tag":34,"props":80,"children":82},{"id":81},"配置",[83],{"type":39,"value":81},{"type":33,"tag":41,"props":85,"children":86},{},[87,89,95,97,103],{"type":39,"value":88},"知识库数据向量化，需要用到 ",{"type":33,"tag":47,"props":90,"children":92},{"className":91},[],[93],{"type":39,"value":94},"队列处理",{"type":39,"value":96}," ，我们使用的是官方的 ",{"type":33,"tag":47,"props":98,"children":100},{"className":99},[],[101],{"type":39,"value":102},"webman/redis-queue",{"type":39,"value":104}," 组件，需要手动配置一下",{"type":33,"tag":41,"props":106,"children":107},{},[108,110,116],{"type":39,"value":109},"找到 ",{"type":33,"tag":47,"props":111,"children":113},{"className":112},[],[114],{"type":39,"value":115},"server\\config\\plugin\\webman\\redis-queue\\process.php",{"type":39,"value":117}," ， 加入以下配置",{"type":33,"tag":119,"props":120,"children":126},"pre",{"className":121,"code":122,"language":123,"meta":124,"style":125},"language-php","\u003C?php\nreturn [\n    'consumer'  => [\n        'handler'     => Webman\\RedisQueue\\Process\\Consumer::class,\n        'count'       => 8, // 可以设置多进程同时消费\n        'constructor' => [\n            // 消费者类目录\n            'consumer_dir' => app_path() . '/queue/redis',\n            'consumer_dir' => base_path() . '/plugin/sai/queue/redis', // SAI 插件配置的队列\n        ]\n    ]\n];\n","php","","undefined",[127],{"type":33,"tag":47,"props":128,"children":129},{"__ignoreMap":124},[130],{"type":39,"value":122},{"type":33,"tag":41,"props":132,"children":133},{},[134,136,142,144,150],{"type":39,"value":135},"知识库支持 ",{"type":33,"tag":47,"props":137,"children":139},{"className":138},[],[140],{"type":39,"value":141},"本地",{"type":39,"value":143}," 和 ",{"type":33,"tag":47,"props":145,"children":147},{"className":146},[],[148],{"type":39,"value":149},"PostgreSQL",{"type":39,"value":151}," 两种方式, 默认使用 Eloquent ORM",{"type":33,"tag":41,"props":153,"children":154},{},[155,157,163],{"type":39,"value":156},"1、 本地非常简单，只需要在配置的时候加入一个目录，目录保存到本地 ",{"type":33,"tag":47,"props":158,"children":160},{"className":159},[],[161],{"type":39,"value":162},"runtime",{"type":39,"value":164}," 下",{"type":33,"tag":41,"props":166,"children":167},{},[168],{"type":39,"value":169},"2、 PGSQL配置",{"type":33,"tag":41,"props":171,"children":172},{},[173,174,180,182,188],{"type":39,"value":109},{"type":33,"tag":47,"props":175,"children":177},{"className":176},[],[178],{"type":39,"value":179},"server\\config\\database.php",{"type":39,"value":181}," , 加入 ",{"type":33,"tag":47,"props":183,"children":185},{"className":184},[],[186],{"type":39,"value":187},"pgsql",{"type":39,"value":189}," 配置",{"type":33,"tag":119,"props":191,"children":193},{"className":121,"code":192,"language":123,"meta":124,"style":125},"\u003C?php\n'pgsql' => [\n    'driver' => 'pgsql',\n    'host' => '127.0.0.1',\n    'port' => 5432,\n    'database' => 'postgres',\n    'username' => 'postgres',\n    'password' => 'postgres',\n    'charset' => 'utf8',\n    'prefix' => '',\n    'schema' => 'public',\n    'sslmode' => 'prefer',\n    'pool' => [ // 连接池配置，仅支持swoole/swow驱动\n        'max_connections' => 5, // 最大连接数\n        'min_connections' => 1, // 最小连接数\n        'wait_timeout' => 3,    // 从连接池获取连接等待的最大时间，超时后会抛出异常\n        'idle_timeout' => 60,   // 连接池中连接最大空闲时间，超时后会关闭回收，直到连接数为min_connections\n        'heartbeat_interval' => 50, // 连接池心跳检测时间，单位秒，建议小于60秒\n    ],\n]\n",[194],{"type":33,"tag":47,"props":195,"children":196},{"__ignoreMap":124},[197],{"type":39,"value":192},{"type":33,"tag":41,"props":199,"children":200},{},[201],{"type":39,"value":202},"向量处理过程中，系统会自动创建表",{"type":33,"tag":119,"props":204,"children":208},{"className":205,"code":207,"language":39},[206],"language-text","CREATE TABLE document_chunks (\n    id BIGSERIAL PRIMARY KEY,\n    document_id INTEGER NOT NULL,\n    knowledge_id INTEGER NOT NULL,\n    content TEXT NOT NULL,\n    embedding vector({$this->vectorDimension}),\n    metadata JSONB DEFAULT '{}',\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n)\n",[209],{"type":33,"tag":47,"props":210,"children":211},{"__ignoreMap":124},[212],{"type":39,"value":207},{"type":33,"tag":214,"props":215,"children":216},"style",{},[217],{"type":39,"value":124}]