diff --git a/README.md b/README.md index 27f877f..d72310e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ 2. 增加港股、美股支持。 3. 完善Dockerfile、GitHub Actions 支持docker一键部署使用。 4. 支持x86_64 和 ARM64架构镜像 +5. 支持流式输出,支持前端传入Key(仅作为本地用户使用,日志等内容不会输出) 感谢@Cassianvale ## docker一键部署 ``` @@ -24,18 +25,22 @@ API_TIMEOUT=60 202503040712版本开始 (AI分析发生错误,查看日志 注意⚠️: 环境变量名变更,更新版本后需要调整!!! -针对API_URL处理兼容更多的api地址 +针对API_URL处理兼容更多的api地址,规则与Cherry Studio一致, /结尾忽略v1版本,#结尾强制使用输入地址。 API_URL 处理逻辑说明: 1. 当 API_URL 以 / 结尾时直接追加 chat/completions,保留原有版本号: 示例: 输入: https://ark.cn-beijing.volces.com/api/v3/ 输出: https://ark.cn-beijing.volces.com/api/v3/chat/completions - -2. 当 API_URL 不以 / 结尾时使用默认版本号 v1: +2. 当 API_URL 以 # 结尾时强制使用当前链接: + 示例: + 输入: https://ark.cn-beijing.volces.com/api/v3/chat/completions# + 输出: https://ark.cn-beijing.volces.com/api/v3/chat/completions +3. 当 API_URL 不以 / 结尾时使用默认版本号 v1: 示例: 输入: https://ark.cn-beijing.volces.com/api 输出: https://ark.cn-beijing.volces.com/api/v1/chat/completions + ``` 默认8888端口,部署完成后访问 http://127.0.0.1:8888 即可使用。 diff --git a/requirements.txt b/requirements.txt index 7799faf..c77a82b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ ---index-url https://pypi.tuna.tsinghua.edu.cn/simple +# 本地打包使用国内镜像源加速下载, 默认不使用,影响github actions +# --index-url https://pypi.tuna.tsinghua.edu.cn/simple # 基础科学计算和数据处理库 numpy==2.1.2 diff --git a/stock_analyzer.py b/stock_analyzer.py index 43d92e2..bcf9375 100644 --- a/stock_analyzer.py +++ b/stock_analyzer.py @@ -7,6 +7,7 @@ from typing import Dict, List, Optional, Tuple, Generator from dotenv import load_dotenv import json from logger import get_logger +from utils.api_utils import APIUtils # 获取日志器 logger = get_logger() @@ -259,12 +260,8 @@ class StockAnalyzer: logger.error(error_msg) return error_msg if not stream else (yield json.dumps({"error": error_msg})) - # 标准化API URL 使用Cherry Studio相同逻辑处理 - if self.API_URL.endswith('/'): - api_url = f"{self.API_URL}chat/completions" - else: - api_url = f"{self.API_URL}/v1/chat/completions" - + # 标准化API URL + api_url = APIUtils.format_api_url(self.API_URL) logger.debug(f"标准化后的API URL: {api_url}") diff --git a/templates/index.html b/templates/index.html index 979f6bc..eeeeb61 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,28 +7,202 @@
+ + + {% if announcement %} +当前时间
+- {{ announcement }} -
+ + +A股市场
+ + +港股市场
+ + +美股市场
+ +