























@@ -5,7 +5,7 @@ import {
55resolveDefaultMediaModel,
66} from "../../media-understanding/defaults.js";
77import type { AuthProfileStore } from "../auth-profiles/types.js";
8-import { isMinimaxVlmProvider } from "../minimax-vlm.js";
8+import { isMinimaxVlmModel, isMinimaxVlmProvider } from "../minimax-vlm.js";
99import {
1010coerceImageModelConfig,
1111type ImageModelConfig,
@@ -55,6 +55,78 @@ function resolveImageCandidateRefs(params: {
5555.filter((value): value is string => Boolean(value));
5656}
575758+function formatProviderModelRef(providerId: string, modelId: string): string {
59+const slash = modelId.indexOf("/");
60+if (slash > 0 && modelId.slice(0, slash).trim() === providerId) {
61+return modelId;
62+}
63+return `${providerId}/${modelId}`;
64+}
65+66+function isMinimaxVlmModelRef(ref: string): boolean {
67+const slash = ref.indexOf("/");
68+if (slash <= 0) {
69+return false;
70+}
71+return isMinimaxVlmModel(ref.slice(0, slash), ref.slice(slash + 1));
72+}
73+74+function resolveMinimaxTextExtractionCandidateRefs(params: {
75+cfg?: OpenClawConfig;
76+primary: { provider: string; model: string };
77+primaryProviderOk: boolean;
78+agentDir: string;
79+authStore?: AuthProfileStore;
80+}): string[] {
81+const candidates: string[] = [];
82+const addCandidate = (providerId: string, modelId: string) => {
83+const provider = providerId.trim();
84+const model = modelId.trim();
85+if (!provider || !model || isMinimaxVlmModel(provider, model)) {
86+return;
87+}
88+const ref = formatProviderModelRef(provider, model);
89+if (!candidates.includes(ref)) {
90+candidates.push(ref);
91+}
92+};
93+94+if (params.primaryProviderOk && isMinimaxVlmProvider(params.primary.provider)) {
95+addCandidate(params.primary.provider, params.primary.model);
96+}
97+98+const providers = params.cfg?.models?.providers;
99+if (!providers || typeof providers !== "object") {
100+return candidates;
101+}
102+103+for (const [providerKey, providerCfg] of Object.entries(providers)) {
104+const providerId = providerKey.trim();
105+if (
106+!providerId ||
107+!isMinimaxVlmProvider(providerId) ||
108+!hasAuthForProvider({
109+provider: providerId,
110+agentDir: params.agentDir,
111+authStore: params.authStore,
112+})
113+) {
114+continue;
115+}
116+const modelId = (providerCfg?.models ?? [])
117+.find((model) => {
118+const id = model?.id?.trim();
119+return Boolean(id) && Array.isArray(model?.input) && model.input.includes("text");
120+})
121+?.id?.trim();
122+if (modelId) {
123+addCandidate(providerId, modelId);
124+}
125+}
126+127+return candidates;
128+}
129+58130export function resolvePdfModelConfigForTool(params: {
59131cfg?: OpenClawConfig;
60132agentDir: string;
@@ -138,6 +210,13 @@ export function resolvePdfModelConfigForTool(params: {
138210agentDir: params.agentDir,
139211workspaceDir: params.workspaceDir,
140212authStore: params.authStore,
213+}).filter((ref) => !isMinimaxVlmModelRef(ref));
214+const minimaxTextExtractionCandidates = resolveMinimaxTextExtractionCandidateRefs({
215+cfg: params.cfg,
216+ primary,
217+primaryProviderOk: providerOk,
218+agentDir: params.agentDir,
219+authStore: params.authStore,
141220});
142221143222if (params.cfg?.models?.providers && typeof params.cfg.models.providers === "object") {
@@ -180,11 +259,19 @@ export function resolvePdfModelConfigForTool(params: {
180259} else if (providerOk && primarySupportsNativePdf && (providerVision || providerDefault)) {
181260preferred = providerVision ?? `${primary.provider}/${providerDefault}`;
182261} else {
183-preferred = nativePdfCandidates[0] ?? genericImageCandidates[0] ?? null;
262+preferred =
263+nativePdfCandidates[0] ??
264+minimaxTextExtractionCandidates[0] ??
265+genericImageCandidates[0] ??
266+null;
184267}
185268186269if (preferred?.trim()) {
187-for (const candidate of [...nativePdfCandidates, ...genericImageCandidates]) {
270+for (const candidate of [
271+ ...nativePdfCandidates,
272+ ...minimaxTextExtractionCandidates,
273+ ...genericImageCandidates,
274+]) {
188275if (candidate !== preferred) {
189276addFallback(candidate);
190277}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。