mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-02 02:58:10 +02:00
Narrow provider status errors with Predicate
This commit is contained in:
parent
b3aaa9a4af
commit
b51dc33786
3 changed files with 39 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect, it } from "@effect/vitest";
|
||||
import type { LlmChunk } from "@trustgraph/base";
|
||||
import { providerRuntimeError, toAsyncGenerator } from "../model/text-completion/common.js";
|
||||
import { providerRuntimeError, providerStatusError, toAsyncGenerator } from "../model/text-completion/common.js";
|
||||
|
||||
const emptyChunkIterator = (): AsyncIterable<LlmChunk> => ({
|
||||
[Symbol.asyncIterator]: () => ({
|
||||
|
|
@ -9,6 +9,18 @@ const emptyChunkIterator = (): AsyncIterable<LlmChunk> => ({
|
|||
});
|
||||
|
||||
describe("text completion common helpers", () => {
|
||||
it("maps provider rate-limit status fields to tagged retry errors", () => {
|
||||
expect(providerStatusError("test-provider", { status: 429 })).toMatchObject({
|
||||
_tag: "TooManyRequestsError",
|
||||
message: "Rate limit exceeded",
|
||||
});
|
||||
|
||||
expect(providerStatusError("test-provider", { statusCode: 429 })).toMatchObject({
|
||||
_tag: "TooManyRequestsError",
|
||||
message: "Rate limit exceeded",
|
||||
});
|
||||
});
|
||||
|
||||
it("maps fallback generator throw failures into tagged provider errors", async () => {
|
||||
const generator = toAsyncGenerator(
|
||||
emptyChunkIterator(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue