Commit 05a30ae00100b94fe1d756357294dc0c356239b8

Authored by tangwang
1 parent 81205fc7

docs

Showing 2 changed files with 82 additions and 19 deletions   Show diff stats
README.md
... ... @@ -111,17 +111,26 @@ cp .env.example .env
111 111  
112 112 若需本地商品图(如侧边栏「Similar」用本地图),可准备 `data/images/` 下的图片资源;图像风格分析不依赖该目录。
113 113  
114   -### 启动
  114 +### 启动与日志
115 115  
116 116 ```bash
117   -# 推荐
118   -./scripts/start.sh
  117 +# 推荐:使用服务脚本(含 Conda 环境激活与日志管理)
  118 +./scripts/service.sh start # 后台启动
  119 +./scripts/service.sh status # 查看状态
  120 +./scripts/service.sh stop # 停止
119 121  
120   -# 或
  122 +# 本地调试:前台运行(Ctrl+C 停止)
  123 +./scripts/service.sh run
  124 +
  125 +# 也可直接运行 Streamlit(需自行激活虚拟环境)
121 126 streamlit run app.py
122 127 ```
123 128  
124   -默认访问 `http://localhost:8501`。商品搜索依赖外部 Search API,请在 `.env` 中配置 `SEARCH_API_BASE_URL` 与 `SEARCH_API_TENANT_ID`。
  129 +- 端口优先级:`STREAMLIT_PORT` 环境变量 > `app.config.settings.app_port` > 默认 `6008`。
  130 +- Host 默认为 `0.0.0.0`,可通过 `STREAMLIT_HOST` 覆盖。
  131 +- 日志目录:`logs/streamlit.log`(标准输出)、`logs/streamlit_error.log`(错误输出,由 `scripts/service.sh` 统一管理)。
  132 +
  133 +默认访问 `http://<HOST>:<PORT>`(本地通常是 `http://localhost:6008`)。商品搜索依赖外部 Search API,请在 `.env` 中配置 `SEARCH_API_BASE_URL` 与 `SEARCH_API_TENANT_ID`。
125 134  
126 135 ### 部署
127 136  
... ... @@ -140,7 +149,13 @@ CentOS 8 等部署说明见 **[docs/DEPLOY_CENTOS8.md](docs/DEPLOY_CENTOS8.md)**
140 149 | `SEARCH_API_TENANT_ID` | 租户 ID | 见 config.py |
141 150 | `SEARCH_PRODUCTS_LIMIT` | 单次搜索返回条数上限 | 20 |
142 151  
143   -更多见 `app/config.py`。
  152 +更多配置项见 `app/config.py` 中的 `Settings`,包括:
  153 +
  154 +- OpenAI 相关:`openai_model`、`openai_vision_model`、`openai_use_reasoning`、`openai_reasoning_effort`、`openai_api_base_url` 等。
  155 +- 应用运行:`app_host`、`app_port`、`debug`、`log_level`。
  156 +- 数据路径:`raw_data_path`、`processed_data_path`、`image_data_path` 等。
  157 +
  158 +配置加载优先级(高 → 低):**代码初始化参数 > 项目根目录下 `.env` > 系统环境变量 > 默认值**,其中 `.env` 会覆盖同名系统环境变量(见 `Settings.settings_customise_sources`)。
144 159  
145 160 ## 项目结构(概览)
146 161  
... ... @@ -157,9 +172,9 @@ shop_agent/
157 172 │ └── ...
158 173 ├── app.py # Streamlit UI、流式渲染、引用解析与商品卡片
159 174 ├── docs/
160   -│ └── 技术实现报告.md # 详细设计与实现说明
  175 +│ └── 技术实现报告.md # 详细设计、Prompt 与架构说明
161 176 ├── scripts/
162   -│ └── start.sh
  177 +│ └── service.sh # 统一的启停脚本(start/stop/status/run)
163 178 ├── .env.example
164 179 ├── requirements.txt
165 180 └── README.md
... ...
docs/DEPLOY_CENTOS8.md
... ... @@ -91,28 +91,53 @@ python scripts/download_dataset.py
91 91  
92 92 ##
93 93  
94 94 -### 4.1 霂湔
  95 +### 4.1 霂湔
95 96  
96 97 | | |
97 98 |------|------|
98   -| `start.sh` | 銝餃嚗 Streamlit |
99   -| `stop.sh` | 迫 Streamlit |
100   -| `check_services.sh` | 摨瑟 |
  99 +| `scripts/service.sh` | 蝏蝞∠嚗 / 迫 / / 蔭 Conda 憓瘣颱敹 |
  100 +
  101 +> 霂湔 `start.sh` / `stop.sh` / `check_services.sh` 撌脫蛹 `scripts/service.sh`嚗遣霈桀憓敺蝙霂亥
