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 model-runtime (#12480)

LobeHub Bot059d0cc0fc61
diff --git a/packages/model-runtime/src/providers/azureOpenai/index.ts b/packages/model-runtime/src/providers/azureOpenai/index.ts
index 09f56aaef97..c76ea626e9c 100644
--- a/packages/model-runtime/src/providers/azureOpenai/index.ts
+++ b/packages/model-runtime/src/providers/azureOpenai/index.ts
@@ -294,12 +294,12 @@ export class LobeAzureOpenAI implements LobeRuntimeAI {
};
private maskSensitiveUrl = (url: string) => {
- // 使用正则表达式匹配 'https://' 后面和 '.openai.azure.com/' 前面的内容
+ // Use a regex to match the content between 'https://' and '.openai.azure.com/'
const regex = /^(https:\/\/)([^.]+)(\.openai\.azure\.com\/.*)$/;
- // 使用替换函数
+ // Use a replacement function
return url.replace(regex, (match, protocol, subdomain, rest) => {
- // 将子域名替换为 '***'
+ // Replace the subdomain with '***'
return `${protocol}***${rest}`;
});
};
diff --git a/packages/model-runtime/src/providers/azureai/index.ts b/packages/model-runtime/src/providers/azureai/index.ts
index 2218e12f29e..f33cb01ccae 100644
--- a/packages/model-runtime/src/providers/azureai/index.ts
+++ b/packages/model-runtime/src/providers/azureai/index.ts
@@ -162,12 +162,12 @@ export class LobeAzureAI implements LobeRuntimeAI {
}
private maskSensitiveUrl = (url: string) => {
- // 使用正则表达式匹配 'https://' 后面和 '.azure.com/' 前面的内容
+ // Use a regex to match the content between 'https://' and '.azure.com/'
const regex = /^(https:\/\/)([^.]+)(\.cognitiveservices\.azure\.com\/.*)$/;
- // 使用替换函数
+ // Use a replacement function
return url.replace(regex, (match, protocol, subdomain, rest) => {
- // 将子域名替换为 '***'
+ // Replace the subdomain with '***'
return `${protocol}***${rest}`;
});
};
diff --git a/packages/model-runtime/src/providers/cometapi/index.ts b/packages/model-runtime/src/providers/cometapi/index.ts
index 29e6191cde4..0aa4b044d45 100644
--- a/packages/model-runtime/src/providers/cometapi/index.ts
+++ b/packages/model-runtime/src/providers/cometapi/index.ts
@@ -31,7 +31,7 @@ export const params = {
const modelsPage = (await client.models.list()) as any;
const rawList: any[] = modelsPage.data || [];
- // 处理模型列表,移除不必要的字段
+ // Process the model list and remove unnecessary fields
const modelList: CometAPIModelCard[] = rawList.map((model) => ({
id: model.id,
object: model.object,
diff --git a/packages/model-runtime/src/providers/huggingface/index.ts b/packages/model-runtime/src/providers/huggingface/index.ts
index 037205ab3b1..2beff6c4989 100644
--- a/packages/model-runtime/src/providers/huggingface/index.ts
+++ b/packages/model-runtime/src/providers/huggingface/index.ts
@@ -71,11 +71,11 @@ export const params = {
.map((model) => {
const { architecture, providers } = model;
- // 选择提供商信息的优先级:is_model_author > 信息完整度 > 默认首个
+ // Provider info selection priority: is_model_author > field completeness > first by default
const mainProvider =
providers.find((p) => p.is_model_author) ||
providers.reduce((prev, curr) => {
- // 计算每个 provider 非 undefined 的字段数
+ // Count the number of non-undefined fields for each provider
const prevFieldCount = Object.values(prev).filter(
(v) => v !== undefined && v !== null,
).length;
@@ -90,13 +90,13 @@ export const params = {
return undefined;
}
- // 多 provider 回退策略:先从主 provider 获取,缺失时查其他 provider
+ // Multi-provider fallback strategy: get from main provider first, fall back to others if missing
const getFieldFromProviders = (field: keyof typeof mainProvider) => {
const value = mainProvider[field];
if (value !== undefined && value !== null) {
return value;
}
- // 缺失时遍历其他 provider
+ // Traverse other providers when the field is missing
return providers.find(
(p) => p !== mainProvider && p[field] !== undefined && p[field] !== null,
)?.[field];
@@ -107,7 +107,7 @@ export const params = {
const supportsTools = getFieldFromProviders('supports_tools') as boolean | undefined;
// const supportsStructuredOutput = getFieldFromProviders('supports_structured_output') as boolean | undefined;
- // displayName 使用 id 去除斜杠左侧内容(例如 'zai-org/GLM-4.6' -> 'GLM-4.6')
+ // displayName strips everything to the left of the slash from the id (e.g. 'zai-org/GLM-4.6' -> 'GLM-4.6')
const displayName =
typeof model.id === 'string' && model.id.includes('/')
? model.id.split('/').slice(1).join('/').trim()
diff --git a/packages/model-runtime/src/providers/minimax/createImage.ts b/packages/model-runtime/src/providers/minimax/createImage.ts
index 3ee6c8b3a20..9d9fcfbba81 100644
--- a/packages/model-runtime/src/providers/minimax/createImage.ts
+++ b/packages/model-runtime/src/providers/minimax/createImage.ts
@@ -39,7 +39,7 @@ export async function createMiniMaxImage(
model,
n: 1,
prompt: params.prompt,
- //prompt_optimizer: true, // 开启 prompt 自动优化
+ //prompt_optimizer: true, // Enable automatic prompt optimization
...(typeof params.seed === 'number' ? { seed: params.seed } : {}),
};
diff --git a/packages/model-runtime/src/providers/minimax/index.ts b/packages/model-runtime/src/providers/minimax/index.ts
index 288aedf5740..f4f985d6424 100644
--- a/packages/model-runtime/src/providers/minimax/index.ts
+++ b/packages/model-runtime/src/providers/minimax/index.ts
@@ -18,7 +18,7 @@ export const LobeMinimaxAI = createOpenAICompatibleRuntime({
// Interleaved thinking
const processedMessages = messages.map((message: any) => {
if (message.role === 'assistant' && message.reasoning) {
- // 只处理没有 signature 的历史推理内容
+ // Only process historical reasoning content without a signature
if (!message.reasoning.signature && message.reasoning.content) {
const { reasoning, ...messageWithoutReasoning } = message;
return {
@@ -35,7 +35,7 @@ export const LobeMinimaxAI = createOpenAICompatibleRuntime({
};
}
- // 有 signature 或没有 content 的情况,移除 reasoning 字段
+ // If there is a signature or no content, remove the reasoning field
// eslint-disable-next-line unused-imports/no-unused-vars
const { reasoning, ...messageWithoutReasoning } = message;
return messageWithoutReasoning;
diff --git a/packages/model-runtime/src/providers/ollama/index.ts b/packages/model-runtime/src/providers/ollama/index.ts
index 713cf4d4d51..aa6c66eeb03 100644
--- a/packages/model-runtime/src/providers/ollama/index.ts
+++ b/packages/model-runtime/src/providers/ollama/index.ts
@@ -231,44 +231,44 @@ export class LobeOllamaAI implements LobeRuntimeAI {
async pullModel(params: PullModelParams, options?: ModelRequestOptions): Promise<Response> {
const { model, insecure } = params;
- const signal = options?.signal; // 获取传入的 AbortSignal
+ const signal = options?.signal; // Get the passed-in AbortSignal
const abortOllama = () => {
- // 假设 this.client.abort() 是幂等的或者可以安全地多次调用
+ // Assume this.client.abort() is idempotent or can be safely called multiple times
this.client.abort();
};
- // 如果有 AbortSignal,监听 abort 事件
- // 使用 { once: true } 确保监听器只触发一次
+ // If an AbortSignal is present, listen for the abort event
+ // Use { once: true } to ensure the listener only fires once
signal?.addEventListener('abort', abortOllama, { once: true });
try {
- // 获取 Ollama pull 的迭代器
+ // Get the iterable for the Ollama pull operation
const iterable = await this.client.pull({
insecure: insecure ?? false,
model,
stream: true,
});
- // 使用专门的模型下载流转换方法
+ // Use the dedicated model download stream conversion method
const progressStream = createModelPullStream(iterable, model, {
onCancel: () => {
- // 当流被取消时,调用 abortOllama
- // 移除 signal 的监听器,避免重复调用(如果 abortOllama 不是幂等的)
+ // When the stream is cancelled, call abortOllama
+ // Remove the signal's event listener to avoid duplicate calls (if abortOllama is not idempotent)
signal?.removeEventListener('abort', abortOllama);
- abortOllama(); // 执行中止逻辑
+ abortOllama(); // Execute the abort logic
},
});
- // 返回标准响应
+ // Return the standard response
return new Response(progressStream, {
headers: { 'Content-Type': 'application/json' },
});
} catch (error) {
- // 如果在调用 client.pull 或创建流的初始阶段出错,需要移除监听器
+ // If an error occurs during the initial call to client.pull or stream creation, remove the listener
signal?.removeEventListener('abort', abortOllama);
- // 处理错误
+ // Handle errors
if ((error as Error).message === 'fetch failed') {
return createErrorResponse(AgentRuntimeErrorType.OllamaServiceUnavailable, {
message: 'please check whether your ollama service is available',
@@ -278,7 +278,7 @@ export class LobeOllamaAI implements LobeRuntimeAI {
console.error('model download error:', error);
- // 检查是否是取消操作
+ // Check if the operation was cancelled
if ((error as Error).name === 'AbortError') {
return new Response(
JSON.stringify({
@@ -292,7 +292,7 @@ export class LobeOllamaAI implements LobeRuntimeAI {
);
}
- // 返回错误响应
+ // Return an error response
const errorMessage = error instanceof Error ? error.message : String(error);
return new Response(
JSON.stringify({
diff --git a/packages/model-runtime/src/providers/openrouter/index.ts b/packages/model-runtime/src/providers/openrouter/index.ts
index a6fbf658780..bf876d96ebb 100644
--- a/packages/model-runtime/src/providers/openrouter/index.ts
+++ b/packages/model-runtime/src/providers/openrouter/index.ts
@@ -68,13 +68,13 @@ export const params = {
return [];
}
- // 处理前端获取的模型信息,转换为标准格式
+ // Process the model info fetched from the frontend and convert to standard format
const formattedModels = modelList.map((model) => {
const { top_provider, architecture, pricing, supported_parameters } = model;
const inputModalities = architecture.input_modalities || [];
- // 处理 name,默认去除冒号及其前面的内容
+ // Process the name, by default strip the colon and everything before it
let displayName = model.name;
const colonIndex = displayName.indexOf(':');
if (colonIndex !== -1) {
diff --git a/packages/model-runtime/src/providers/qiniu/index.ts b/packages/model-runtime/src/providers/qiniu/index.ts
index 92b30a4ea4a..dae6d2b2b7c 100644
--- a/packages/model-runtime/src/providers/qiniu/index.ts
+++ b/packages/model-runtime/src/providers/qiniu/index.ts
@@ -18,7 +18,7 @@ export const params = {
return rest;
});
- // 自动检测模型提供商并选择相应配置
+ // Auto-detect the model provider and select the corresponding configuration
return processMultiProviderModelList(modelList, 'qiniu');
},
provider: ModelProvider.Qiniu,
diff --git a/packages/model-runtime/src/providers/straico/index.ts b/packages/model-runtime/src/providers/straico/index.ts
index 9ff14166fb1..72d9d900917 100644
--- a/packages/model-runtime/src/providers/straico/index.ts
+++ b/packages/model-runtime/src/providers/straico/index.ts
@@ -55,7 +55,7 @@ export const LobeStraicoAI = createOpenAICompatibleRuntime({
}
const json: StraicoModelsResponse = await response.json();
- const chatModels: StraicoChatModel[] = json?.data?.chat || []; // 另有 audio, image 模型待适配
+ const chatModels: StraicoChatModel[] = json?.data?.chat || []; // There are also audio and image models to be adapted
// Transform Straico models to standardized format
const formattedModels = chatModels.map((model) => {
diff --git a/packages/model-runtime/src/providers/togetherai/type.ts b/packages/model-runtime/src/providers/togetherai/type.ts
index d3628306324..191789396b9 100644
--- a/packages/model-runtime/src/providers/togetherai/type.ts
+++ b/packages/model-runtime/src/providers/togetherai/type.ts
@@ -1,5 +1,5 @@
interface ModelInstanceConfig {
- appearsIn: any[]; // 你可以替换为实际类型
+ appearsIn: any[]; // You can replace this with the actual type
order: number;
}
diff --git a/packages/model-runtime/src/providers/vertexai/index.ts b/packages/model-runtime/src/providers/vertexai/index.ts
index 0be72082778..5a158e71bde 100644
--- a/packages/model-runtime/src/providers/vertexai/index.ts
+++ b/packages/model-runtime/src/providers/vertexai/index.ts
@@ -12,7 +12,7 @@ export class LobeVertexAI extends LobeGoogleAI {
try {
const client = new GoogleGenAI({
...params,
- location: params?.location ?? DEFAULT_VERTEXAI_LOCATION, // @google/genai 不传 location 会报错
+ location: params?.location ?? DEFAULT_VERTEXAI_LOCATION, // @google/genai throws an error if location is not provided
vertexai: true,
});