Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/api/src/opendirector_api/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
chooses an English message from the stable error code when the caller asks for
English, so a missing translation never leaks Chinese into an English UI.
"""
import re

from fastapi import Request


Expand Down Expand Up @@ -98,6 +100,7 @@
"role_restricted": "This item does not allow that operation.",
"storage_unavailable": "A stored file is missing or has changed. Restore the file and try again.",
"capability_unsupported": "This capability is not supported yet.",
"model_list_http_error": "Could not load the model list from the service.",
"operation_rejected": "The operation was rejected. Reload the item and try again.",
"storage_busy": "Project storage is busy. Try again shortly.",
"project_open_elsewhere": "This project is open in another window. Close it there and try again.",
Expand Down Expand Up @@ -150,6 +153,10 @@ def localized_error_for_language(
return chinese
if code == 'tool_model_missing':
return missing_tool_model_message(required_capability, english=True)
if code == 'model_list_http_error':
upstream_status = re.search(r'HTTP ([0-9]{3})', chinese)
if upstream_status:
return f'Could not load the model list (HTTP {upstream_status[1]}).'
if code.startswith(('capability_', 'image_input_', 'tool_source_')):
translated = english_capability_message(chinese)
if translated:
Expand Down
3 changes: 2 additions & 1 deletion docs/development/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,13 @@ Zhipu BigModel chat access uses the following checks. Browser commands connect t
```sh
.venv/bin/python -m pytest tests/test_zhipu.py tests/test_model_configs.py -q
node --test tests/providerPresets.test.ts
CREATION_API_URL=http://127.0.0.1:8019 CREATION_WEB_URL=http://127.0.0.1:5179 node tests/browser/new_model_discovery.mjs
CREATION_API_URL=http://127.0.0.1:8019 CREATION_WEB_URL=http://127.0.0.1:5179 node tests/browser/zhipu_provider.mjs
```

The Python cases check how the shared thinking levels map to GLM reasoning_effort. GLM accepts only low, high and max for reasoning_effort. The auto level omits the parameter so the provider default applies, and an unknown level falls back to high as in the DeepSeek branch. Other hosts and the DeepSeek behavior stay unchanged.

The browser case checks both display languages for the provider list and names, canonical URL prefill, GLM model preselection without remote discovery, manual addition of other model IDs, the saved connection reuse hint, save and reopen, key privacy in public model responses, and the assistant agent picker listing and keeping the selected Zhipu model. The browser never contacts open.bigmodel.cn and the API key is always a fixture value. Real streaming conversations, tool call execution and thinking level effects additionally require valid Zhipu credentials. Keep the conversation transcript, tool receipts and screenshots as evidence.
The **New model discovery** case runs on its own with the isolated API and Vite. It verifies that a model absent from the preset appears after an authenticated `GET /models`, can be selected and saved, and remains selectable in the assistant. The **Zhipu model settings feedback** case checks both display languages for missing credentials, request progress, upstream failure, retry, empty responses, manual entry, and audio preset isolation. Both cases use local HTTP fixtures and synthetic keys. Real streaming conversations, tool calls, and thinking levels require a separate run with valid Zhipu credentials.

智谱 BigModel GLM-TTS 接入使用以下检查:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Read an optional, explicit videoCapabilities extension on GET /models."""
"""Read service model lists and resolve video capabilities."""
import json
import logging

