Merge pull request #3674 from code-yeongyu/fix/doctor-parse-multi-slash-model
fix(doctor): parse provider/model with indexOf for multi-slash IDs (fixes #3380)
This commit is contained in:
@@ -1,6 +1,47 @@
|
|||||||
import { describe, it, expect } from "bun:test"
|
import { describe, it, expect } from "bun:test"
|
||||||
|
|
||||||
describe("model-resolution check", () => {
|
describe("model-resolution check", () => {
|
||||||
|
describe("parseProviderModel", () => {
|
||||||
|
it("splits chutes model IDs at the provider separator", async () => {
|
||||||
|
const { parseProviderModel } = await import("./model-resolution")
|
||||||
|
|
||||||
|
// #given a provider-prefixed model whose model ID contains a slash
|
||||||
|
const value = "chutes/deepseek-ai/DeepSeek-V3.2-TEE"
|
||||||
|
|
||||||
|
// #when parsing the provider and model IDs
|
||||||
|
const result = parseProviderModel(value)
|
||||||
|
|
||||||
|
// #then only the first slash separates the provider
|
||||||
|
expect(result).toEqual({ providerID: "chutes", modelID: "deepseek-ai/DeepSeek-V3.2-TEE" })
|
||||||
|
})
|
||||||
|
|
||||||
|
it("splits simple provider model IDs", async () => {
|
||||||
|
const { parseProviderModel } = await import("./model-resolution")
|
||||||
|
|
||||||
|
// #given a provider-prefixed model without extra slashes
|
||||||
|
const value = "openai/gpt-5"
|
||||||
|
|
||||||
|
// #when parsing the provider and model IDs
|
||||||
|
const result = parseProviderModel(value)
|
||||||
|
|
||||||
|
// #then provider and model are split normally
|
||||||
|
expect(result).toEqual({ providerID: "openai", modelID: "gpt-5" })
|
||||||
|
})
|
||||||
|
|
||||||
|
it("splits synthetic provider model IDs at the provider separator", async () => {
|
||||||
|
const { parseProviderModel } = await import("./model-resolution")
|
||||||
|
|
||||||
|
// #given a synthetic provider model whose model ID contains a slash
|
||||||
|
const value = "synthetic/hf:zai-org/GLM-5.1"
|
||||||
|
|
||||||
|
// #when parsing the provider and model IDs
|
||||||
|
const result = parseProviderModel(value)
|
||||||
|
|
||||||
|
// #then only the first slash separates the provider
|
||||||
|
expect(result).toEqual({ providerID: "synthetic", modelID: "hf:zai-org/GLM-5.1" })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("getModelResolutionInfo", () => {
|
describe("getModelResolutionInfo", () => {
|
||||||
// given: Model requirements are defined in model-requirements.ts
|
// given: Model requirements are defined in model-requirements.ts
|
||||||
// when: Getting model resolution info
|
// when: Getting model resolution info
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { buildModelResolutionDetails } from "./model-resolution-details"
|
|||||||
import { buildEffectiveResolution, getEffectiveModel } from "./model-resolution-effective-model"
|
import { buildEffectiveResolution, getEffectiveModel } from "./model-resolution-effective-model"
|
||||||
import type { AgentResolutionInfo, CategoryResolutionInfo, ModelResolutionInfo, OmoConfig } from "./model-resolution-types"
|
import type { AgentResolutionInfo, CategoryResolutionInfo, ModelResolutionInfo, OmoConfig } from "./model-resolution-types"
|
||||||
|
|
||||||
function parseProviderModel(value: string): { providerID: string; modelID: string } | null {
|
export function parseProviderModel(value: string): { providerID: string; modelID: string } | null {
|
||||||
const slashIndex = value.lastIndexOf("/")
|
const slashIndex = value.indexOf("/")
|
||||||
if (slashIndex <= 0 || slashIndex === value.length - 1) {
|
if (slashIndex <= 0 || slashIndex === value.length - 1) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user