refactor(models): reuse shared model key helper · openclaw/openclaw@a409df6
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,9 @@
|
2 | 2 | import { normalizeProviderId } from "@openclaw/model-catalog-core/provider-id"; |
3 | 3 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
4 | 4 | import { splitTrailingAuthProfile } from "../../agents/model-ref-profile.js"; |
| 5 | +import { modelKey } from "../../agents/model-ref-shared.js"; |
5 | 6 | import { isModelKeyAllowedBySet } from "../../agents/model-selection-shared.js"; |
| 7 | +export { modelKey }; |
6 | 8 | |
7 | 9 | /** Alias lookup tables used by `/model` directive resolution. */ |
8 | 10 | export type ModelAliasIndex = { |
@@ -59,23 +61,6 @@ const FUZZY_VARIANT_TOKENS = [
|
59 | 61 | "nano", |
60 | 62 | ]; |
61 | 63 | |
62 | | -/** Builds the canonical provider/model key used by allowlists and aliases. */ |
63 | | -export function modelKey(provider: string, model: string): string { |
64 | | -const providerId = provider.trim(); |
65 | | -const modelId = model.trim(); |
66 | | -if (!providerId) { |
67 | | -return modelId; |
68 | | -} |
69 | | -if (!modelId) { |
70 | | -return providerId; |
71 | | -} |
72 | | -return normalizeLowercaseStringOrEmpty(modelId).startsWith( |
73 | | -`${normalizeLowercaseStringOrEmpty(providerId)}/`, |
74 | | -) |
75 | | - ? modelId |
76 | | - : `${providerId}/${modelId}`; |
77 | | -} |
78 | | - |
79 | 64 | /** Resolves an explicit model directive string into a provider/model ref. */ |
80 | 65 | export function resolveModelRefFromDirectiveString(params: { |
81 | 66 | raw: string; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。