Skip to content

Commit

Permalink
added BACKOFF_RETRY_LIMIT env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Knar33 committed Oct 20, 2023
1 parent c2e385d commit c2136f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export const AGENT_RESPONSE_TIMEOUT_MSEC =

export const CLOUD_AGENT_KEY = getVarForEnvironment('CLOUD_AGENT_KEY') || v4()

export const BACKOFF_RETRY_LIMIT = Number(
getVarForEnvironment('BACKOFF_RETRY_LIMIT') || 0
)

export const AWS_ACCESS_KEY = getVarForEnvironment('AWS_ACCESS_KEY') || ''
export const AWS_SECRET_KEY = getVarForEnvironment('AWS_SECRET_KEY') || ''
export const AWS_REGION = getVarForEnvironment('AWS_REGION') || ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
} from '@magickml/core'
import axios from 'axios'
import { OPENAI_ENDPOINT } from '../constants'
import { DEFAULT_OPENAI_KEY, PRODUCTION } from '@magickml/config'
import {
DEFAULT_OPENAI_KEY,
PRODUCTION,
BACKOFF_RETRY_LIMIT,
} from '@magickml/config'
import { GPT4_MODELS } from '@magickml/plugin-openai-shared'
import { trackOpenAIUsage } from '@magickml/server-core'
import axiosRetry from 'axios-retry'
Expand Down Expand Up @@ -112,7 +116,7 @@ export async function makeChatCompletion(
try {
// Exponential back-off retry delay between requests
axiosRetry(axios, {
retries: 5,
retries: BACKOFF_RETRY_LIMIT,
retryDelay: axiosRetry.exponentialDelay,
shouldResetTimeout: true,
retryCondition: error => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import { CompletionHandlerInputData, saveRequest } from '@magickml/core'
import axios from 'axios'
import { OPENAI_ENDPOINT } from '../constants'
import { DEFAULT_OPENAI_KEY, PRODUCTION } from '@magickml/config'
import {
DEFAULT_OPENAI_KEY,
PRODUCTION,
BACKOFF_RETRY_LIMIT,
} from '@magickml/config'
import { GPT4_MODELS } from '@magickml/plugin-openai-shared'
import { trackOpenAIUsage } from '@magickml/server-core'
import axiosRetry from 'axios-retry'
Expand Down Expand Up @@ -75,7 +79,7 @@ export async function makeTextCompletion(
try {
// Exponential back-off retry delay between requests
axiosRetry(axios, {
retries: 5,
retries: BACKOFF_RETRY_LIMIT,
retryDelay: axiosRetry.exponentialDelay,
shouldResetTimeout: true,
retryCondition: error => {
Expand Down

0 comments on commit c2136f8

Please sign in to comment.