Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ await client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' },

### Timeouts

Requests time out after 1 minute by default. You can configure this with a `timeout` option:
Requests time out after 3 minutes by default. You can configure this with a `timeout` option:

<!-- prettier-ignore -->
```ts
// Configure the default for all requests:
const client = new Writer({
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
timeout: 20 * 1000, // 20 seconds (default is 3 minutes)
});

// Override per-request:
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export abstract class APIClient {
constructor({
baseURL,
maxRetries = 2,
timeout = 60000, // 1 minute
timeout = 180000, // 3 minutes
httpAgent,
fetch: overridenFetch,
}: {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class Writer extends Core.APIClient {
*
* @param {string | undefined} [opts.apiKey=process.env['WRITER_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['WRITER_BASE_URL'] ?? https://api.writer.com] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.timeout=3 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
Expand All @@ -167,7 +167,7 @@ export class Writer extends Core.APIClient {

super({
baseURL: options.baseURL!,
timeout: options.timeout ?? 60000 /* 1 minute */,
timeout: options.timeout ?? 180000 /* 3 minutes */,
httpAgent: options.httpAgent,
maxRetries: options.maxRetries,
fetch: options.fetch,
Expand Down Expand Up @@ -202,7 +202,7 @@ export class Writer extends Core.APIClient {
}

static Writer = this;
static DEFAULT_TIMEOUT = 60000; // 1 minute
static DEFAULT_TIMEOUT = 180000; // 3 minutes

static WriterError = Errors.WriterError;
static APIError = Errors.APIError;
Expand Down