chore: update version to 0.3.0, enhance configuration migration logic, and remove outdated README notes

This commit is contained in:
Chenyme committed 2026-02-15 18:08:10 +08:00
1 parent 7b093288dc
commit 2611aad43e
3 files changed
+63 -21

No files matched your search

+62 -17
View File
@@ -72,6 +72,41 @@ def _migrate_deprecated_config(
"grok.image_ws_blocked_seconds": "image.final_timeout",
"grok.image_ws_final_min_bytes": "image.final_min_bytes",
"grok.image_ws_medium_min_bytes": "image.medium_min_bytes",
# legacy sections
"network.base_proxy_url": "proxy.base_proxy_url",
"network.asset_proxy_url": "proxy.asset_proxy_url",
"network.timeout": [
"chat.timeout",
"image.timeout",
"video.timeout",
"voice.timeout",
],
"security.cf_clearance": "proxy.cf_clearance",
"security.browser": "proxy.browser",
"security.user_agent": "proxy.user_agent",
"timeout.stream_idle_timeout": [
"chat.stream_timeout",
"image.stream_timeout",
"video.stream_timeout",
],
"timeout.video_idle_timeout": "video.stream_timeout",
"image.image_ws_nsfw": "image.nsfw",
"image.image_ws_blocked_seconds": "image.final_timeout",
"image.image_ws_final_min_bytes": "image.final_min_bytes",
"image.image_ws_medium_min_bytes": "image.medium_min_bytes",
"performance.assets_max_concurrent": [
"asset.upload_concurrent",
"asset.download_concurrent",
"asset.list_concurrent",
"asset.delete_concurrent",
],
"performance.assets_delete_batch_size": "asset.delete_batch_size",
"performance.assets_batch_size": "asset.list_batch_size",
"performance.media_max_concurrent": ["chat.concurrent", "video.concurrent"],
"performance.usage_max_concurrent": "usage.concurrent",
"performance.usage_batch_size": "usage.batch_size",
"performance.nsfw_max_concurrent": "nsfw.concurrent",
"performance.nsfw_batch_size": "nsfw.batch_size",
}
deprecated_sections = set(config.keys()) - valid_sections
@@ -81,25 +116,35 @@ def _migrate_deprecated_config(
result = {k: deepcopy(v) for k, v in config.items() if k in valid_sections}
migrated_count = 0
# 处理废弃配置节中的配置项
for old_section in deprecated_sections:
if old_section not in config or not isinstance(config[old_section], dict):
# 处理废弃配置节或旧配置键
for old_section, old_values in config.items():
if not isinstance(old_values, dict):
continue
for old_key, old_value in config[old_section].items():
# 查找映射规则
for old_key, old_value in old_values.items():
old_path = f"{old_section}.{old_key}"
new_path = MIGRATION_MAP.get(old_path)
if new_path:
new_section, new_key = new_path.split(".", 1)
# 确保新配置节存在
if new_section not in result:
result[new_section] = {}
# 迁移配置项(保留用户的自定义值)
result[new_section][new_key] = old_value
migrated_count += 1
logger.debug(f"Migrated config: {old_path} -> {new_path} = {old_value}")
new_paths = MIGRATION_MAP.get(old_path)
if not new_paths:
continue
if isinstance(new_paths, str):
new_paths = [new_paths]
for new_path in new_paths:
try:
new_section, new_key = new_path.split(".", 1)
if new_section not in result:
result[new_section] = {}
if new_key not in result[new_section]:
result[new_section][new_key] = old_value
migrated_count += 1
logger.debug(
f"Migrated config: {old_path} -> {new_path} = {old_value}"
)
except Exception as e:
logger.warning(
f"Skip config migration for {old_path}: {e}"
)
continue
if isinstance(result.get(old_section), dict):
result[old_section].pop(old_key, None)
# 兼容旧 chat.* 配置键迁移到 app.*
legacy_chat_map = {
-3
View File
@@ -7,9 +7,6 @@
Grok2API rebuilt with **FastAPI**, fully aligned with the latest web call format. Supports streaming/non-streaming chat, image generation/editing, video generation/upscale, deep reasoning, token pool concurrency, and automatic load balancing.
> [!IMPORTANT]
> The project is no longer accepting PRs or new features; this is the last structure optimization.
<img width="2480" height="1686" alt="image" src="https://github.com/user-attachments/assets/c85546a2-9729-4e8a-9c4d-6dc16c62b6b4" />
<br>
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "grok2api"
version = "1.5.0"
version = "0.3.0"
description = "Grok2API rebuilt with FastAPI, fully aligned with the latest web call format. Supports streaming and non-streaming chat, image generation/editing, deep thinking, token pool concurrency, and automatic load balancing."
readme = "README.md"
requires-python = ">=3.13"