mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-07 02:07:47 +08:00
The "Fetch models" button asks the provider for its models (OpenAI-style /models, Anthropic, Google, Ollama, OpenRouter, Vercel Gateway, AIHubMix) and shows them in a searchable picker. This replaces the route that only worked for AIHubMix. A snapshot of models.dev (MIT) says which models support tool calls. Models without them get a "no tool calls" badge in the picker and a hint in the model list, since drawing needs tool calls. Refresh the snapshot with scripts/update-model-catalog.mjs.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
import { getModelInfo } from "@/lib/model-catalog"
|
|
import catalog from "@/lib/model-catalog.json"
|
|
|
|
describe("getModelInfo", () => {
|
|
it("finds a model by its exact id, ignoring case", () => {
|
|
const id = Object.keys(catalog.openai).find((m) => m === "gpt-4.1")
|
|
expect(id).toBe("gpt-4.1")
|
|
expect(getModelInfo("openai", "GPT-4.1")).toEqual(
|
|
catalog.openai["gpt-4.1"],
|
|
)
|
|
})
|
|
|
|
it("finds a dated or tagged variant by the longest id it starts with", () => {
|
|
expect(getModelInfo("openai", "gpt-4.1-2025-04-14")).toEqual(
|
|
catalog.openai["gpt-4.1"],
|
|
)
|
|
})
|
|
|
|
it("does not match a different model that shares a prefix", () => {
|
|
// gpt-4.1-mini is its own entry, not gpt-4.1
|
|
expect(getModelInfo("openai", "gpt-4.1-mini")).toEqual(
|
|
catalog.openai["gpt-4.1-mini"],
|
|
)
|
|
expect(getModelInfo("openai", "gpt-4.1x")).toBeUndefined()
|
|
})
|
|
|
|
it("knows nothing about providers models.dev does not list", () => {
|
|
expect(getModelInfo("sglang", "anything")).toBeUndefined()
|
|
expect(getModelInfo("openai", "not-a-model")).toBeUndefined()
|
|
})
|
|
})
|