59 lines
1.5 KiB
Markdown
59 lines
1.5 KiB
Markdown
## python环境
|
||
本项目的python环境是基于 poetry创建的,如果需要运行 py文件,需要执行poetry run python xxx.py 来执行。
|
||
启动脚本:
|
||
```
|
||
poetry run uvicorn fastapi_app:app --host 0.0.0.0 --port 8001
|
||
```
|
||
|
||
|
||
## 测试脚本:
|
||
```
|
||
curl --request POST \
|
||
--url http://localhost:8001/api/v2/chat/completions \
|
||
--header 'authorization: Bearer a21c99620a8ef61d69563afe05ccce89' \
|
||
--header 'content-type: application/json' \
|
||
--header 'X-Request-ID: 123123123' \
|
||
--data '{
|
||
"messages": [
|
||
{
|
||
"role": "user",
|
||
"content": "咖啡多少钱一杯"
|
||
}
|
||
],
|
||
"stream": true,
|
||
"model": "whatever",
|
||
"language": "ja",
|
||
"bot_id": "63069654-7750-409d-9a58-a0960d899a20",
|
||
"tool_response": true,
|
||
"session_id":"xxxxx",
|
||
"user_identifier": "及川"
|
||
}'
|
||
```
|
||
|
||
## 环境变量
|
||
环境变量的代码都需要放到 utils/settings.py里管理
|
||
|
||
## 添加依赖
|
||
如果需要添加依赖,需要在 pyproject.toml 里添加,然后执行 poetry install 来安装。
|
||
并执行`poetry export -f requirements.txt -o requirements.txt --without-hashes`来更新 requirements.txt 文件。
|
||
|
||
|
||
## Git Worktree 管理
|
||
|
||
用于在多个分支间并行工作,无需频繁切换分支。
|
||
|
||
### 创建新的 worktree 和分支
|
||
|
||
```bash
|
||
# 1. 创建 worktree 目录(如果不存在)
|
||
mkdir -p worktrees
|
||
|
||
# 2. 创建新的 worktree
|
||
git worktree add worktrees/branch-name branch-name
|
||
|
||
# 3. 切换到新的 worktree 目录
|
||
cd worktrees/branch-name
|
||
|
||
# 4. 确认当前分支
|
||
git branch # 应该显示 branch-name
|
||
``` |