Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Indexing, [TOO MANY REQUESTS] Keeps being thrown #6

Open
Bewinxed opened this issue Mar 25, 2023 · 13 comments
Open

When Indexing, [TOO MANY REQUESTS] Keeps being thrown #6

Bewinxed opened this issue Mar 25, 2023 · 13 comments

Comments

@Bewinxed
Copy link

Indexing as usual, after estimation, it runs for a bit then keeps throwing this error:

Failed to get summary for file github.py
⠹ Processing 724 files...Error: Request failed with status code 429
    at createError (file:///home/bewinxed/.nvm/versions/node/v18.15.0/lib/node_modules/@context-labs/autodoc/node_modules/langchain/dist/util/axios-fetch-adapter.js:302:19)
    at settle (file:///home/bewinxed/.nvm/versions/node/v18.15.0/lib/node_modules/@context-labs/autodoc/node_modules/langchain/dist/util/axios-fetch-adapter.js:24:16)
    at file:///home/bewinxed/.nvm/versions/node/v18.15.0/lib/node_modules/@context-labs/autodoc/node_modules/langchain/dist/util/axios-fetch-adapter.js:185:19
    at new Promise (<anonymous>)
    at fetchAdapter (file:///home/bewinxed/.nvm/versions/node/v18.15.0/lib/node_modules/@context-labs/autodoc/node_modules/langchain/dist/util/axios-fetch-adapter.js:177:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [AsyncFunction: fetchAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'OpenAI/NodeJS/3.2.1',
      Authorization: 'Bearer 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'
    },
    method: 'post',
    data: '{"model":"gpt-3.5-turbo","temperature":0.1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"n":1,"stream":false,"messages":[{"role":"user","content":"\\n    You are acting as a code documentation expert for a project called RADAR.\\n    Below is the code from a file located at `RADAR`. \\n    Write a detailed technical explanation of what this code does. \\n    Focus on the high-level purpose of the code and how it may be used in the larger project.\\n    Include code examples where appropriate. Keep you response between 100 and 300 words. \\n    DO NOT RETURN MORE THAN 300 WORDS.\\n    Output should be in markdown format. \\n    Do not say \\"this file is a part of the RADAR project\\".\\n    Do not just list the methods and classes in this file.\\n\\n    Code:\\n    import json\\nfrom fastapi.encoders import jsonable_encoder\\nfrom typing import Optional\\nimport aiohttp\\nfrom fastapi import APIRouter, Query, Response\\n\\nfrom utils.lunaris import Lunaris\\n\\nAPI_KEY = \\"819a8443-a2fb-433f-83cd-7a47257bd548\\"\\n\\nrouter = APIRouter()\\n\\n\\[email protected](\\"/collection/find\\")\\nasync def find_collection_post(\\n    helloMoonCollectionId: str = None,\\n    collectionName: str = None,\\n):\\n    if all([helloMoonCollectionId, collectionName]):\\n        raise Exception(\\n            \\"You can only provide one of helloMoonCollectionId or collectionName\\"\\n        )\\n    if not any([helloMoonCollectionId, collectionName]):\\n        raise Exception(\\n            \\"You must provide either helloMoonCollectionId or collectionName\\"\\n        )\\n    return await Lunaris().find_collection(\\n        helloMoonCollectionId=helloMoonCollectionId, collectionName=collectionName\\n    )\\n\\n\\n    Response:\\n\\n  "}]}',
    url: 'https://api.openai.com/v1/chat/completions'
  },
  request: Request {
    [Symbol(realm)]: { settingsObject: [Object] },
    [Symbol(state)]: {
      method: 'POST',
      localURLsOnly: false,
      unsafeRequest: false,
      body: [Object],
      client: [Object],
      reservedClient: null,
      replacesClientId: '',
      window: 'client',
      keepalive: false,
      serviceWorkers: 'all',
      initiator: '',
      destination: '',
      priority: null,
      origin: 'client',
      policyContainer: 'client',
      referrer: 'client',
      referrerPolicy: '',
      mode: 'cors',
      useCORSPreflightFlag: false,
      credentials: 'same-origin',
      useCredentials: false,
      cache: 'default',
      redirect: 'follow',
      integrity: '',
      cryptoGraphicsNonceMetadata: '',
      parserMetadata: '',
      reloadNavigation: false,
      historyNavigation: false,
      userActivation: false,
      taintedOrigin: false,
      redirectCount: 0,
      responseTainting: 'basic',
      preventNoCacheCacheControlHeaderModification: false,
      done: false,
      timingAllowFailed: false,
      headersList: [HeadersList],
      urlList: [Array],
      url: [URL]
    },
    [Symbol(signal)]: AbortSignal { aborted: false },
    [Symbol(headers)]: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    }
  },
  response: {
    ok: false,
    status: 429,
    statusText: 'Too Many Requests',
    headers: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    config: {
      transitional: [Object],
      adapter: [AsyncFunction: fetchAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      headers: [Object],
      method: 'post',
      data: '{"model":"gpt-3.5-turbo","temperature":0.1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"n":1,"stream":false,"messages":[{"role":"user","content":"\\n    You are acting as a code documentation expert for a project called RADAR.\\n    Below is the code from a file located at `RADAR`. \\n    Write a detailed technical explanation of what this code does. \\n    Focus on the high-level purpose of the code and how it may be used in the larger project.\\n    Include code examples where appropriate. Keep you response between 100 and 300 words. \\n    DO NOT RETURN MORE THAN 300 WORDS.\\n    Output should be in markdown format. \\n    Do not say \\"this file is a part of the RADAR project\\".\\n    Do not just list the methods and classes in this file.\\n\\n    Code:\\n    import json\\nfrom fastapi.encoders import jsonable_encoder\\nfrom typing import Optional\\nimport aiohttp\\nfrom fastapi import APIRouter, Query, Response\\n\\nfrom utils.lunaris import Lunaris\\n\\nAPI_KEY = \\"819a8443-a2fb-433f-83cd-7a47257bd548\\"\\n\\nrouter = APIRouter()\\n\\n\\[email protected](\\"/collection/find\\")\\nasync def find_collection_post(\\n    helloMoonCollectionId: str = None,\\n    collectionName: str = None,\\n):\\n    if all([helloMoonCollectionId, collectionName]):\\n        raise Exception(\\n            \\"You can only provide one of helloMoonCollectionId or collectionName\\"\\n        )\\n    if not any([helloMoonCollectionId, collectionName]):\\n        raise Exception(\\n            \\"You must provide either helloMoonCollectionId or collectionName\\"\\n        )\\n    return await Lunaris().find_collection(\\n        helloMoonCollectionId=helloMoonCollectionId, collectionName=collectionName\\n    )\\n\\n\\n    Response:\\n\\n  "}]}',
      url: 'https://api.openai.com/v1/chat/completions'
    },
    request: Request {
      [Symbol(realm)]: [Object],
      [Symbol(state)]: [Object],
      [Symbol(signal)]: [AbortSignal],
      [Symbol(headers)]: [HeadersList]
    },
    data: { error: [Object] }
  },
  isAxiosError: true,
  toJSO
@Bewinxed
Copy link
Author

Just got this email from openAI

Hi there,

Your OpenAI API key was determined to have been leaked, which has triggered a key rotation and this friendly notification email.

This may be because you committed your API key to an online service such as GitHub, or your key may have been compromised in another way.

Don't worry, you still have API access! Head over to the [API Keys](https://mandrillapp.com/track/click/31165340/platform.openai.com?p=eyJzIjoiaV9DU0RkMFdkQkg1cUJRQlVQdmJGWTRCZmI4IiwidiI6MSwicCI6IntcInVcIjozMTE2NTM0MCxcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL3BsYXRmb3JtLm9wZW5haS5jb21cXFwvYWNjb3VudFxcXC9hcGkta2V5c1wiLFwiaWRcIjpcIjg2YmU5MTMwZDNhYTRlZWNiMjZlNDljNTA3ZDljZTQzXCIsXCJ1cmxfaWRzXCI6W1wiZGRlMTIyMmY1ZjBmNGVlOWEwNGY2NzdkZDQ2N2ZjN2MyNTllN2U4MFwiXX0ifQ) page to view your updated API key.

If your API key was stored in any locations - for instance, in code you are running - it will need to be updated before you can run this code again.

Finally, we ask that you please review our [best practices for API key safety](https://mandrillapp.com/track/click/31165340/help.openai.com?p=eyJzIjoiNUhhYkNXSWxjS25Gd01sakxNWExUTFJYYUlZIiwidiI6MSwicCI6IntcInVcIjozMTE2NTM0MCxcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL2hlbHAub3BlbmFpLmNvbVxcXC9lblxcXC9hcnRpY2xlc1xcXC81MTEyNTk1LWJlc3QtcHJhY3RpY2VzLWZvci1hcGkta2V5LXNhZmV0eVwiLFwiaWRcIjpcIjg2YmU5MTMwZDNhYTRlZWNiMjZlNDljNTA3ZDljZTQzXCIsXCJ1cmxfaWRzXCI6W1wiNzI4ODA0ZmM5MzY4OWEyZTk2MDE2ZDNhYzYyZjhmZGY0MTc5MGJkOVwiXX0ifQ).

Best,
The OpenAI team

@samheutmaker
Copy link
Contributor

samheutmaker commented Mar 25, 2023

You're hitting up against the maximum number of requests that OpenAI allows. This can happen in large projects.

We'll be adding improvements to handle this more gracefully in the near future.

Edit: your open AI key is viewable in the terminal output you posted. You should delete your post and rotate your key immediately.

@Bewinxed
Copy link
Author

Bewinxed commented Mar 25, 2023 via email

@samheutmaker
Copy link
Contributor

Sequentially would take a very long time for large projects using slower models.

Right now we parallelize up to 25 requests at a time but it's not perfect. Checkout RateLimit.ts in the project for more info.

If you can improve this, I'll merge it right away.

@Prem95
Copy link

Prem95 commented Mar 27, 2023

I face this issue even for smaller projects; how can this be solved?

https://github.com/Prem95/DataSciencePortfolio was my test attempt

@Nilotaviano
Copy link
Contributor

I was getting this error immediately on a pretty small repository (136 files). I changed APIRateLimit manually (this.maxConcurrentCalls = 1;) and managed to index all files, though it took a few minutes.

@Bewinxed
Copy link
Author

Bewinxed commented Mar 29, 2023 via email

@Prem95
Copy link

Prem95 commented Mar 31, 2023

I was getting this error immediately on a pretty small repository (136 files). I changed APIRateLimit manually (this.maxConcurrentCalls = 1;) and managed to index all files, though it took a few minutes.

where exactly I should change this? currently it is 50

@Nilotaviano
Copy link
Contributor

Nilotaviano commented Mar 31, 2023

where exactly I should change this? currently it is 50

node_modules/@context-labs/autodoc/dist/cli/utils/APIRateLimit.js
Just remove the parameter and set this.maxConcurrentCalls directly

@Prem95
Copy link

Prem95 commented Mar 31, 2023

where exactly I should change this? currently it is 50

node_modules/@context-labs/autodoc/dist/cli/utils/APIRateLimit.js Just remove the parameter and set this.maxConcurrentCalls directly

Even after adding the line, i still get

response: { ok: false, status: 429, statusText: 'Too Many Requests', headers: HeadersList { [Symbol(headers map)]: [Map], [Symbol(headers map sorted)]: null },,

Unsure what the issue is

@yhyu13
Copy link

yhyu13 commented May 15, 2023

#6 (comment)

The problem with that is we need to built autodoc from source, we should let this value be configurable from the .autodoc config

@yhyu13
Copy link

yhyu13 commented May 15, 2023

@ALL After switching to a pay as you go api key from a free trail api key, I am able to bypass this 429 rate limit error. But this error might still affect us all if OpenAI changes its rate limit

And here is OpenAI guide to implement rate throttle based on your manully set limit : https://github.com/openai/openai-cookbook/blob/main/examples/How_to_handle_rate_limits.ipynb

@samheutmaker
Copy link
Contributor

Yes it is recommended to have a paid OpenAI account with GPT-4 access to use autodoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants