refactor: drop legacy compatibility fallbacks and strictly structure config under 1h-tools
This commit is contained in:
1 parent
69877803ca
commit
ffe71f24b4
6 files changed
+10
-137
No files matched your search
+3
-33
@@ -64,40 +64,10 @@ export function resolveImageConfig(
|
||||
cfg: ImageGenerationRequest["cfg"] | undefined,
|
||||
apiPluginConfig?: Record<string, unknown>,
|
||||
): ImagePluginConfig | undefined {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
||||
| {
|
||||
image?: ImagePluginConfig;
|
||||
baseUrl?: string;
|
||||
apiKey?: string | SecretRefObject;
|
||||
defaultModel?: string;
|
||||
models?: string[];
|
||||
allowPrivateNetwork?: boolean;
|
||||
}
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||
| { image?: ImagePluginConfig }
|
||||
| undefined;
|
||||
|
||||
const legacyConfig = (
|
||||
cfg?.plugins?.entries?.["openai-image"]?.config ??
|
||||
cfg?.plugins?.entries?.["bifrost-image"]?.config
|
||||
) as ImagePluginConfig | undefined;
|
||||
|
||||
const directImageConfig = toolsConfig?.image;
|
||||
const flatToolsConfig: ImagePluginConfig | undefined = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directImageConfig,
|
||||
};
|
||||
return config?.image;
|
||||
}
|
||||
|
||||
export function resolveConfiguredImageBaseUrl(
|
||||
|
||||
@@ -53,8 +53,6 @@ OpenClaw 视频生成驱动模块,适配标准 **OpenAI Videos API**(`/v1/vi
|
||||
}
|
||||
```
|
||||
|
||||
> **向下兼容提示**:插件仍完全兼容旧版独立插件 `plugins.entries["openai-video"].config` 的配置路径,迁移期间无需强行改动旧配置即可直接读取。
|
||||
|
||||
---
|
||||
|
||||
## 使用方法
|
||||
|
||||
+3
-23
@@ -75,30 +75,10 @@ export function resolveVideoConfig(
|
||||
cfg: VideoGenerationRequest["cfg"] | undefined,
|
||||
apiPluginConfig?: Record<string, unknown>,
|
||||
): VideoPluginConfig | undefined {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
||||
| { video?: VideoPluginConfig; baseUrl?: string; apiKey?: string | SecretRefObject; defaultModel?: string; models?: string[]; allowPrivateNetwork?: boolean }
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||
| { video?: VideoPluginConfig }
|
||||
| undefined;
|
||||
|
||||
const legacyConfig = cfg?.plugins?.entries?.["openai-video"]?.config as VideoPluginConfig | undefined;
|
||||
|
||||
const directVideoConfig = toolsConfig?.video;
|
||||
const flatToolsConfig: VideoPluginConfig | undefined = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directVideoConfig,
|
||||
};
|
||||
return config?.video;
|
||||
}
|
||||
|
||||
export function resolveConfiguredOpenAIBaseUrl(
|
||||
|
||||
Reference in new issue
Block a user