docs: update project README
This commit is contained in:
parent
c79709d08f
commit
f78a9adea7
37
README.md
37
README.md
@ -701,25 +701,30 @@ AI 不是神,它需要知道你的代码、你的报错、你的意图。
|
||||
- **依赖管理**: **uv** (强烈推荐,替代 pip/venv)
|
||||
- **编辑器**: 推荐 Cursor 或 VS Code + Windsurf 插件。
|
||||
|
||||
### 2. 项目初始化 (使用 uv)
|
||||
```bash
|
||||
# 1. 安装 uv (MacOS/Linux)
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
# Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
### 2. uv 核心操作指南
|
||||
|
||||
# 2. 初始化项目
|
||||
mkdir my-ai-app
|
||||
cd my-ai-app
|
||||
uv init
|
||||
#### 2.1 安装 uv
|
||||
- **Mac/Linux**: `curl -LsSf https://astral.sh/uv/install.sh | sh`
|
||||
- **Windows**: `powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"`
|
||||
|
||||
# 3. 添加依赖
|
||||
uv add streamlit chainlit openai python-dotenv
|
||||
#### 2.2 Python 版本管理 (无需手动下载 Python!)
|
||||
uv 会自动管理 Python 版本,**你甚至不需要去 python.org 下载 installer**。
|
||||
- `uv python install 3.12` # 下载并安装 Python 3.12
|
||||
- `uv python list` # 查看已安装和可用的 Python 版本
|
||||
- `uv python pin 3.12` # 锁定当前项目使用的 Python 版本 (生成 .python-version)
|
||||
|
||||
# 4. 运行应用
|
||||
uv run streamlit run app.py
|
||||
# 或
|
||||
uv run chainlit run app.py -w
|
||||
```
|
||||
#### 2.3 项目与依赖管理
|
||||
- `uv init <项目名>` # 初始化一个新项目
|
||||
- `uv add <库名>` # 添加依赖 (例: `uv add streamlit`)
|
||||
- `uv remove <库名>` # 移除依赖
|
||||
- `uv tree` # 查看依赖关系树
|
||||
- `uv sync` # 根据 lock 文件同步环境 (团队协作神器)
|
||||
|
||||
#### 2.4 运行代码
|
||||
使用 `uv run` 可以自动检测虚拟环境,无需手动 activate。
|
||||
- `uv run app.py` # 运行 Python 脚本
|
||||
- `uv run streamlit run app.py` # 运行 Streamlit 应用
|
||||
- `uv run --with pandas script.py` # 临时安装 pandas 并运行脚本 (不污染环境)
|
||||
|
||||
### 3. API Key 管理示例 (`.env`)
|
||||
不要把 Key 写死在代码里!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user