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 server/routers (#11361)

LobeHub Botaaded66d9910
diff --git a/src/server/routers/async/caller.ts b/src/server/routers/async/caller.ts
index bf63a054ed4..83a63ab8395 100644
--- a/src/server/routers/async/caller.ts
+++ b/src/server/routers/async/caller.ts
@@ -38,7 +38,7 @@ export const createAsyncServerClient = async (userId: string) => {
};
/**
- * 用来推断 caller 类型辅助方法,但不实际调用 createAsyncCallerFactory,调用会报错:asyncRouter 没有初始化
+ * Helper method for inferring caller type, but does not actually call createAsyncCallerFactory. Calling it will throw an error: asyncRouter is not initialized
*/
const helperFunc = () => {
const dummyCreateCaller = createAsyncCallerFactory(asyncRouter);
@@ -52,8 +52,8 @@ interface CreateCallerOptions {
}
/**
- * 创建 caller 的工厂方法,使用 HTTP Client 调用
- * 使用方式统一成 caller.a.b() 的调用方式
+ * Factory method for creating caller, using HTTP Client to make calls
+ * Unified usage pattern: caller.a.b()
*/
export const createAsyncCaller = async (
options: CreateCallerOptions,
diff --git a/src/server/routers/async/image.ts b/src/server/routers/async/image.ts
index 0ce8a2b0f59..332b573e7ec 100644
--- a/src/server/routers/async/image.ts
+++ b/src/server/routers/async/image.ts
@@ -147,7 +147,7 @@ const categorizeError = (
};
}
- // FIXME: 401 的问题应该放到 agentRuntime 中处理会更好
+ // FIXME: 401 errors should be handled in agentRuntime for better practice
if (error.errorType === AgentRuntimeErrorType.InvalidProviderAPIKey || error?.status === 401) {
return {
errorMessage:
diff --git a/src/server/routers/async/ragEval.ts b/src/server/routers/async/ragEval.ts
index 42a20f43a85..39a5c189a3d 100644
--- a/src/server/routers/async/ragEval.ts
+++ b/src/server/routers/async/ragEval.ts
@@ -63,7 +63,7 @@ export const ragEvalRouter = router({
let questionEmbeddingId = evalRecord.questionEmbeddingId;
let context = evalRecord.context;
- // 如果不存在 questionEmbeddingId,那么就需要做一次 embedding
+ // If questionEmbeddingId does not exist, perform an embedding
if (!questionEmbeddingId) {
const embeddings = await modelRuntime.embeddings({
dimensions: 1024,
@@ -83,7 +83,7 @@ export const ragEvalRouter = router({
questionEmbeddingId = embeddingId;
}
- // 如果不存在 context,那么就需要做一次检索
+ // If context does not exist, perform a retrieval
if (!context || context.length === 0) {
const datasetRecord = await ctx.datasetRecordModel.findById(evalRecord.datasetRecordId);
@@ -99,7 +99,7 @@ export const ragEvalRouter = router({
await ctx.evalRecordModel.update(evalRecord.id, { context });
}
- // 做一次生成 LLM 答案生成
+ // Generate LLM answer
const { messages } = chainAnswerWithContext({ context, knowledge: [], question });
const response = await modelRuntime.chat({
diff --git a/src/server/routers/lambda/_helpers/resolveContext.ts b/src/server/routers/lambda/_helpers/resolveContext.ts
index 68352838ab9..66042dd7f0e 100644
--- a/src/server/routers/lambda/_helpers/resolveContext.ts
+++ b/src/server/routers/lambda/_helpers/resolveContext.ts
@@ -54,14 +54,14 @@ export const resolveContext = async (
};
/**
- * 反向解析:从 sessionId 获取 agentId
+ * Reverse resolution: Get agentId from sessionId
*
- * 用于 Topic Router 等需要 agentId 进行查询的场景
+ * Used in scenarios like Topic Router where agentId is needed for queries
*
* @param sessionId - session ID
- * @param db - 数据库实例
- * @param userId - 用户 ID
- * @returns agentId 或 undefined
+ * @param db - Database instance
+ * @param userId - User ID
+ * @returns agentId or undefined
*/
export const resolveAgentIdFromSession = async (
sessionId: string,
@@ -78,14 +78,14 @@ export const resolveAgentIdFromSession = async (
};
/**
- * 批量反向解析:从多个 sessionId 获取 agentId 映射
+ * Batch reverse resolution: Get agentId mapping from multiple sessionIds
*
- * 用于需要批量解析 sessionId -> agentId 的场景(如 recentTopics)
+ * Used in scenarios requiring batch sessionId -> agentId resolution (e.g., recentTopics)
*
- * @param sessionIds - session ID 数组
- * @param db - 数据库实例
- * @param userId - 用户 ID
- * @returns sessionId -> agentId 的映射 Map
+ * @param sessionIds - Array of session IDs
+ * @param db - Database instance
+ * @param userId - User ID
+ * @returns Map of sessionId -> agentId
*/
export const batchResolveAgentIdFromSessions = async (
sessionIds: string[],
diff --git a/src/server/routers/lambda/_schema/context.ts b/src/server/routers/lambda/_schema/context.ts
index 95011e0b4b6..84e32e86af3 100644
--- a/src/server/routers/lambda/_schema/context.ts
+++ b/src/server/routers/lambda/_schema/context.ts
@@ -1,11 +1,11 @@
import { z } from 'zod';
/**
- * 会话上下文 Schema
- * 同时支持 agentId 和 sessionId,用于向后兼容
+ * Conversation context schema
+ * Supports both agentId and sessionId for backward compatibility
*
- * 优先级:agentId > sessionId
- * 当同时提供时,agentId 会被用于解析对应的 sessionId
+ * Priority: agentId > sessionId
+ * When both are provided, agentId will be used to resolve the corresponding sessionId
*/
export const conversationContextSchema = z.object({
agentId: z.string().optional(),
@@ -16,8 +16,8 @@ export const conversationContextSchema = z.object({
});
/**
- * 简化版上下文
- * 用于 message 和 topic 的 CRUD 操作
+ * Simplified context
+ * Used for CRUD operations of messages and topics
*/
export const basicContextSchema = z.object({
agentId: z.string().optional(),
diff --git a/src/server/sitemap.ts b/src/server/sitemap.ts
index 0fe0ec4253b..13eaf515852 100644
--- a/src/server/sitemap.ts
+++ b/src/server/sitemap.ts
@@ -32,7 +32,7 @@ export enum SitemapType {
export const LAST_MODIFIED = new Date().toISOString();
-// 每页条目数量
+// Number of items per page
const ITEMS_PER_PAGE = 100;
export class Sitemap {
@@ -40,19 +40,19 @@ export class Sitemap {
private discoverService = new DiscoverService();
- // 获取插件总页数
+ // Get total number of plugin pages
async getPluginPageCount(): Promise<number> {
const list = await this.discoverService.getPluginIdentifiers();
return Math.ceil(list.length / ITEMS_PER_PAGE);
}
- // 获取助理总页数
+ // Get total number of assistant pages
async getAssistantPageCount(): Promise<number> {
const list = await this.discoverService.getAssistantIdentifiers();
return Math.ceil(list.length / ITEMS_PER_PAGE);
}
- // 获取模型总页数
+ // Get total number of model pages
async getModelPageCount(): Promise<number> {
const list = await this.discoverService.getModelIdentifiers();
return Math.ceil(list.length / ITEMS_PER_PAGE);
@@ -164,14 +164,14 @@ export class Sitemap {
),
);
- // 获取需要分页的类型的页数
+ // Get page counts for types that need pagination
const [pluginPages, assistantPages, modelPages] = await Promise.all([
this.getPluginPageCount(),
this.getAssistantPageCount(),
this.getModelPageCount(),
]);
- // 生成分页sitemap链接
+ // Generate paginated sitemap links
const paginatedSitemaps = [
...Array.from({ length: pluginPages }, (_, i) =>
this._generateSitemapLink(
@@ -211,7 +211,7 @@ export class Sitemap {
const pageAssistants = list.slice(startIndex, endIndex);
const sitmap = pageAssistants
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/assistant', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -220,7 +220,7 @@ export class Sitemap {
return flatten(sitmap);
}
- // 如果没有指定页数,返回所有(向后兼容)
+ // If page number is not specified, return all (backward compatibility)
const sitmap = list
.filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
.map((item) =>
@@ -240,7 +240,7 @@ export class Sitemap {
const pagePlugins = list.slice(startIndex, endIndex);
const sitmap = pagePlugins
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/plugin', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -249,7 +249,7 @@ export class Sitemap {
return flatten(sitmap);
}
- // 如果没有指定页数,返回所有(向后兼容)
+ // If page number is not specified, return all (backward compatibility)
const sitmap = list
.filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
.map((item) =>
@@ -269,7 +269,7 @@ export class Sitemap {
const pageModels = list.slice(startIndex, endIndex);
const sitmap = pageModels
- .filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
+ .filter((item) => item.identifier) // Filter out items with empty identifiers
.map((item) =>
this._genSitemap(urlJoin('/community/model', item.identifier), {
lastModified: item?.lastModified || LAST_MODIFIED,
@@ -278,7 +278,7 @@ export class Sitemap {
return flatten(sitmap);
}
- // 如果没有指定页数,返回所有(向后兼容)
+ // If page number is not specified, return all (backward compatibility)
const sitmap = list
.filter((item) => item.identifier) // 过滤掉 identifier 为空的项目
.map((item) =>