101 102  
102 103 ### 4.2 摨
103 104  
104 105 ```bash
105   -# 撘 1嚗蝙 start.sh嚗
106   -./scripts/start.sh
  106 +cd /path/to/shop_agent
107 107  
108   -# 撘 2嚗餈
109   -source venv/bin/activate
110   -streamlit run app.py --server.port=8501 --server.address=0.0.0.0
  108 +# 嚗
  109 +./scripts/service.sh start
  110 +
  111 +#
  112 +./scripts/service.sh status
  113 +
  114 +# 迫
  115 +./scripts/service.sh stop
  116 +
  117 +# 靚餈trl+C 迫嚗
  118 +./scripts/service.sh run
  119 +```
  120 +
  121 +`service.sh` 隡
  122 +
  123 +- 瞈瘣餌漲摰 Conda 憓恕嚗CONDA_BASE=$HOME/miniconda3`嚗CONDA_ENV=aishopping-py312`嚗憓
  124 +- 蝏 `streamlit run app.py`嚗
  125 +- 撠銝秤颲 `logs/streamlit.log` `logs/streamlit_error.log`
  126 +
  127 +蝡臬銝 Host 漣銝綽
  128 +
  129 +- 蝡臬嚗STREAMLIT_PORT` 憓 > `.env`/憓葉 `APP_PORT`嚗Settings.app_port`嚗> 暺恕 `6008`嚗
  130 +- Host嚗STREAMLIT_HOST` 憓 > 暺恕 `0.0.0.0`
  131 +
  132 +憒餈 Streamlit嚗嚗
  133 +
  134 +```bash
  135 +source venv/bin/activate # 瘣餃笆摨 Conda 憓
  136 +streamlit run app.py --server.port=6008 --server.address=0.0.0.0
111 137 ```
112 138  
113 139 ### 4.3 霈輸
114 140  
115   -- **Streamlit 摨**嚗ttp://IP:8501
  141 +- **Streamlit 摨**嚗http://IP:<PORT>`嚗恕 `http://IP:6008` 霈輸嚗 Nginx 誨 80/443 蝡臬嚗
116 142  
117 143 ## 鈭漣蝵脣遣霈
118 144  
... ... @@ -176,4 +201,27 @@ A: 蝖桐歇摰 `openssl-devel`libffi-devel`嚗雿輻 Miniconda
176 201 A: 璉 `.env` 銝 `SEARCH_API_BASE_URL` `SEARCH_API_TENANT_ID` 蔭嚗&靽霈輸揣
177 202  
178 203 ### Q: 摨瑟嚗
179   -A: 銵 `./scripts/check_services.sh` 辣
  204 +A: 挪 `/admin/health`/indexer/health` 蝑璉揣摨瑞嚗頨怠 `scripts/service.sh status` 敹辣嚗logs/streamlit.log`logs/streamlit_error.log`嚗憸
  205 +
  206 +---
  207 +
  208 +## 銝憓宏憓遣霈格郊撉
  209 +
  210 +1. **郊隞**
  211 + - 銝隞
  212 + - ﹝蝚 2 蝡遣 Python/Conda 憓僎摰 `requirements.txt`
  213 +2. **餈宏蔭**
  214 + - 隞憭 `.env`嚗釣鈭 `.env.example` 憛怠
  215 + - 撖孵僎靽格嚗
  216 + - 憭扳芋嚗OPENAI_API_KEY`OPENAI_API_BASE_URL`嚗芋妍蝑
  217 + - 揣嚗SEARCH_API_BASE_URL`SEARCH_API_TENANT_ID`嚗
  218 + - 摨嚗APP_PORT`敶楝敺
  219 +3. **擐活嚗靚**
  220 + - 憓葉銵 `./scripts/service.sh run`嚗
  221 + - 蝖株恕憿菟霈輸揣銝笆霂甇虜嚗
  222 + - 憒撘虜嚗 `logs/streamlit_error.log` 銝 `logs/streamlit.log`
  223 +4. **甇餈**
  224 + - 雿輻 `./scripts/service.sh start` 嚗僎蝏蝡 `systemd` / Nginx 蝷箔蝥喳蝏餈輕雿頂嚗
  225 + - 憓誨蔭嚗笆憭挪
  226 +
  227 +誑銝郊撉歹隞亙銝銋蝔喳宏 ShopAgent嚗靽撘垢銝敹蔭
... ...