feat(models): add max concurrency setting for background tasks
Introduce a new `max_concurrency` parameter to the model configuration, allowing control over the maximum number of concurrent background tasks (ingestion/enrichment) per model. This feature is applicable to chat, embedding, and VLM models, with a value of 0 or undefined falling back to the global default. Update UI components and localization files to support this new setting, ensuring a seamless user experience.
This commit is contained in:
@@ -28,6 +28,9 @@ export interface ModelConfig {
|
||||
// 会在调用远程模型 API 时附加到每个请求上。Authorization、Content-Type 等保留头会被忽略。
|
||||
custom_headers?: Record<string, string>;
|
||||
supports_vision?: boolean; // Whether the model accepts image/multimodal input
|
||||
// 后台任务(入库/富化)对该模型的并发上限,按模型 ID 全副本共享。
|
||||
// 0 或不填表示沿用全局默认(model.max_concurrency);仅对 chat/embedding/vllm 生效。
|
||||
max_concurrency?: number;
|
||||
app_id?: string;
|
||||
// Secret fields (api_key, app_secret) are never returned by the server in
|
||||
// this shape — they live behind the /credentials subresource. They are
|
||||
|
||||
@@ -313,7 +313,7 @@
|
||||
</template>
|
||||
|
||||
<!-- Section 3 — 高级选项(仅在有内容时渲染,避免空 section 出现底部分隔线) -->
|
||||
<section v-if="activeModelType === 'embedding' || activeModelType === 'chat'" class="setting-drawer__section">
|
||||
<section v-if="['embedding', 'chat', 'vllm'].includes(activeModelType)" class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionAdvanced') }}</h4>
|
||||
|
||||
<!-- Embedding 专用:维度 -->
|
||||
@@ -376,6 +376,18 @@
|
||||
</t-select>
|
||||
<p class="form-desc">{{ $t('model.editor.thinkingControlDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Background concurrency cap for this model. Only chat / embedding / vllm
|
||||
are gated by the governor (see internal/models/limiter), so we surface
|
||||
it just for those three. 0 = fall back to the global default.
|
||||
-->
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('model.editor.maxConcurrencyLabel') }}</label>
|
||||
<t-input v-model.number="formData.maxConcurrency" type="number" :min="0" :max="4096"
|
||||
:placeholder="$t('model.editor.maxConcurrencyPlaceholder')" />
|
||||
<p class="form-desc">{{ $t('model.editor.maxConcurrencyDesc') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</t-form>
|
||||
@@ -425,6 +437,8 @@ interface ModelFormData {
|
||||
interfaceType?: 'ollama' | 'openai'
|
||||
isDefault: boolean
|
||||
supportsVision?: boolean
|
||||
/** 后台任务对该模型的并发上限;0/undefined 表示沿用全局默认。仅 chat/embedding/vllm 生效。 */
|
||||
maxConcurrency?: number
|
||||
/** extra_config.thinking_control — how agent thinking on/off maps to API fields. */
|
||||
thinkingControl?: string
|
||||
// 自定义 HTTP 请求头(类似 OpenAI Python SDK 的 extra_headers)
|
||||
@@ -819,6 +833,7 @@ const formData = ref<ModelFormData>({
|
||||
interfaceType: 'ollama',
|
||||
isDefault: false,
|
||||
supportsVision: false,
|
||||
maxConcurrency: undefined,
|
||||
thinkingControl: defaultThinkingControl('generic', ''),
|
||||
customHeaders: [],
|
||||
appSecret: '',
|
||||
@@ -1059,6 +1074,7 @@ const resetForm = () => {
|
||||
interfaceType: undefined,
|
||||
isDefault: false,
|
||||
supportsVision: false,
|
||||
maxConcurrency: undefined,
|
||||
thinkingControl: defaultThinkingControl('generic', ''),
|
||||
customHeaders: [],
|
||||
appSecret: '',
|
||||
|
||||
@@ -3773,6 +3773,9 @@ export default {
|
||||
dimensionOverrideDesc: 'Enable only if the provider documentation says this model accepts a dimensions parameter.',
|
||||
supportsVisionLabel: 'Supports Vision / Multimodal',
|
||||
supportsVisionDesc: 'Whether the model accepts image and multimodal input',
|
||||
maxConcurrencyLabel: 'Background concurrency limit',
|
||||
maxConcurrencyPlaceholder: '0 = use global default',
|
||||
maxConcurrencyDesc: 'Caps concurrent background (ingestion/enrichment) calls to this model, shared per model across all replicas. 0 or empty falls back to the global default; interactive chat is never affected.',
|
||||
thinkingControlLabel: 'Thinking mode request format',
|
||||
thinkingControlDesc:
|
||||
'Controls how the agent’s “Thinking mode” on/off switch is written to the API. We pre-select based on vendor/model when possible; change it to match your API docs. With “Do not send”, the agent Thinking mode switch has no effect.',
|
||||
|
||||
@@ -2765,6 +2765,9 @@ export default {
|
||||
dimensionOverrideDesc: "제공자 문서에서 이 모델이 dimensions 매개변수를 지원한다고 확인한 경우에만 켜세요.",
|
||||
supportsVisionLabel: "비전/멀티모달 지원",
|
||||
supportsVisionDesc: "모델의 이미지 등 멀티모달 입력 지원 여부",
|
||||
maxConcurrencyLabel: "백그라운드 동시 실행 상한",
|
||||
maxConcurrencyPlaceholder: "0이면 전역 기본값 사용",
|
||||
maxConcurrencyDesc: "문서 인덱싱/보강 등 백그라운드 작업이 이 모델을 호출하는 동시 실행 수를 제한합니다(모델별로 모든 복제본이 공유). 0 또는 비워 두면 전역 기본값을 사용하며, 대화형 채팅에는 영향을 주지 않습니다.",
|
||||
thinkingControlLabel: "사고 모드 매개변수 형식",
|
||||
thinkingControlDesc:
|
||||
"에이전트 「사고 모드」 켜기/끄기 시 API에 어떻게 기록할지 결정합니다. 벤더/모델에 따라 미리 선택되며, 실제 API와 다르면 문서에 맞게 수정하세요. 「전송 안 함」을 선택하면 에이전트 「사고 모드」 스위치가 효과가 없습니다.",
|
||||
|
||||
@@ -2463,6 +2463,9 @@ export default {
|
||||
dimensionOverrideDesc: 'Включайте только если документация провайдера подтверждает поддержку параметра dimensions.',
|
||||
supportsVisionLabel: 'Поддержка визуального / мультимодального ввода',
|
||||
supportsVisionDesc: 'Поддерживает ли модель изображения и другой мультимодальный ввод',
|
||||
maxConcurrencyLabel: 'Лимит фоновой параллельности',
|
||||
maxConcurrencyPlaceholder: '0 — использовать глобальное значение',
|
||||
maxConcurrencyDesc: 'Ограничивает число одновременных фоновых вызовов (индексация/обогащение) к этой модели, общее для модели по всем репликам. 0 или пусто — используется глобальное значение по умолчанию; интерактивный чат не затрагивается.',
|
||||
thinkingControlLabel: 'Формат параметров режима размышления',
|
||||
thinkingControlDesc:
|
||||
'Определяет, как переключатель «Режим размышления» агента записывается в API. При возможности выбирается по поставщику/модели; при несоответствии измените по документации API. При выборе «Не отправлять» переключатель «Режим размышления» агента не действует.',
|
||||
|
||||
@@ -2787,6 +2787,9 @@ export default {
|
||||
dimensionOverrideDesc: "仅在确认该模型支持 dimensions 参数时开启;默认只使用检测到的实际维度。",
|
||||
supportsVisionLabel: "支持视觉/多模态",
|
||||
supportsVisionDesc: "模型是否支持图片等多模态输入",
|
||||
maxConcurrencyLabel: "后台并发上限",
|
||||
maxConcurrencyPlaceholder: "0 表示使用全局默认",
|
||||
maxConcurrencyDesc: "限制文档入库/富化等后台任务对该模型的并发调用数(按模型全副本共享)。0 或留空表示沿用全局默认;不影响交互式对话。",
|
||||
thinkingControlLabel: "思考模式参数格式",
|
||||
thinkingControlDesc:
|
||||
"决定智能体「思考模式」开/关时如何写入 API。已尝试按厂商/模型预选,若与实际情况不符请按 API 文档手动修改;选「不写入」时,智能体「思考模式」开关不生效。",
|
||||
|
||||
@@ -188,6 +188,7 @@ function convertToLegacyFormat(model: ModelConfig) {
|
||||
supportsDimensionOverride: model.parameters.embedding_parameters?.supports_dimension_override || false,
|
||||
isBuiltin: model.is_builtin || false,
|
||||
supportsVision: model.parameters.supports_vision || false,
|
||||
maxConcurrency: model.parameters.max_concurrency,
|
||||
customHeaders: model.parameters.custom_headers
|
||||
? Object.entries(model.parameters.custom_headers).map(([key, value]) => ({ key, value: String(value) }))
|
||||
: [],
|
||||
@@ -443,7 +444,12 @@ const handleModelSave = async (modelData: any) => {
|
||||
supports_vision: true
|
||||
} : saveType === 'chat' ? {
|
||||
supports_vision: modelData.supportsVision ?? false
|
||||
} : {})
|
||||
} : {}),
|
||||
// 后台并发上限:仅 chat/embedding/vllm 受治理,>0 才写入(0/空沿用全局默认)。
|
||||
...(['chat', 'embedding', 'vllm'].includes(saveType)
|
||||
&& Number(modelData.maxConcurrency) > 0
|
||||
? { max_concurrency: Number(modelData.maxConcurrency) }
|
||||
: {})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user