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
# Override SQLAlchemy URL from environment variables when available
# 如果环境变量提供了数据库连接字符串,则优先使用该配置
database_url = os.getenv("DATABASE_URL")
if database_url:
config.set_main_option("sqlalchemy.url", database_url)

View file

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

View file

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

View file

@ -99,11 +99,11 @@ async def get_user_llm_instance(
"AZURE_OPENAI": "azure",
"OPENROUTER": "openrouter",
"COMETAPI": "cometapi",
# Chinese LLM providers (OpenAI-compatible) / 国产 LLMOpenAI 兼容)
"DEEPSEEK": "openai", # DeepSeek uses OpenAI-compatible API
"ALIBABA_QWEN": "openai", # Qwen uses OpenAI-compatible API
"MOONSHOT": "openai", # Moonshot (Kimi) uses OpenAI-compatible API
"ZHIPU": "openai", # Zhipu (GLM) uses OpenAI-compatible API
# Chinese LLM providers (OpenAI-compatible)
"DEEPSEEK": "openai", # DeepSeek uses OpenAI-compatible API
"ALIBABA_QWEN": "openai", # Qwen uses OpenAI-compatible API
"MOONSHOT": "openai", # Moonshot (Kimi) uses OpenAI-compatible API
"ZHIPU": "openai", # Zhipu (GLM) uses OpenAI-compatible API
# Add more mappings as needed
}
provider_prefix = provider_map.get(

View file

@ -1,3 +1,4 @@
import contextlib
import logging
from datetime import datetime
from typing import Any
@ -73,16 +74,14 @@ class TaskLoggingService:
Returns:
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:
await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态
try:
# Refresh log_entry to avoid expired state
with contextlib.suppress(Exception):
await self.session.refresh(log_entry)
except Exception:
pass
# Update the existing log entry
log_entry.status = LogStatus.SUCCESS
log_entry.message = message
@ -124,17 +123,14 @@ class TaskLoggingService:
Returns:
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:
await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态
try:
# Refresh log_entry to avoid expired state
with contextlib.suppress(Exception):
await self.session.refresh(log_entry)
except Exception:
# If refresh fails, the object might be detached / 如果刷新失败,对象可能已分离
pass
# Update the existing log entry
log_entry.status = LogStatus.FAILED
log_entry.level = LogLevel.ERROR
@ -182,16 +178,14 @@ class TaskLoggingService:
Returns:
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:
await self.session.rollback()
# Refresh log_entry to avoid expired state / 刷新 log_entry 避免过期状态
try:
# Refresh log_entry to avoid expired state
with contextlib.suppress(Exception):
await self.session.refresh(log_entry)
except Exception:
pass
log_entry.message = progress_message
if progress_metadata:

View file

@ -37,8 +37,8 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers";
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 InferenceParamsEditor from "../inference-params-editor";
@ -489,10 +489,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
<div className="space-y-2">
<Label htmlFor="provider">Provider *</Label>
<Select
value={formData.provider}
onValueChange={handleProviderChange}
>
<Select value={formData.provider} onValueChange={handleProviderChange}>
<SelectTrigger>
<SelectValue placeholder="Select a provider">
{formData.provider && (
@ -548,23 +545,23 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
</div>
<div className="space-y-2">
<Label htmlFor="language">Language (Optional)</Label>
<Select
value={formData.language || "English"}
onValueChange={(value) => handleInputChange("language", value)}
>
<SelectTrigger>
<SelectValue placeholder="Select language" />
</SelectTrigger>
<SelectContent>
{LANGUAGES.map((language) => (
<SelectItem key={language.value} value={language.value}>
{language.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<Label htmlFor="language">Language (Optional)</Label>
<Select
value={formData.language || "English"}
onValueChange={(value) => handleInputChange("language", value)}
>
<SelectTrigger>
<SelectValue placeholder="Select language" />
</SelectTrigger>
<SelectContent>
{LANGUAGES.map((language) => (
<SelectItem key={language.value} value={language.value}>
{language.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="api_key">API Key *</Label>
@ -580,7 +577,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
<div className="space-y-2">
<Label htmlFor="api_base">
API Base URL
API Base URL
{selectedProvider?.apiBase && (
<span className="text-xs font-normal text-muted-foreground ml-2">
(Auto-filled for {selectedProvider.label})
@ -602,8 +599,8 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
{selectedProvider?.apiBase && !formData.api_base && (
<p className="text-xs text-amber-600 flex items-center gap-1">
<AlertCircle className="h-3 w-3" />
API Base URL is required for {selectedProvider.label}. Click to auto-fill:
<button
API Base URL is required for {selectedProvider.label}. Click to auto-fill:
<button
type="button"
className="underline font-medium"
onClick={() => handleInputChange("api_base", selectedProvider.apiBase || "")}