Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🌐 chore: translate non-English comments to English in src/server/services (#11841)

LobeHub Bot2fdd71882c0f
diff --git a/src/server/services/changelog/index.ts b/src/server/services/changelog/index.ts
index cbc7ea40dfd..a0c4bf397df 100644
--- a/src/server/services/changelog/index.ts
+++ b/src/server/services/changelog/index.ts
@@ -185,7 +185,7 @@ export class ChangelogService {
}
private genUrl(path: string) {
- // 自定义分隔符为 {{}}
+ // Custom delimiter set to {{}}
const compiledTemplate = template(this.config.urlTemplate, { interpolate: /{{([\S\s]+?)}}/g });
return compiledTemplate({ ...this.config, path });
diff --git a/src/server/services/comfyui/config/fluxModelRegistry.ts b/src/server/services/comfyui/config/fluxModelRegistry.ts
index 09683fdd599..688e0a4b99e 100644
--- a/src/server/services/comfyui/config/fluxModelRegistry.ts
+++ b/src/server/services/comfyui/config/fluxModelRegistry.ts
@@ -514,7 +514,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
// === Priority 3: Community Fine-tuned Models (48 models) ===
- // 3.1 Jib Mix Flux系列
+ // 3.1 Jib Mix Flux Series
'Jib_Mix_Flux_v8_schnell.safetensors': {
priority: 3,
variant: 'schnell',
@@ -534,7 +534,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.2 Real Dream FLUX系列
+ // 3.2 Real Dream FLUX Series
'real_dream_flux_v1.safetensors': {
priority: 3,
variant: 'dev',
@@ -566,7 +566,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.3 Vision Realistic FLUX系列
+ // 3.3 Vision Realistic FLUX Series
'vision_realistic_flux_dev_v2.safetensors': {
priority: 3,
variant: 'dev',
@@ -598,7 +598,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.4 Flux Fusion系列
+ // 3.4 Flux Fusion Series
'flux_fusion_v2_4steps.safetensors': {
priority: 3,
variant: 'dev',
@@ -618,7 +618,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.5 PixelWave FLUX系列
+ // 3.5 PixelWave FLUX Series
'PixelWave_FLUX.1-dev_03.safetensors': {
priority: 3,
variant: 'dev',
@@ -632,7 +632,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.6 Fux Capacity系列
+ // 3.6 Fux Capacity Series
'Fux_Capacity_NSFW_v3.safetensors': {
priority: 3,
variant: 'dev',
@@ -658,7 +658,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.7 Fluxmania系列
+ // 3.7 Fluxmania Series
'FluxMania_Kreamania_v1.safetensors': {
priority: 3,
variant: 'krea',
@@ -684,7 +684,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.8 Fluxed Up系列
+ // 3.8 Fluxed Up Series
'Fluxed_Up_NSFW_v2.safetensors': {
priority: 3,
variant: 'dev',
@@ -692,7 +692,7 @@ export const FLUX_MODEL_REGISTRY: Record<string, ModelConfig> = {
recommendedDtype: 'default',
},
- // 3.9 企业级LiblibAI模型
+ // 3.9 Enterprise LiblibAI Models
'flux.1-ultra-realphoto-v2.safetensors': {
priority: 3,
variant: 'dev',
diff --git a/src/server/services/discover/index.ts b/src/server/services/discover/index.ts
index a7c877ffecf..da4cd8abe9a 100644
--- a/src/server/services/discover/index.ts
+++ b/src/server/services/discover/index.ts
@@ -99,15 +99,15 @@ export class DiscoverService {
async registerClient({ userAgent }: { userAgent?: string }) {
const getDeviceId = async (): Promise<string> => {
- // 1. Vercel 环境下使用 VERCEL_PROJECT_ID
+ // 1. Use VERCEL_PROJECT_ID in Vercel environment
if (process.env.VERCEL_PROJECT_ID) {
return process.env.VERCEL_PROJECT_ID;
}
- // 2. 桌面端使用 machine-id
+ // 2. Use machine-id for desktop
if (isDesktop) {
try {
- // 动态导入
+ // Dynamic import
const { machineId } = await import('node-machine-id');
return await machineId();
} catch (error) {
@@ -191,8 +191,8 @@ export class DiscoverService {
// ============================== Helper Methods ==============================
/**
- * 计算 ModelAbilities 的完整度分数
- * 分数越高表示 abilities 越全
+ * Calculate ModelAbilities completeness score
+ * Higher score indicates more complete abilities
*/
private calculateAbilitiesScore = (abilities?: any): number => {
if (!abilities) return 0;
@@ -218,14 +218,14 @@ export class DiscoverService {
};
/**
- * 在模型数组中选择 abilities 最全的模型
- * 组合最全的 abilities 和最大的 contextWindowTokens
+ * Select the model with the most complete abilities from model array
+ * Combines the most complete abilities and largest contextWindowTokens
*/
private selectModelWithBestAbilities = (models: DiscoverModelItem[]): DiscoverModelItem => {
log('selectModelWithBestAbilities: input models count=%d', models.length);
if (models.length === 1) return models[0];
- // 找到最全的 abilities
+ // Find the most complete abilities
let bestAbilities: Record<string, boolean> = {};
let maxAbilitiesScore = 0;
models.forEach((model) => {
@@ -234,7 +234,7 @@ export class DiscoverService {
maxAbilitiesScore = score;
bestAbilities = { ...(model.abilities as Record<string, boolean>) };
} else if (score === maxAbilitiesScore && model.abilities) {
- // 合并相同分数的 abilities,确保获得最全的组合
+ // Merge abilities with the same score to ensure the most complete combination
const abilities = model.abilities as Record<string, boolean>;
Object.keys(abilities).forEach((key) => {
if (abilities[key]) {
@@ -244,26 +244,26 @@ export class DiscoverService {
}
});
- // 找到最大的 contextWindowTokens
+ // Find the largest contextWindowTokens
const maxContextWindowTokens = Math.max(
...models.map((model) => model.contextWindowTokens || 0),
);
- // 找到最新的 releasedAt
+ // Find the latest releasedAt
const latestReleasedAt = models
.map((model) => model.releasedAt)
.filter(Boolean)
.sort((a, b) => new Date(b!).getTime() - new Date(a!).getTime())[0];
- // 找到最短的 identifier
+ // Find the shortest identifier
const shortestIdentifier = models
.map((model) => model.identifier)
.reduce((shortest, current) => (current.length < shortest.length ? current : shortest));
- // 选择一个基础模型(通常选择第一个)
+ // Select a base model (usually the first one)
const baseModel = models[0];
- // 组装最终模型,使用最佳的各项属性
+ // Assemble final model using the best attributes
const result: DiscoverModelItem = {
...baseModel,
abilities: bestAbilities as any,
@@ -952,7 +952,7 @@ export class DiscoverService {
}
const categoryCounts = countBy(list, (item) => item.category);
const result = Object.entries(categoryCounts)
- .filter(([category]) => Boolean(category)) // 过滤掉空值
+ .filter(([category]) => Boolean(category)) // Filter out empty values
.map(([category, count]) => ({
category,
count,
@@ -1388,7 +1388,7 @@ export class DiscoverService {
providerCount: providers.length,
providers,
};
- // 使用简单的合并而不是 DEFAULT_DISCOVER_MODEL_ITEM,避免类型冲突
+ // Use simple merge instead of DEFAULT_DISCOVER_MODEL_ITEM to avoid type conflicts
return {
...model,
abilities: model.abilities || {},
@@ -1413,8 +1413,8 @@ export class DiscoverService {
);
}
- // 优化去重逻辑:选择 abilities 最全的模型
- // 1. 按 identifier 分组
+ // Optimize deduplication logic: select models with most complete abilities
+ // 1. Group by identifier
const identifierGroups = new Map<string, DiscoverModelItem[]>();
list.forEach((item) => {
const key = item.identifier;
@@ -1430,12 +1430,12 @@ export class DiscoverService {
identifierGroups.size,
);
- // 2. 从每个 identifier 组中选择 abilities 最全的
+ // 2. Select the model with most complete abilities from each identifier group
let deduplicatedByIdentifier = Array.from(identifierGroups.values()).map((models) =>
this.selectModelWithBestAbilities(models),
);
- // 3. 按 displayName 分组
+ // 3. Group by displayName
const displayNameGroups = new Map<string, DiscoverModelItem[]>();
deduplicatedByIdentifier.forEach((item) => {
const key = item.displayName?.toLowerCase() || '';
@@ -1451,7 +1451,7 @@ export class DiscoverService {
displayNameGroups.size,
);
- // 4. 从每个 displayName 组中选择 abilities 最全的
+ // 4. Select the model with most complete abilities from each displayName group
const finalList: DiscoverModelItem[] = Array.from(displayNameGroups.values()).map((models) =>
this.selectModelWithBestAbilities(models),
);
@@ -1484,7 +1484,7 @@ export class DiscoverService {
}
const categoryCounts = countBy(list, (item) => item.providerId);
const result = Object.entries(categoryCounts)
- .filter(([category]) => Boolean(category)) // 过滤掉空值
+ .filter(([category]) => Boolean(category)) // Filter out empty values
.map(([category, count]) => ({
category,
count,
diff --git a/src/server/services/document/index.ts b/src/server/services/document/index.ts
index e33774cc8bc..c6c9a39f128 100644
--- a/src/server/services/document/index.ts
+++ b/src/server/services/document/index.ts
@@ -253,13 +253,13 @@ export class DocumentService {
const { filePath, file, cleanup } = await this.fileService.downloadFileToLocal(fileId);
const logPrefix = `[${file.name}]`;
- log(`${logPrefix} 开始解析文件为文档, 路径: ${filePath}`);
+ log(`${logPrefix} Starting to parse file as document, path: ${filePath}`);
try {
- // 使用loadFile加载文件内容
+ // Use loadFile to load file content
const fileDocument = await loadFile(filePath);
- log(`${logPrefix} 文件解析成功 %O`, {
+ log(`${logPrefix} File parsed successfully %O`, {
fileType: fileDocument.fileType,
size: fileDocument.content.length,
});
@@ -292,7 +292,7 @@ export class DocumentService {
return document as LobeDocument;
} catch (error) {
- console.error(`${logPrefix} 文件解析失败:`, error);
+ console.error(`${logPrefix} File parsing failed:`, error);
throw error;
} finally {
cleanup();
@@ -300,20 +300,20 @@ export class DocumentService {
}
/**
- * 解析文件内容
+ * Parse file content
*
*/
async parseFile(fileId: string): Promise<LobeDocument> {
const { filePath, file, cleanup } = await this.fileService.downloadFileToLocal(fileId);
const logPrefix = `[${file.name}]`;
- log(`${logPrefix} 开始解析文件, 路径: ${filePath}`);
+ log(`${logPrefix} Starting to parse file, path: ${filePath}`);
try {
- // 使用loadFile加载文件内容
+ // Use loadFile to load file content
const fileDocument = await loadFile(filePath);
- log(`${logPrefix} 文件解析成功 %O`, {
+ log(`${logPrefix} File parsed successfully %O`, {
fileType: fileDocument.fileType,
size: fileDocument.content.length,
});
@@ -341,7 +341,7 @@ export class DocumentService {
return document as LobeDocument;
} catch (error) {
- console.error(`${logPrefix} 文件解析失败:`, error);
+ console.error(`${logPrefix} File parsing failed:`, error);
throw error;
} finally {
cleanup();
diff --git a/src/server/services/oidc/index.ts b/src/server/services/oidc/index.ts
index 67a01781a40..a63641ccd5c 100644
--- a/src/server/services/oidc/index.ts
+++ b/src/server/services/oidc/index.ts
@@ -35,10 +35,10 @@ export class OIDCService {
}
async findOrCreateGrants(accountId: string, clientId: string, existingGrantId?: string) {
- // 2. 查找或创建 Grant 对象
+ // 2. Find or create Grant object
let grant;
if (existingGrantId) {
- // 如果之前的交互步骤已经关联了 Grant
+ // If a previous interaction step already associated a Grant
grant = await this.provider.Grant.find(existingGrantId);
log('Found existing grantId: %s', existingGrantId);
if (grant) {
@@ -68,7 +68,7 @@ export class OIDCService {
}
if (!grant) {
- // 如果没有找到或没有 existingGrantId,则创建新的
+ // If not found or no existingGrantId, create a new one
grant = new this.provider.Grant({
accountId: accountId,
clientId: clientId,
diff --git a/src/server/services/queue/impls/qstash.ts b/src/server/services/queue/impls/qstash.ts
index 1afdd72d5e8..7cc85b0aee2 100644
--- a/src/server/services/queue/impls/qstash.ts
+++ b/src/server/services/queue/impls/qstash.ts
@@ -44,7 +44,7 @@ export class QStashQueueServiceImpl implements QueueServiceImpl {
stepIndex,
timestamp: Date.now(),
},
- delay: Math.ceil(delay / 1000), // 将毫秒转换为秒
+ delay: Math.ceil(delay / 1000), // Convert milliseconds to seconds
headers: {
'Content-Type': 'application/json',
'X-Agent-Operation-Id': operationId,
@@ -91,7 +91,7 @@ export class QStashQueueServiceImpl implements QueueServiceImpl {
// Check this marker during actual execution
log('Requested cancellation for message %s', messageId);
- // TODO: Implement cancellation logic, can store cancellation list via Redis
+ // TODO: Implement cancellation logic, cancellation list can be stored via Redis
// await this.redis.sadd('cancelled_tasks', messageId);
} catch (error) {
log('Failed to cancel task %s: %O', messageId, error);