Expand All @@ -23,18 +23,20 @@ async def read_service_models(config, transport=None):
return [{'id': name, 'videoCapabilities': kling_capabilities(name)} for name in KLING_MODELS]
if config.get('protocol') == 'minimax_video_v2':
return [{'id': name} for name in MINIMAX_MODELS]
is_text_model = config.get('kind') == 'agent'
try:
async with httpx.AsyncClient(event_hooks=MODEL_HTTP_HOOKS, transport=transport, trust_env=trust_environment(config['url'], config=config),
timeout=15, follow_redirects=False) as client:
async with client.stream('GET', endpoint(config['url'], '/models'), headers=auth_headers(config)) as response:
if response.status_code != 200:
raise ProjectError(f'读取模型声明失败(HTTP {response.status_code}),未修改配置。')
raise ProjectError(f'读取模型声明失败(HTTP {response.status_code}),未修改配置。',
code='model_list_http_error' if is_text_model else None)
data = bytearray()
async for chunk in response.aiter_bytes():
data.extend(chunk)
if len(data) > 1024 * 1024:
raise ProjectError('模型声明超过 1 MB,未修改配置。')
models = json.loads(data).get('data', [])
models = json.loads(data).get('data', None if is_text_model else [])
if not isinstance(models, list) or any(not isinstance(item, dict) or not isinstance(item.get('id'), str)
or not item['id'].strip() or len(item['id']) > 200 for item in models):
raise ProjectError('服务返回的模型列表格式无效。')
Expand Down
2 changes: 2 additions & 0 deletions scripts/run-browser-suite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const workflows = [
},
{ name: "minimax h3", script: "tests/browser/minimax_h3.mjs" },
{ name: "provider settings", script: "tests/browser/provider_settings.mjs" },
{ name: "new model discovery", script: "tests/browser/new_model_discovery.mjs" },
{ name: "Zhipu model settings feedback", script: "tests/browser/zhipu_provider.mjs" },
{ name: "capability discovery", script: "tests/browser/capability_discovery.mjs" },
{ name: "created node focus", script: "tests/browser/created_node_focus.mjs" },
{ name: "cross canvas paste", script: "tests/browser/cross_canvas_paste.mjs" },
Expand Down
42 changes: 25 additions & 17 deletions src/canvas/ModelPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function ModelPicker({
selected,
loaded,
loading,
loadsPreset,
error,
disabled,
canFetch,
Expand All @@ -22,13 +23,13 @@ export function ModelPicker({
onTest,
results,
renderDetails,
fetchLabel,
}: {
modelPlaceholder: string;
available: string[];
selected: string[];
loaded: boolean;
loading: boolean;
loadsPreset: boolean;
error: string;
disabled: boolean;
canFetch: boolean;
Expand All @@ -37,7 +38,6 @@ export function ModelPicker({
onTest?: (id: string) => void;
results: Record<string, ModelTestResult>;
renderDetails?: (id: string) => ReactNode;
fetchLabel?: string;
}) {
const t = useT();
const manualFieldId = useId();
Expand All @@ -55,6 +55,17 @@ export function ModelPicker({
);
const allSelected =
visible.length > 0 && visible.every((id) => selected.includes(id));
const fetchLabel = loadsPreset
? "models.service.loadSupportedModels"
: loaded ? "generation.picker.refresh" : "generation.picker.fetch";
let status = "";
if (loading) {
status = t("generation.picker.fetching");
} else if (loaded && !error) {
status = available.length
? t(loadsPreset ? "generation.picker.loadedPreset" : "generation.picker.fetched", { count: available.length })
: t("generation.picker.noReturned");
}
const addManual = () => {
const id = manualId.trim();
if (!id || id.length > 200 || /[\x00-\x1f]/.test(id)) {
Expand Down Expand Up @@ -101,18 +112,21 @@ export function ModelPicker({
<button
type="button"
className="cw-settings-button"
disabled={disabled || !canFetch}
disabled={disabled}
onClick={onFetch}
>
{loading
? t("generation.picker.loading")
: (fetchLabel ??
(loaded
? t("generation.picker.refresh")
: t("generation.picker.fetch")))}
{t(loading ? "generation.picker.loading" : fetchLabel)}
</button>
</div>
</div>
<div role="status">
{status && <p className="cw-model-note">{status}</p>}
</div>
{error && (
<p className="cw-model-feedback" role="alert">
{error}
</p>
)}
{manualOpen && (
<div className="cw-model-manual">
<label htmlFor={manualFieldId}>
Expand Down Expand Up @@ -160,11 +174,6 @@ export function ModelPicker({
)}
</div>
)}
{error && (
<p className="cw-model-feedback" role="alert">
{t("generation.picker.retry", { error })}
</p>
)}
{ids.length > 4 && (
<>
<div className="cw-model-filterbar">
Expand Down Expand Up @@ -209,15 +218,14 @@ export function ModelPicker({
)}
<div className="cw-model-options" aria-busy={loading}>
{loading && !ids.length ? (
<div className="cw-model-empty-state" role="status">
<div className="cw-model-empty-state">
<span className="cw-model-spinner" />
<strong>{t("generation.picker.fetching")}</strong>
<p>{t("generation.picker.connecting")}</p>
</div>
) : !ids.length ? (
<div className="cw-model-empty-state">
<CanvasIcon name="model" size={26} />
<strong>{loaded ? t("generation.picker.noReturned") : t("generation.picker.noneAdded")}</strong>
{!loaded && <strong>{t("generation.picker.noneAdded")}</strong>}
<p>
{loaded
? t("generation.picker.manualHint")
Expand Down
37 changes: 21 additions & 16 deletions src/canvas/ModelServiceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,19 @@ export function ModelServiceForm({
const segmentation = value.protocol === "vllm_omni_segmentation";
const depth = value.protocol === "vllm_omni_depth";
const score = value.protocol === "vllm_omni_score";
const preset = PROVIDER_PRESETS.find((item) => item.id === presetId);
const mediaPresetModels = kind === "agent" ? undefined : preset?.modelsByKind?.[kind];
const hasSavedKey = Boolean(
connection &&
connection.authMode === "bearer" &&
connection.url === value.url.trim(),
);
const canFetch = Boolean(
value.url.trim() &&
(value.authMode === "none" || value.apiKey.trim() || hasSavedKey),
);
const fetchPrerequisite = !value.url.trim()
? "generation.picker.addressRequired"
: value.authMode === "bearer" && !value.apiKey.trim() && !hasSavedKey
? "generation.picker.keyRequired"
: null;
const canFetch = fetchPrerequisite === null;
const canSave = canFetch && selectedModels.length > 0 && selectedModels.length <= 200 &&
!selectedTestFailed && !selectedModels.some((id) => modelErrors[id]);
const update = (patch: Partial<ModelConfigInput>) => {
Expand All @@ -174,7 +178,7 @@ export function ModelServiceForm({
patch.protocol !== undefined ||
patch.connectionType !== undefined ||
patch.authMode !== undefined;
if (connectionChanged) {
if (connectionChanged || patch.proxyMode !== undefined) {
setModelIds(selectedModels);
setLoaded(false);
setDiscoveryError("");
Expand All @@ -198,20 +202,23 @@ export function ModelServiceForm({
setError("");
};
const loadModels = async () => {
if (fetchPrerequisite) {
setDiscoveryError(t(fetchPrerequisite));
if (fetchPrerequisite === "generation.picker.addressRequired") setConnectionOpen(true);
return;
}
setDiscovering(true);
setDiscoveryError("");
try {
const preset = PROVIDER_PRESETS.find((item) => item.id === presetId);
const presetModels = preset?.modelsByKind?.[kind];
const models = presetModels
? [...presetModels]
const models = mediaPresetModels
? [...mediaPresetModels]
: (await discoverModels(value, connection?.id)).models;
setModelIds(models);
if (presetModels && !connection) setSelectedModels(models);
if (mediaPresetModels && !connection) setSelectedModels(models);
setLoaded(true);
setConnectionOpen(false);
} catch (failure) {
setDiscoveryError(errorMessage(failure));
setDiscoveryError(t("generation.picker.retry", { error: errorMessage(failure) }));
} finally {
setDiscovering(false);
}
Expand Down Expand Up @@ -320,6 +327,8 @@ export function ModelServiceForm({
);
setSelectedModels(peers.map((item) => item.modelId));
setModelIds(peers.map((item) => item.modelId));
setLoaded(false);
setDiscoveryError("");
setModelOptions({});
setModelErrors({});
setResults({});
Expand Down Expand Up @@ -524,6 +533,7 @@ export function ModelServiceForm({
selected={selectedModels}
loaded={loaded}
loading={discovering}
loadsPreset={Boolean(mediaPresetModels)}
error={discoveryError}
disabled={locked}
canFetch={canFetch}
Expand All @@ -534,11 +544,6 @@ export function ModelServiceForm({
}}
onTest={kind === "agent" ? (id) => void test(id) : undefined}
results={results}
fetchLabel={
PROVIDER_PRESETS.find((item) => item.id === presetId)?.modelsByKind?.[kind]
? t("models.service.loadSupportedModels")
: undefined
}
renderDetails={(id) => (
<>
<DraftAvailabilityCheck connection={{ ...value, ...optionsFor(id) }} configId={connection?.id} modelId={id} />
Expand Down
10 changes: 10 additions & 0 deletions src/i18n/messages/en-US/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export const generation = {
"generation.picker.modelId": "Model ID (the service's served-model-name)",
"generation.picker.add": "Add",
"generation.picker.cancel": "Cancel",
"generation.picker.addressRequired": "Enter the service address first.",
"generation.picker.keyRequired": "Enter an API Key first.",
"generation.picker.retry": "{error} You can retry or add a model manually.",
"generation.picker.search": "Search models",
"generation.picker.searchPlaceholder": "Search model names…",
Expand All @@ -227,6 +229,14 @@ export const generation = {
"generation.picker.selectAll": "Select all current results",
"generation.picker.deselectAll": "Deselect all",
"generation.picker.fetching": "Fetching the model list",
"generation.picker.fetched": {
one: "{count} model fetched",
other: "{count} models fetched",
},
"generation.picker.loadedPreset": {
one: "{count} preset model loaded",
other: "{count} preset models loaded",
},
"generation.picker.connecting": "Connecting to the service…",
"generation.picker.noReturned": "The service returned no models",
"generation.picker.noneAdded": "No models added yet",
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/messages/zh-CN/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ export const generation = {
"generation.picker.modelId": "Model ID(服务的 served-model-name)",
"generation.picker.add": "添加",
"generation.picker.cancel": "取消",
"generation.picker.addressRequired": "请先填写服务地址。",
"generation.picker.keyRequired": "请先填写 API Key。",
"generation.picker.retry": "{error} 可重试或手动添加模型。",
"generation.picker.search": "搜索模型",
"generation.picker.searchPlaceholder": "搜索模型名称…",
Expand All @@ -209,6 +211,8 @@ export const generation = {
"generation.picker.selectAll": "全选当前结果",
"generation.picker.deselectAll": "取消当前全选",
"generation.picker.fetching": "正在获取模型列表",
"generation.picker.fetched": "已获取 {count} 个模型",
"generation.picker.loadedPreset": "已载入 {count} 个预设模型",
"generation.picker.connecting": "正在连接服务,请稍候…",
"generation.picker.noReturned": "服务未返回模型",
"generation.picker.noneAdded": "尚未添加模型",
Expand Down
18 changes: 16 additions & 2 deletions tests/browser/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,26 @@
],
"note": "Runs with voice_library_server.py in the Release checks voice library phase."
},
{
"file": "new_model_discovery.mjs",
"previewSafe": true,
"lanes": [
"gate"
],
"note": "Discovers a new text model from a loopback GET /models service, saves it, and selects it in the assistant."
},
{
"file": "zhipu_catalog_fixture.mjs",
"helper": true,
"note": "Shared loopback catalog fixture for the new-model and Zhipu feedback tests."
},
{
"file": "zhipu_provider.mjs",
"previewSafe": true,
"lanes": [
"extended"
]
"gate"
],
"note": "Bilingual catalog feedback, retry and empty responses, and Zhipu audio preset isolation."
},
{
"file": "kimi_real.mjs",
Expand Down
Loading
Loading