From 2611aad43e4481ca28f9be106c858891c3b7a802 Mon Sep 17 00:00:00 2001 From: Chenyme <118253778+chenyme@users.noreply.github.com> Date: Sun, 15 Feb 2026 18:08:10 +0800 Subject: [PATCH] chore: update version to 0.3.0, enhance configuration migration logic, and remove outdated README notes --- app/core/config.py | 79 ++++++++++++++++++++++++++++++++++++---------- docs/README.en.md | 3 -- pyproject.toml | 2 +- 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index efb0ec2..d761bd8 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -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 = { diff --git a/docs/README.en.md b/docs/README.en.md index e92283a..c674654 100644 --- a/docs/README.en.md +++ b/docs/README.en.md @@ -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. - image
diff --git a/pyproject.toml b/pyproject.toml index e2fc17b..f808a04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"