mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 04:20:44 +00:00
* initial commit * removes assesment from docs * resolves automated review comments * resolves lint , type , tests , refactors , and submits * solves : why do we have to lint the tests xD * adds greptile fixes * solves a type error * solves a ci error * refactors auths * solves a failing test after i pulled from main lol * solves a failing test after i pulled from main lol * resolves token naming issue to comply with better practices when using hf / huggingface * fixes curly lints ! * fixes failing tests for google api from main * solve merge conflicts * solve failing tests with a defensive check 'undefined' openrouterapi key * fix: preserve Hugging Face auth-choice intent and token behavior (#13472) (thanks @Josephrp) * test: resolve auth-choice cherry-pick conflict cleanup (#13472) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
discoverHuggingfaceModels,
|
|
HUGGINGFACE_MODEL_CATALOG,
|
|
buildHuggingfaceModelDefinition,
|
|
isHuggingfacePolicyLocked,
|
|
} from "./huggingface-models.js";
|
|
|
|
describe("huggingface-models", () => {
|
|
it("buildHuggingfaceModelDefinition returns config with required fields", () => {
|
|
const entry = HUGGINGFACE_MODEL_CATALOG[0];
|
|
const def = buildHuggingfaceModelDefinition(entry);
|
|
expect(def.id).toBe(entry.id);
|
|
expect(def.name).toBe(entry.name);
|
|
expect(def.reasoning).toBe(entry.reasoning);
|
|
expect(def.input).toEqual(entry.input);
|
|
expect(def.cost).toEqual(entry.cost);
|
|
expect(def.contextWindow).toBe(entry.contextWindow);
|
|
expect(def.maxTokens).toBe(entry.maxTokens);
|
|
});
|
|
|
|
it("discoverHuggingfaceModels returns static catalog when apiKey is empty", async () => {
|
|
const models = await discoverHuggingfaceModels("");
|
|
expect(models).toHaveLength(HUGGINGFACE_MODEL_CATALOG.length);
|
|
expect(models.map((m) => m.id)).toEqual(HUGGINGFACE_MODEL_CATALOG.map((m) => m.id));
|
|
});
|
|
|
|
it("discoverHuggingfaceModels returns static catalog in test env (VITEST)", async () => {
|
|
const models = await discoverHuggingfaceModels("hf_test_token");
|
|
expect(models).toHaveLength(HUGGINGFACE_MODEL_CATALOG.length);
|
|
expect(models[0].id).toBe("deepseek-ai/DeepSeek-R1");
|
|
});
|
|
|
|
describe("isHuggingfacePolicyLocked", () => {
|
|
it("returns true for :cheapest and :fastest refs", () => {
|
|
expect(isHuggingfacePolicyLocked("huggingface/deepseek-ai/DeepSeek-R1:cheapest")).toBe(true);
|
|
expect(isHuggingfacePolicyLocked("huggingface/deepseek-ai/DeepSeek-R1:fastest")).toBe(true);
|
|
});
|
|
it("returns false for base ref and :provider refs", () => {
|
|
expect(isHuggingfacePolicyLocked("huggingface/deepseek-ai/DeepSeek-R1")).toBe(false);
|
|
expect(isHuggingfacePolicyLocked("huggingface/foo:together")).toBe(false);
|
|
});
|
|
});
|
|
});
|