Skip to content

Commit 19bb5e6

Browse files
authored
♻️ Translate error messages and Chinese comments in backend code into English #1131
2 parents 9e11804 + d798f9b commit 19bb5e6

File tree

13 files changed

+510
-656
lines changed

13 files changed

+510
-656
lines changed

backend/apps/model_managment_app.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ async def create_provider_model(request: ProviderModelRequest, authorization: Op
115115
model_list = await get_provider_models(model_data)
116116

117117
# Merge existing model's max_tokens attribute
118-
model_list = merge_existing_model_tokens(model_list, tenant_id, request.provider, request.model_type)
118+
model_list = merge_existing_model_tokens(
119+
model_list, tenant_id, request.provider, request.model_type)
119120

120121
# Sort model list by ID
121122
model_list = sort_models_by_id(model_list)
@@ -164,7 +165,8 @@ async def batch_create_models(request: BatchCreateModelsRequest, authorization:
164165
existing_max_tokens = existing_model_by_display["max_tokens"]
165166
new_max_tokens = model["max_tokens"]
166167
if existing_max_tokens != new_max_tokens:
167-
update_model_record(existing_model_by_display["model_id"], {"max_tokens": new_max_tokens}, user_id)
168+
update_model_record(existing_model_by_display["model_id"], {
169+
"max_tokens": new_max_tokens}, user_id)
168170
continue
169171

170172
model_dict = await prepare_model_dict(
@@ -267,7 +269,7 @@ async def delete_model(display_name: str = Query(..., embed=True), authorization
267269
If the model is an embedding or multi_embedding type, both types will be deleted
268270
269271
Args:
270-
display_name: Display name of the model to delete (唯一键)
272+
display_name: Display name of the model to delete (unique key)
271273
authorization: Authorization header
272274
"""
273275
try:
@@ -282,10 +284,10 @@ async def delete_model(display_name: str = Query(..., embed=True), authorization
282284
message=f"Model not found: {display_name}",
283285
data=None
284286
)
285-
# 支持 embedding/multi_embedding 互删
287+
# Support mutual deletion of embedding/multi_embedding
286288
deleted_types = []
287289
if model["model_type"] in ["embedding", "multi_embedding"]:
288-
# 查找所有 embedding/multi_embedding 且 display_name 相同的模型
290+
# Find all embedding/multi_embedding models with the same display_name
289291
for t in ["embedding", "multi_embedding"]:
290292
m = get_model_by_display_name(display_name, tenant_id)
291293
if m and m["model_type"] == t:

backend/consts/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_value(cls, status: Optional[str]) -> str:
2525
return status
2626

2727

28-
# 用户认证相关请求模型
28+
# User authentication related request models
2929
class UserSignUpRequest(BaseModel):
3030
"""User registration request model"""
3131
email: EmailStr

backend/database/utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from typing import Any, Dict
22

33

4-
# 全局追踪字段管理方法
4+
# Global tracking field management methods
55
def add_creation_tracking(data: Dict[str, Any], user_id: str) -> Dict[str, Any]:
66
"""
7-
添加创建追踪字段(created_by和updated_by)
7+
Add creation tracking fields (created_by and updated_by)
88
99
Args:
10-
data: 要添加字段的数据字典
11-
user_id: 当前用户ID
10+
data: Data dictionary to add fields to
11+
user_id: Current user ID
1212
1313
Returns:
14-
Dict[str, Any]: 添加追踪字段后的数据字典
14+
Dict[str, Any]: Data dictionary with tracking fields added
1515
"""
1616
data_copy = data.copy()
1717
data_copy["created_by"] = user_id
@@ -21,14 +21,14 @@ def add_creation_tracking(data: Dict[str, Any], user_id: str) -> Dict[str, Any]:
2121

2222
def add_update_tracking(data: Dict[str, Any], user_id: str) -> Dict[str, Any]:
2323
"""
24-
添加更新追踪字段(updated_by
24+
Add update tracking field (updated_by)
2525
2626
Args:
27-
data: 要添加字段的数据字典
28-
user_id: 当前用户ID
27+
data: Data dictionary to add field to
28+
user_id: Current user ID
2929
3030
Returns:
31-
Dict[str, Any]: 添加追踪字段后的数据字典
31+
Dict[str, Any]: Data dictionary with tracking field added
3232
"""
3333
data_copy = data.copy()
3434
data_copy["updated_by"] = user_id

backend/services/data_process_service.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def _init_redis_client(self):
6565
connection_pool=self.redis_pool)
6666
logger.info("Redis client initialized successfully.")
6767
else:
68-
logger.warning("REDIS_BACKEND_URL not set, Redis client not initialized.")
68+
logger.warning(
69+
"REDIS_BACKEND_URL not set, Redis client not initialized.")
6970
except Exception as e:
7071
logger.error(f"Failed to initialize Redis client: {str(e)}")
7172

@@ -82,7 +83,8 @@ def _init_clip_model(self):
8283
self.clip_available = True
8384
logger.info("CLIP model loaded successfully")
8485
except Exception as e:
85-
logger.warning(f"Failed to load CLIP model, size-only filtering will be used: {str(e)}")
86+
logger.warning(
87+
f"Failed to load CLIP model, size-only filtering will be used: {str(e)}")
8688
self.clip_available = False
8789

8890
async def start(self):
@@ -102,7 +104,8 @@ def _get_celery_inspector(self):
102104
if not celery_app.conf.broker_url or not celery_app.conf.result_backend:
103105
celery_app.conf.broker_url = REDIS_URL
104106
celery_app.conf.result_backend = REDIS_BACKEND_URL
105-
logger.warning(f"Celery broker URL is not configured properly, reconfiguring to {celery_app.conf.broker_url}")
107+
logger.warning(
108+
f"Celery broker URL is not configured properly, reconfiguring to {celery_app.conf.broker_url}")
106109
try:
107110
inspector = celery_app.control.inspect()
108111
inspector.ping()
@@ -176,8 +179,10 @@ def get_reserved():
176179
# Add to the set, duplicates will be handled
177180
task_ids.add(task_id)
178181
except Exception as redis_error:
179-
logger.warning(f"Failed to query Redis for stored task IDs: {str(redis_error)}")
180-
logger.debug(f"Total unique task IDs collected (inspector + Redis): {len(task_ids)}")
182+
logger.warning(
183+
f"Failed to query Redis for stored task IDs: {str(redis_error)}")
184+
logger.debug(
185+
f"Total unique task IDs collected (inspector + Redis): {len(task_ids)}")
181186
tasks = [get_task_info(task_id) for task_id in task_ids]
182187
all_task_infos = await asyncio.gather(*tasks, return_exceptions=True)
183188
for task_info in all_task_infos:
@@ -366,7 +371,7 @@ async def filter_important_image(self, image_url: str, positive_prompt: str = "a
366371
}
367372
}
368373

369-
# 延迟加载CLIP模型
374+
# Lazy load CLIP model
370375
if not self.clip_available:
371376
self._init_clip_model()
372377

backend/services/prompt_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ def _stream_results(produce_queue, latest, stop_flags, threads):
237237

238238

239239
def join_info_for_generate_system_prompt(prompt_for_generate, sub_agent_info_list, task_description, tool_info_list, language: str = 'zh'):
240-
input_label = "接受输入" if language == 'zh' else "Inputs"
241-
output_label = "返回输出类型" if language == 'zh' else "Output type"
240+
input_label = "Inputs" if language == 'en' else "接受输入"
241+
output_label = "Output type" if language == 'en' else "返回输出类型"
242242

243243
tool_description = "\n".join(
244244
[f"- {tool['name']}: {tool['description']} \n {input_label}: {tool['inputs']}\n {output_label}: {tool['output_type']}"

backend/services/user_management_service.py

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,21 @@ async def check_auth_service_health() -> bool:
8888
try:
8989
supabase_url = os.getenv("SUPABASE_URL")
9090
supabase_key = os.getenv("SUPABASE_KEY")
91-
91+
9292
health_url = f'{supabase_url}/auth/v1/health'
9393
headers = {'apikey': supabase_key}
94-
94+
9595
async with aiohttp.ClientSession() as session:
9696
async with session.get(health_url, headers=headers) as response:
9797
if not response.ok:
9898
return False
99-
99+
100100
data = await response.json()
101101
# Check if the service is available by checking if the response contains the name field and its value is "GoTrue"
102102
is_available = data and data.get("name") == "GoTrue"
103-
103+
104104
return is_available
105-
105+
106106
except aiohttp.ClientError as e:
107107
logging.error(f"Auth service connection failed: {str(e)}")
108108
return False
@@ -117,7 +117,8 @@ async def signup_user(email: EmailStr,
117117
invite_code: Optional[str] = None):
118118
"""User registration"""
119119
client = get_supabase_client()
120-
logging.info(f"Receive registration request: email={email}, is_admin={is_admin}")
120+
logging.info(
121+
f"Receive registration request: email={email}, is_admin={is_admin}")
121122
if is_admin:
122123
await verify_invite_code(invite_code)
123124

@@ -138,7 +139,8 @@ async def signup_user(email: EmailStr,
138139
# Create user tenant relationship
139140
insert_user_tenant(user_id=user_id, tenant_id=tenant_id)
140141

141-
logging.info(f"User {email} registered successfully, role: {user_role}, tenant: {tenant_id}")
142+
logging.info(
143+
f"User {email} registered successfully, role: {user_role}, tenant: {tenant_id}")
142144

143145
if is_admin:
144146
await generate_tts_stt_4_admin(tenant_id, user_id)
@@ -147,7 +149,8 @@ async def signup_user(email: EmailStr,
147149
else:
148150
logging.error(
149151
"Supabase registration request returned no user object")
150-
raise UserRegistrationException("Registration service is temporarily unavailable, please try again later")
152+
raise UserRegistrationException(
153+
"Registration service is temporarily unavailable, please try again later")
151154

152155

153156
async def parse_supabase_response(is_admin, response, user_role):
@@ -157,7 +160,7 @@ async def parse_supabase_response(is_admin, response, user_role):
157160
"email": response.user.email,
158161
"role": user_role
159162
}
160-
163+
161164
session_data = None
162165
if response.session:
163166
session_data = {
@@ -166,7 +169,7 @@ async def parse_supabase_response(is_admin, response, user_role):
166169
"expires_at": calculate_expires_at(response.session.access_token),
167170
"expires_in_seconds": get_jwt_expiry_seconds(response.session.access_token)
168171
}
169-
172+
170173
return {
171174
"user": user_data,
172175
"session": session_data,
@@ -206,7 +209,8 @@ async def generate_tts_stt_4_admin(tenant_id, user_id):
206209

207210

208211
async def verify_invite_code(invite_code):
209-
logging.info("detect admin registration request, start verifying invite code")
212+
logging.info(
213+
"detect admin registration request, start verifying invite code")
210214
logging.info(f"The INVITE_CODE obtained from consts.const: {INVITE_CODE}")
211215
if not INVITE_CODE:
212216
logging.error("please check the INVITE_CODE environment variable")
@@ -219,7 +223,8 @@ async def verify_invite_code(invite_code):
219223
if invite_code != INVITE_CODE:
220224
logging.warning(
221225
f"Admin invite code verification failed: user provided='{invite_code}', system configured='{INVITE_CODE}'")
222-
raise IncorrectInviteCodeException("Please enter the correct admin invite code")
226+
raise IncorrectInviteCodeException(
227+
"Please enter the correct admin invite code")
223228
logging.info("Admin invite code verification successful")
224229

225230

@@ -246,21 +251,21 @@ async def signin_user(email: EmailStr,
246251
f"User {email} logged in successfully, session validity is {expiry_seconds} seconds, role: {user_role}")
247252

248253
return {
249-
"message":f"Login successful, session validity is {expiry_seconds} seconds",
250-
"data":{
251-
"user": {
252-
"id": response.user.id,
253-
"email": response.user.email,
254-
"role": user_role
255-
},
256-
"session": {
257-
"access_token": response.session.access_token,
258-
"refresh_token": response.session.refresh_token,
259-
"expires_at": expires_at,
260-
"expires_in_seconds": expiry_seconds
261-
}
254+
"message": f"Login successful, session validity is {expiry_seconds} seconds",
255+
"data": {
256+
"user": {
257+
"id": response.user.id,
258+
"email": response.user.email,
259+
"role": user_role
260+
},
261+
"session": {
262+
"access_token": response.session.access_token,
263+
"refresh_token": response.session.refresh_token,
264+
"expires_at": expires_at,
265+
"expires_in_seconds": expiry_seconds
262266
}
263267
}
268+
}
264269

265270

266271
async def refresh_user_token(authorization, refresh_token: str):
@@ -283,10 +288,10 @@ async def get_session_by_authorization(authorization):
283288
if user.user_metadata and 'role' in user.user_metadata:
284289
user_role = user.user_metadata['role']
285290
return {"user": {
286-
"id": user.id,
287-
"email": user.email,
288-
"role": user_role
289-
}
290-
}
291+
"id": user.id,
292+
"email": user.email,
293+
"role": user_role
294+
}
295+
}
291296
else:
292297
raise ValueError("Session is invalid")

0 commit comments

Comments
 (0)