Skip to content

Commit

Permalink
test error case
Browse files Browse the repository at this point in the history
  • Loading branch information
SBrandeis committed Jan 16, 2025
1 parent be5123d commit c4d8acb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/inference/src/lib/makeRequestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function mapModel(params: { model: string; provider: InferenceProvider; taskHint
})();

if (!model) {
throw new Error(`Model ${params.model} is not supported for provider ${params.provider}`);
throw new Error(`Model ${params.model} is not supported for task ${task} and provider ${params.provider}`);
}
return model;
}
Expand Down
15 changes: 14 additions & 1 deletion packages/inference/test/HfInference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, it, describe, assert } from "vitest";

import type { ChatCompletionStreamOutput } from "@huggingface/tasks";

import { HfInference } from "../src";
import { chatCompletion, HfInference } from "../src";
import "./vcr";
import { readTestFile } from "./test-files";

Expand Down Expand Up @@ -911,4 +911,17 @@ describe.concurrent("HfInference", () => {
},
TIMEOUT
);

describe.concurrent("3rd party providers", () => {
it("chatCompletion - fails with unsupported model", async () => {
expect(
chatCompletion({
model: "black-forest-labs/Flux.1-dev",
provider: "together",
messages: [{ role: "user", content: "Complete this sentence with words, one plus one is equal " }],
accessToken: env.HF_TOGETHER_KEY
})
).rejects.toThrowError("Model black-forest-labs/Flux.1-dev is not supported for task conversational and provider together")
});
})
});

0 comments on commit c4d8acb

Please sign in to comment.