Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,11 @@ export abstract class BaseLLM implements ILLM {
);
}
}
return new Error(
const error = new Error(
`HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}`,
);
) as any;
error.response = resp;
return error;
}

fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
Expand Down Expand Up @@ -543,7 +545,7 @@ export abstract class BaseLLM implements ILLM {
};
return withExponentialBackoff<Response>(
() => customFetch(url, init) as any,
5,
8,
0.5,
);
}
Expand Down
6 changes: 3 additions & 3 deletions core/util/withExponentialBackoff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RETRY_AFTER_HEADER,
} from "./withExponentialBackoff";

describe.skip("withExponentialBackoff", () => {
describe("withExponentialBackoff", () => {
it("should return result when apiCall succeeds on first attempt", async () => {
// Arrange
const apiCall = jest.fn().mockResolvedValue("Success");
Expand Down Expand Up @@ -112,7 +112,7 @@ describe.skip("withExponentialBackoff", () => {
// Act & Assert
await expect(
withExponentialBackoff(apiCall, maxTries, initialDelaySeconds),
).rejects.toThrow("Failed to make API call after max tries");
).rejects.toThrow(`Failed to make API call after ${maxTries} retries`);

expect(apiCall).toHaveBeenCalledTimes(maxTries);
});
Expand All @@ -135,7 +135,7 @@ describe.skip("withExponentialBackoff", () => {

await expect(
withExponentialBackoff(apiCall, maxTries, initialDelaySeconds),
).rejects.toThrow("Failed to make API call after max tries");
).rejects.toThrow(`Failed to make API call after ${maxTries} retries`);

expect(apiCall).toHaveBeenCalledTimes(0);
});
Expand Down
1 change: 1 addition & 0 deletions packages/openai-adapters/src/apis/OpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class OpenAIApi implements BaseLlmApi {
baseURL: this.apiBase,
fetch: customFetch(config.requestOptions),
timeout: config?.requestOptions?.timeout || undefined,
maxRetries: 8,
});
}
modifyChatBody<T extends ChatCompletionCreateParams>(body: T): T {
Expand Down
Loading