docs(quick-start): 添加项目初始化脚本和更新快速入门文档

添加 Bash 和 PowerShell 初始化脚本,用于自动配置环境变量和拉取 Docker 镜像
更新快速入门文档,增加两种初始化方法的说明和 API Key 获取指引
This commit is contained in:
Wenjie Zhang 2025-12-15 10:27:59 +08:00
parent ff75c2dfb3
commit eb79ad4b8e
3 changed files with 203 additions and 1 deletions

View File

@ -26,7 +26,32 @@ cd Yuxi-Know
- `main`: 最新开发版本(不稳定,新特性可能会导致新 bug
:::
#### 2. 配置环境变量
#### 2. 项目启动
** 方法 1**:使用 init 脚本(推荐)
我们提供了自动化的初始化脚本,可以帮您完成环境配置和 Docker 镜像拉取:
```bash
# Linux/macOS
./scripts/init.sh
# Windows PowerShell
.\scripts\init.ps1
```
脚本会:
- 检查并创建 `.env` 文件
- 提示您输入 `SILICONFLOW_API_KEY`(必需)
- 提示您输入 `TAVILY_API_KEY`(可选,用于搜索服务)
- 自动拉取所有必需的 Docker 镜像
::: tip API Key 获取
- [硅基流动](https://cloud.siliconflow.cn/i/Eo5yTHGJ) 注册即送 14 元额度
- [Tavily](https://app.tavily.com/) 获取搜索服务 API Key可选
:::
** 方法 2**:手动配置环境变量
复制环境变量模板并编辑:

93
scripts/init.ps1 Normal file
View File

@ -0,0 +1,93 @@
# Yuxi-Know Initialization Script for PowerShell
# This script helps set up the environment for the Yuxi-Know project
# Note: API keys will be visible during input - use with care
Write-Host "🚀 Initializing Yuxi-Know project..." -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
# Check if .env file exists
if (Test-Path ".env") {
Write-Host "✅ .env file already exists. Skipping environment setup." -ForegroundColor Green
} else {
Write-Host "📝 .env file not found. Let's set up your environment variables." -ForegroundColor Yellow
Write-Host ""
# Get SILICONFLOW_API_KEY
Write-Host "🔑 SiliconFlow API Key required" -ForegroundColor Yellow
Write-Host "Get your API key from: https://cloud.siliconflow.cn/i/Eo5yTHGJ" -ForegroundColor Blue
Write-Host "Note: Press Ctrl+C at any time to cancel" -ForegroundColor Gray
Write-Host ""
do {
$apiKey = Read-Host "Please enter your SILICONFLOW_API_KEY"
if ([string]::IsNullOrEmpty($apiKey)) {
Write-Host "❌ API Key cannot be empty. Please try again." -ForegroundColor Red
}
} while ([string]::IsNullOrEmpty($apiKey))
# Get TAVILY_API_KEY (optional)
Write-Host ""
Write-Host "🔍 Tavily API Key (optional) - for search service" -ForegroundColor Yellow
Write-Host "Get your API key from: https://app.tavily.com/" -ForegroundColor Blue
$TAVILY_API_KEY = Read-Host "Please enter your TAVILY_API_KEY (press Enter to skip)"
# Create .env file
$envContent = @"
# SiliconFlow API Key (required)
SILICONFLOW_API_KEY=$apiKey
# Tavily API Key (optional - for search service)
"@
if (-not [string]::IsNullOrEmpty($TAVILY_API_KEY)) {
$envContent += "TAVILY_API_KEY=$TAVILY_API_KEY"
}
$envContent | Out-File -FilePath ".env" -Encoding UTF8
Write-Host "✅ .env file created successfully!" -ForegroundColor Green
# Clear the variables from memory
Remove-Variable -Name "apiKey" -ErrorAction SilentlyContinue
Remove-Variable -Name "TAVILY_API_KEY" -ErrorAction SilentlyContinue
}
Write-Host ""
Write-Host "📦 Pulling Docker images..." -ForegroundColor Cyan
Write-Host "=========================" -ForegroundColor Cyan
# List of Docker images to pull
$images = @(
"python:3.12-slim",
"node:20-slim",
"node:20-alpine",
"milvusdb/milvus:v2.5.6",
"neo4j:5.26",
"minio/minio:RELEASE.2023-03-20T20-16-18Z",
"ghcr.io/astral-sh/uv:0.7.2",
"nginx:alpine",
"quay.io/coreos/etcd:v3.5.5"
)
# Pull each image
foreach ($image in $images) {
Write-Host "🔄 Pulling ${image}..." -ForegroundColor Yellow
try {
& docker/pull_image.ps1 $image
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Successfully pulled ${image}" -ForegroundColor Green
} else {
Write-Host "❌ Failed to pull ${image}" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "❌ Error pulling ${image}: $_" -ForegroundColor Red
exit 1
}
}
Write-Host ""
Write-Host "🎉 Initialization complete!" -ForegroundColor Green
Write-Host "==========================" -ForegroundColor Green
Write-Host "You can now run: docker compose up -d --build" -ForegroundColor Cyan
Write-Host "This will start all services in development mode with hot-reload enabled." -ForegroundColor Cyan

84
scripts/init.sh Normal file
View File

@ -0,0 +1,84 @@
#!/bin/bash
# Yuxi-Know Initialization Script for Bash/Linux/macOS
# This script helps set up the environment for the Yuxi-Know project
set -e
echo "🚀 Initializing Yuxi-Know project..."
echo "=================================="
# Check if .env file exists
if [ -f ".env" ]; then
echo "✅ .env file already exists. Skipping environment setup."
else
echo "📝 .env file not found. Let's set up your environment variables."
echo ""
# Get SILICONFLOW_API_KEY
echo "🔑 SiliconFlow API Key required"
echo "Get your API key from: https://cloud.siliconflow.cn/i/Eo5yTHGJ"
while true; do
read -s -p "Please enter your SILICONFLOW_API_KEY: " SILICONFLOW_API_KEY
echo ""
if [ -z "$SILICONFLOW_API_KEY" ]; then
echo "❌ API Key cannot be empty. Please try again."
else
break
fi
done
# Get TAVILY_API_KEY (optional)
echo ""
echo "🔍 Tavily API Key (optional) - for search service"
echo "Get your API key from: https://app.tavily.com/"
read -p "Please enter your TAVILY_API_KEY (press Enter to skip): " TAVILY_API_KEY
# Create .env file
cat > .env << EOF
# SiliconFlow API Key (required)
SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY}
# Tavily API Key (optional - for search service)
EOF
if [ -n "$TAVILY_API_KEY" ]; then
echo "TAVILY_API_KEY=${TAVILY_API_KEY}" >> .env
fi
echo "✅ .env file created successfully!"
fi
echo ""
echo "📦 Pulling Docker images..."
echo "========================="
# List of Docker images to pull
images=(
"python:3.12-slim"
"node:20-slim"
"node:20-alpine"
"milvusdb/milvus:v2.5.6"
"neo4j:5.26"
"minio/minio:RELEASE.2023-03-20T20-16-18Z"
"ghcr.io/astral-sh/uv:0.7.2"
"nginx:alpine"
"quay.io/coreos/etcd:v3.5.5"
)
# Pull each image
for image in "${images[@]}"; do
echo "🔄 Pulling ${image}..."
if bash docker/pull_image.sh "$image"; then
echo "✅ Successfully pulled ${image}"
else
echo "❌ Failed to pull ${image}"
exit 1
fi
done
echo ""
echo "🎉 Initialization complete!"
echo "=========================="
echo "You can now run: docker compose up -d --build"
echo "This will start all services in development mode with hot-reload enabled."