Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52c4ef2d87 | |||
| 52c31fabe2 | |||
| 79e239ad97 |
@@ -1 +1 @@
|
||||
__version__ = "4.17.0"
|
||||
__version__ = "4.17.1"
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Any, TypedDict
|
||||
|
||||
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
||||
|
||||
VERSION = "4.17.0"
|
||||
VERSION = "4.17.1"
|
||||
DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db")
|
||||
|
||||
WEBHOOK_SUPPORTED_PLATFORMS = [
|
||||
|
||||
+13
-8
@@ -299,7 +299,9 @@ class LogManager:
|
||||
) -> int:
|
||||
os.makedirs(os.path.dirname(file_path) or ".", exist_ok=True)
|
||||
rotation = f"{max_mb} MB" if max_mb and max_mb > 0 else None
|
||||
retention = f"{backup_count} files" if rotation else None
|
||||
retention = (
|
||||
backup_count if rotation and backup_count and backup_count > 0 else None
|
||||
)
|
||||
if trace:
|
||||
return _loguru.add(
|
||||
file_path,
|
||||
@@ -363,13 +365,16 @@ class LogManager:
|
||||
if not enable_file:
|
||||
return
|
||||
|
||||
cls._file_sink_id = cls._add_file_sink(
|
||||
file_path=cls._resolve_log_path(file_path),
|
||||
level=logger.level,
|
||||
max_mb=max_mb,
|
||||
backup_count=3,
|
||||
trace=False,
|
||||
)
|
||||
try:
|
||||
cls._file_sink_id = cls._add_file_sink(
|
||||
file_path=cls._resolve_log_path(file_path),
|
||||
level=logger.level,
|
||||
max_mb=max_mb,
|
||||
backup_count=3,
|
||||
trace=False,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to add file sink: {e}")
|
||||
|
||||
@classmethod
|
||||
def configure_trace_logger(cls, config: dict | None) -> None:
|
||||
|
||||
@@ -323,7 +323,8 @@ class ProviderOpenAIOfficial(Provider):
|
||||
llm_response.reasoning_content = reasoning
|
||||
_y = True
|
||||
if delta.content:
|
||||
completion_text = delta.content
|
||||
# Don't strip streaming chunks to preserve spaces between words
|
||||
completion_text = self._normalize_content(delta.content, strip=False)
|
||||
llm_response.result_chain = MessageChain(
|
||||
chain=[Comp.Plain(completion_text)],
|
||||
)
|
||||
@@ -371,6 +372,86 @@ class ProviderOpenAIOfficial(Provider):
|
||||
output=completion_tokens,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _normalize_content(raw_content: Any, strip: bool = True) -> str:
|
||||
"""Normalize content from various formats to plain string.
|
||||
|
||||
Some LLM providers return content as list[dict] format
|
||||
like [{'type': 'text', 'text': '...'}] instead of
|
||||
plain string. This method handles both formats.
|
||||
|
||||
Args:
|
||||
raw_content: The raw content from LLM response, can be str, list, or other.
|
||||
strip: Whether to strip whitespace from the result. Set to False for
|
||||
streaming chunks to preserve spaces between words.
|
||||
|
||||
Returns:
|
||||
Normalized plain text string.
|
||||
"""
|
||||
if isinstance(raw_content, list):
|
||||
# Check if this looks like OpenAI content-part format
|
||||
# Only process if at least one item has {'type': 'text', 'text': ...} structure
|
||||
has_content_part = any(
|
||||
isinstance(part, dict) and part.get("type") == "text"
|
||||
for part in raw_content
|
||||
)
|
||||
if has_content_part:
|
||||
text_parts = []
|
||||
for part in raw_content:
|
||||
if isinstance(part, dict) and part.get("type") == "text":
|
||||
text_val = part.get("text", "")
|
||||
# Coerce to str in case text is null or non-string
|
||||
text_parts.append(str(text_val) if text_val is not None else "")
|
||||
return "".join(text_parts)
|
||||
# Not content-part format, return string representation
|
||||
return str(raw_content)
|
||||
|
||||
if isinstance(raw_content, str):
|
||||
content = raw_content.strip() if strip else raw_content
|
||||
# Check if the string is a JSON-encoded list (e.g., "[{'type': 'text', ...}]")
|
||||
# This can happen when streaming concatenates content that was originally list format
|
||||
# Only check if it looks like a complete JSON array (requires strip for check)
|
||||
check_content = raw_content.strip()
|
||||
if (
|
||||
check_content.startswith("[")
|
||||
and check_content.endswith("]")
|
||||
and len(check_content) < 8192
|
||||
):
|
||||
try:
|
||||
# First try standard JSON parsing
|
||||
parsed = json.loads(check_content)
|
||||
except json.JSONDecodeError:
|
||||
# If that fails, try parsing as Python literal (handles single quotes)
|
||||
# This is safer than blind replace("'", '"') which corrupts apostrophes
|
||||
try:
|
||||
import ast
|
||||
|
||||
parsed = ast.literal_eval(check_content)
|
||||
except (ValueError, SyntaxError):
|
||||
parsed = None
|
||||
|
||||
if isinstance(parsed, list):
|
||||
# Only convert if it matches OpenAI content-part schema
|
||||
# i.e., at least one item has {'type': 'text', 'text': ...}
|
||||
has_content_part = any(
|
||||
isinstance(part, dict) and part.get("type") == "text"
|
||||
for part in parsed
|
||||
)
|
||||
if has_content_part:
|
||||
text_parts = []
|
||||
for part in parsed:
|
||||
if isinstance(part, dict) and part.get("type") == "text":
|
||||
text_val = part.get("text", "")
|
||||
# Coerce to str in case text is null or non-string
|
||||
text_parts.append(
|
||||
str(text_val) if text_val is not None else ""
|
||||
)
|
||||
if text_parts:
|
||||
return "".join(text_parts)
|
||||
return content
|
||||
|
||||
return str(raw_content)
|
||||
|
||||
async def _parse_openai_completion(
|
||||
self, completion: ChatCompletion, tools: ToolSet | None
|
||||
) -> LLMResponse:
|
||||
@@ -383,8 +464,7 @@ class ProviderOpenAIOfficial(Provider):
|
||||
|
||||
# parse the text completion
|
||||
if choice.message.content is not None:
|
||||
# text completion
|
||||
completion_text = str(choice.message.content).strip()
|
||||
completion_text = self._normalize_content(choice.message.content)
|
||||
# specially, some providers may set <think> tags around reasoning content in the completion text,
|
||||
# we use regex to remove them, and store then in reasoning_content field
|
||||
reasoning_pattern = re.compile(r"<think>(.*?)</think>", re.DOTALL)
|
||||
@@ -394,6 +474,8 @@ class ProviderOpenAIOfficial(Provider):
|
||||
[match.strip() for match in matches],
|
||||
)
|
||||
completion_text = reasoning_pattern.sub("", completion_text).strip()
|
||||
# Also clean up orphan </think> tags that may leak from some models
|
||||
completion_text = re.sub(r"</think>\s*$", "", completion_text).strip()
|
||||
llm_response.result_chain = MessageChain().message(completion_text)
|
||||
|
||||
# parse the reasoning content if any
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
## What's Changed
|
||||
|
||||
hotfix of 4.17.0
|
||||
|
||||
- 修复:当开启了 “启用文件日志” 后,无法启动 AstrBot,报错 `ValueError: Invalid unit value while parsing duration: 'files'`。这是由于日志轮转设置中保留配置错误导致的,已通过根据备份数量正确设置保留参数进行修复。
|
||||
- fix: When "Enable file logging" is turned on, AstrBot fails to start with error `ValueError: Invalid unit value while parsing duration: 'files'`. This is due to an incorrect retention configuration in the log rotation setup, which has been fixed by properly setting the retention parameter based on backup count.
|
||||
|
||||
### 新增
|
||||
- 新增 LINE 平台适配器与相关配置支持 ([#5085](https://github.com/AstrBotDevs/AstrBot/issues/5085))
|
||||
- 新增备用回退聊天模型列表,当主模型报错时自动切换到备用模型 ([#5109](https://github.com/AstrBotDevs/AstrBot/issues/5109))
|
||||
- 新增插件加载失败后的热重载支持,便于插件修复后快速恢复 ([#5043](https://github.com/AstrBotDevs/AstrBot/issues/5043))
|
||||
- WebUI 新增 SSL 配置选项并同步更新相关日志行为 ([#5117](https://github.com/AstrBotDevs/AstrBot/issues/5117))
|
||||
|
||||
### 修复
|
||||
- 修复 Dockerfile 中依赖导出流程,增加 `uv lock` 步骤并移除不必要的 `--frozen` 参数,提升构建稳定性 ([#5091](https://github.com/AstrBotDevs/AstrBot/issues/5091), [#5089](https://github.com/AstrBotDevs/AstrBot/issues/5089))
|
||||
- 修复首次启动公告 `FIRST_NOTICE.md` 的本地化路径解析问题,补充兼容路径处理 ([#5083](https://github.com/AstrBotDevs/AstrBot/issues/5083), [#5082](https://github.com/AstrBotDevs/AstrBot/issues/5082))
|
||||
|
||||
### 优化
|
||||
- 日志系统由 `colorlog` 切换为 `loguru`,增强日志输出与展示能力 ([#5115](https://github.com/AstrBotDevs/AstrBot/issues/5115))
|
||||
|
||||
## What's Changed (EN)
|
||||
|
||||
### New Features
|
||||
- Added LINE platform adapter support with related configuration options ([#5085](https://github.com/AstrBotDevs/AstrBot/issues/5085))
|
||||
- Added fallback chat model chain support in tool loop runner, with corresponding config and improved provider selection display ([#5109](https://github.com/AstrBotDevs/AstrBot/issues/5109))
|
||||
- Added hot reload support after plugin load failure for faster recovery during plugin development and maintenance ([#5043](https://github.com/AstrBotDevs/AstrBot/issues/5043))
|
||||
- Added SSL configuration options for WebUI and updated related logging behavior ([#5117](https://github.com/AstrBotDevs/AstrBot/issues/5117))
|
||||
|
||||
### Fixes
|
||||
- Fixed Dockerfile dependency export flow by adding a `uv lock` step and removing unnecessary `--frozen` flag to improve build stability ([#5091](https://github.com/AstrBotDevs/AstrBot/issues/5091), [#5089](https://github.com/AstrBotDevs/AstrBot/issues/5089))
|
||||
- Fixed locale path resolution for `FIRST_NOTICE.md` and added compatible fallback handling ([#5083](https://github.com/AstrBotDevs/AstrBot/issues/5083), [#5082](https://github.com/AstrBotDevs/AstrBot/issues/5082))
|
||||
|
||||
### Improvements
|
||||
- Replaced `colorlog` with `loguru` to improve logging capabilities and console display ([#5115](https://github.com/AstrBotDevs/AstrBot/issues/5115))
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "astrbot-desktop",
|
||||
"version": "4.17.0",
|
||||
"version": "4.17.1",
|
||||
"description": "AstrBot desktop wrapper",
|
||||
"private": true,
|
||||
"main": "main.js",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "AstrBot"
|
||||
version = "4.17.0"
|
||||
version = "4.17.1"
|
||||
description = "Easy-to-use multi-platform LLM chatbot and development framework"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
Reference in New Issue
Block a user