mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:11:25 +00:00
feat(agents) : Hugging Face Inference provider first-class support and Together API fix and Direct Injection Refactor Auths [AI-assisted] (#13472)
* 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>
This commit is contained in:
44
src/agents/huggingface-models.test.ts
Normal file
44
src/agents/huggingface-models.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user