Merge pull request #398 from MODSetter/dev

chore: removed chinese comments to pass ruff checks and updated migration nos
This commit is contained in:
Rohan Verma 2025-10-13 20:12:50 -07:00 committed by GitHub
commit cbabc2bb4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 63 additions and 83 deletions

View file

@ -21,7 +21,6 @@ from app.db import Base # Assuming your Base is defined in app.db
config = context.config config = context.config
# Override SQLAlchemy URL from environment variables when available # Override SQLAlchemy URL from environment variables when available
# 如果环境变量提供了数据库连接字符串,则优先使用该配置
database_url = os.getenv("DATABASE_URL") database_url = os.getenv("DATABASE_URL")
if database_url: if database_url:
config.set_main_option("sqlalchemy.url", database_url) config.set_main_option("sqlalchemy.url", database_url)

View file

@ -1,8 +1,7 @@
"""Add Chinese LLM providers to LiteLLMProvider enum """Add Chinese LLM providers to LiteLLMProvider enum
添加国产 LLM 提供商到 LiteLLMProvider 枚举
Revision ID: 26 Revision ID: 28
Revises: 25 Revises: 27
""" """
from collections.abc import Sequence from collections.abc import Sequence
@ -10,8 +9,8 @@ from collections.abc import Sequence
from alembic import op from alembic import op
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision: str = "26" revision: str = "28"
down_revision: str | None = "25" down_revision: str | None = "27"
branch_labels: str | Sequence[str] | None = None branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None
@ -19,17 +18,15 @@ depends_on: str | Sequence[str] | None = None
def upgrade() -> None: def upgrade() -> None:
""" """
Add Chinese LLM providers to LiteLLMProvider enum. Add Chinese LLM providers to LiteLLMProvider enum.
添加国产 LLM 提供商到 LiteLLMProvider 枚举
Adds support for: Adds support for:
- DEEPSEEK: DeepSeek AI models - DEEPSEEK: DeepSeek AI models
- ALIBABA_QWEN: Alibaba Qwen (通义千问) models - ALIBABA_QWEN: Alibaba Qwen models
- MOONSHOT: Moonshot AI (月之暗面 Kimi) models - MOONSHOT: Moonshot AI models
- ZHIPU: Zhipu AI (智谱 GLM) models - ZHIPU: Zhipu AI models
""" """
# Add DEEPSEEK to the enum if it doesn't already exist # Add DEEPSEEK to the enum if it doesn't already exist
# 如果不存在则添加 DEEPSEEK 到枚举
op.execute( op.execute(
""" """
DO $$ DO $$
@ -46,7 +43,6 @@ def upgrade() -> None:
) )
# Add ALIBABA_QWEN to the enum if it doesn't already exist # Add ALIBABA_QWEN to the enum if it doesn't already exist
# 如果不存在则添加 ALIBABA_QWEN 到枚举
op.execute( op.execute(
""" """
DO $$ DO $$
@ -63,7 +59,6 @@ def upgrade() -> None:
) )
# Add MOONSHOT to the enum if it doesn't already exist # Add MOONSHOT to the enum if it doesn't already exist
# 如果不存在则添加 MOONSHOT 到枚举
op.execute( op.execute(
""" """
DO $$ DO $$
@ -80,7 +75,6 @@ def upgrade() -> None:
) )
# Add ZHIPU to the enum if it doesn't already exist # Add ZHIPU to the enum if it doesn't already exist
# 如果不存在则添加 ZHIPU 到枚举
op.execute( op.execute(
""" """
DO $$ DO $$
@ -100,19 +94,14 @@ def upgrade() -> None:
def downgrade() -> None: def downgrade() -> None:
""" """
Remove Chinese LLM providers from LiteLLMProvider enum. Remove Chinese LLM providers from LiteLLMProvider enum.
LiteLLMProvider 枚举中移除国产 LLM 提供商
Note: PostgreSQL doesn't support removing enum values directly. Note: PostgreSQL doesn't support removing enum values directly.
This would require recreating the enum type and updating all dependent objects. This would require recreating the enum type and updating all dependent objects.
For safety, this downgrade is a no-op. For safety, this downgrade is a no-op.
注意PostgreSQL 不支持直接删除枚举值
这需要重建枚举类型并更新所有依赖对象
为了安全起见此降级操作为空操作
""" """
# PostgreSQL doesn't support removing enum values directly # PostgreSQL doesn't support removing enum values directly
# This would require a complex migration recreating the enum # This would require a complex migration recreating the enum
# PostgreSQL 不支持直接删除枚举值 # PostgreSQL 不支持直接删除枚举值
# 这需要复杂的迁移来重建枚举 # 这需要复杂的迁移来重建枚举
pass pass

View file

@ -83,6 +83,7 @@ class LiteLLMProvider(str, Enum):
Enum for LLM providers supported by LiteLLM. Enum for LLM providers supported by LiteLLM.
LiteLLM 支持的 LLM 提供商枚举 LiteLLM 支持的 LLM 提供商枚举
""" """
OPENAI = "OPENAI" OPENAI = "OPENAI"
ANTHROPIC = "ANTHROPIC" ANTHROPIC = "ANTHROPIC"
GROQ = "GROQ" GROQ = "GROQ"
@ -106,11 +107,11 @@ class LiteLLMProvider(str, Enum):
ALEPH_ALPHA = "ALEPH_ALPHA" ALEPH_ALPHA = "ALEPH_ALPHA"
PETALS = "PETALS" PETALS = "PETALS"
COMETAPI = "COMETAPI" COMETAPI = "COMETAPI"
# Chinese LLM Providers (OpenAI-compatible) / 国产 LLM 提供商OpenAI 兼容) # Chinese LLM Providers (OpenAI-compatible)
DEEPSEEK = "DEEPSEEK" # DeepSeek DEEPSEEK = "DEEPSEEK"
ALIBABA_QWEN = "ALIBABA_QWEN" # 阿里通义千问 ALIBABA_QWEN = "ALIBABA_QWEN"
MOONSHOT = "MOONSHOT" # 月之暗面 (Kimi) MOONSHOT = "MOONSHOT"
ZHIPU = "ZHIPU" # 智谱 AI (GLM) ZHIPU = "ZHIPU"
CUSTOM = "CUSTOM" CUSTOM = "CUSTOM"

View file

@ -99,7 +99,7 @@ async def get_user_llm_instance(
"AZURE_OPENAI": "azure", "AZURE_OPENAI": "azure",
"OPENROUTER": "openrouter", "OPENROUTER": "openrouter",
"COMETAPI": "cometapi", "COMETAPI": "cometapi",
# Chinese LLM providers (OpenAI-compatible) / 国产 LLMOpenAI 兼容) # Chinese LLM providers (OpenAI-compatible)
"DEEPSEEK": "openai", # DeepSeek uses OpenAI-compatible API "DEEPSEEK": "openai", # DeepSeek uses OpenAI-compatible API
"ALIBABA_QWEN": "openai", # Qwen uses OpenAI-compatible API "ALIBABA_QWEN": "openai", # Qwen uses OpenAI-compatible API
"MOONSHOT": "openai", # Moonshot (Kimi) uses OpenAI-compatible API "MOONSHOT": "openai", # Moonshot (Kimi) uses OpenAI-compatible API

View file

@ -1,3 +1,4 @@
import contextlib
import logging import logging
from datetime import datetime from datetime import datetime
from typing import Any from typing import Any
@ -73,15 +74,13 @@ class TaskLoggingService:
Returns: Returns:
Log: The updated log entry Log: The updated log entry
""" """
# Ensure session is in a valid state / 确保 session 处于有效状态 # Ensure session is in a valid state
if not self.session.is_active: if not self.session.is_active:
await self.session.rollback() await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态 # Refresh log_entry to avoid expired state
try: with contextlib.suppress(Exception):
await self.session.refresh(log_entry) await self.session.refresh(log_entry)
except Exception:
pass
# Update the existing log entry # Update the existing log entry
log_entry.status = LogStatus.SUCCESS log_entry.status = LogStatus.SUCCESS
@ -124,16 +123,13 @@ class TaskLoggingService:
Returns: Returns:
Log: The updated log entry Log: The updated log entry
""" """
# Ensure session is in a valid state / 确保 session 处于有效状态 # Ensure session is in a valid state
if not self.session.is_active: if not self.session.is_active:
await self.session.rollback() await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态 # Refresh log_entry to avoid expired state
try: with contextlib.suppress(Exception):
await self.session.refresh(log_entry) await self.session.refresh(log_entry)
except Exception:
# If refresh fails, the object might be detached / 如果刷新失败,对象可能已分离
pass
# Update the existing log entry # Update the existing log entry
log_entry.status = LogStatus.FAILED log_entry.status = LogStatus.FAILED
@ -182,15 +178,13 @@ class TaskLoggingService:
Returns: Returns:
Log: The updated log entry Log: The updated log entry
""" """
# Ensure session is in a valid state / 确保 session 处于有效状态 # Ensure session is in a valid state
if not self.session.is_active: if not self.session.is_active:
await self.session.rollback() await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态 # Refresh log_entry to avoid expired state
try: with contextlib.suppress(Exception):
await self.session.refresh(log_entry) await self.session.refresh(log_entry)
except Exception:
pass
log_entry.message = progress_message log_entry.message = progress_message

View file

@ -37,8 +37,8 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers";
import { LANGUAGES } from "@/contracts/enums/languages"; import { LANGUAGES } from "@/contracts/enums/languages";
import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers";
import { type CreateLLMConfig, type LLMConfig, useLLMConfigs } from "@/hooks/use-llm-configs"; import { type CreateLLMConfig, type LLMConfig, useLLMConfigs } from "@/hooks/use-llm-configs";
import InferenceParamsEditor from "../inference-params-editor"; import InferenceParamsEditor from "../inference-params-editor";
@ -489,10 +489,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="provider">Provider *</Label> <Label htmlFor="provider">Provider *</Label>
<Select <Select value={formData.provider} onValueChange={handleProviderChange}>
value={formData.provider}
onValueChange={handleProviderChange}
>
<SelectTrigger> <SelectTrigger>
<SelectValue placeholder="Select a provider"> <SelectValue placeholder="Select a provider">
{formData.provider && ( {formData.provider && (