File size: 2,198 Bytes
246d201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import { describe, it, expect } from "vitest";
import { extractModelAndProvider } from "../../src/utils/extract-model-and-provider";
describe("extractModelAndProvider", () => {
it("should work", () => {
expect(extractModelAndProvider("azure/ada")).toEqual({
provider: "azure",
model: "ada",
separator: "/",
});
expect(
extractModelAndProvider("azure/standard/1024-x-1024/dall-e-2"),
).toEqual({
provider: "azure",
model: "standard/1024-x-1024/dall-e-2",
separator: "/",
});
expect(extractModelAndProvider("vertex_ai_beta/chat-bison")).toEqual({
provider: "vertex_ai_beta",
model: "chat-bison",
separator: "/",
});
expect(extractModelAndProvider("cohere.command-r-v1:0")).toEqual({
provider: "cohere",
model: "command-r-v1:0",
separator: ".",
});
expect(
extractModelAndProvider(
"cloudflare/@cf/mistral/mistral-7b-instruct-v0.1",
),
).toEqual({
provider: "cloudflare",
model: "@cf/mistral/mistral-7b-instruct-v0.1",
separator: "/",
});
expect(extractModelAndProvider("together-ai-21.1b-41b")).toEqual({
provider: "",
model: "together-ai-21.1b-41b",
separator: "",
});
});
it("should add provider for popular models", () => {
expect(extractModelAndProvider("gpt-4o-mini")).toEqual({
provider: "openai",
model: "gpt-4o-mini",
separator: "/",
});
expect(extractModelAndProvider("gpt-4o")).toEqual({
provider: "openai",
model: "gpt-4o",
separator: "/",
});
expect(extractModelAndProvider("claude-3-5-sonnet-20240620")).toEqual({
provider: "anthropic",
model: "claude-3-5-sonnet-20240620",
separator: "/",
});
expect(extractModelAndProvider("claude-3-haiku-20240307")).toEqual({
provider: "anthropic",
model: "claude-3-haiku-20240307",
separator: "/",
});
expect(extractModelAndProvider("claude-2.1")).toEqual({
provider: "anthropic",
model: "claude-2.1",
separator: "/",
});
});
});
|