run-llama / LlamaIndexTS

LlamaIndex in TypeScript
https://ts.llamaindex.ai
MIT License
1.75k stars 335 forks source link

Rate Limit Error with OPENAI_API_KEY #31

Closed sid-metricpath closed 1 year ago

sid-metricpath commented 1 year ago

I was running the starter tutorial from the docs. I am getting rate limit error from OpenAI. It should not be happening because I have a paid plan. Here are the information that may help you: llamaindex: 0.0.12 typescript: 5.1.6

here is the error from the console: ` var error = new Error(message); ^ Error: Request failed with status code 429 at createError (C:\Users\sidmi\Documents\llama-index-ts\node_modules\llamaindex\dist\index.js:452:19) at settle (C:\Users\sidmi\Documents\llama-index-ts\node_modules\llamaindex\dist\index.js:468:16) at C:\Users\sidmi\Documents\llama-index-ts\node_modules\llamaindex\dist\index.js:3017:124 at new Promise () at C:\Users\sidmi\Documents\llama-index-ts\node_modules\llamaindex\dist\index.js:3013:16 at Generator.next () at fulfilled (C:\Users\sidmi\Documents\llama-index-ts\node_modules\llamaindex\dist\index.js:61:24) at processTicksAndRejections (node:internal/process/task_queues:95:5) { config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: [Function: fetchAdapter2], 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.3.0', Authorization: 'Bearer ' }, method: 'post', data: '{"model":"text-embedding-ada-002","input":"I started this decade as a first-year college student fresh out of high school. I was 17, didn’t have a job, didn’t have any industry connections, and really didn’t know shit. And now you’re reading my blog! I would have been proud. I’ve told bits and pieces of my story on different podcasts. Now feels like an appropriate time to write down the parts that were most memorable to me. Every person’s story is unique and not directly reproducible. I’ve benefited immensely from the privilege of being born in an upper middle class family and looking like a typical coder stereotype. People took chances on me. Still, I hope that sharing my story can be helpful to compare our experiences. Even if our circumstances are too different, at least you might find some of it entertaining. 2010 I was born in Russia and I finished the high school there in 2009. In Russia, higher education is free if you do well enough at tests. I tried my chances with a few colleges. I was particularly hoping to get into one college whose students often won programming competitions (which I thought was cool at the time). However, it turned out my math exam scores weren’t good enough. So there were not many options I could choose from that had to do with programming. From the remaining options, I picked a college that gave Macbooks to students. (Remember the white plastic ones with GarageBand? They were the best.) By the summer of 2010, I had just finished my first year there. It turned out that there wasn’t going to be much programming in the curriculum for two more years. But there was a lot of linear algebra, physics, and other subjects I didn’t find particularly interesting. Everything was well in the beginning, but I started slacking off and skipping lectures that I had to wake up early for. My gaps in knowledge gradually snowballed, and most of what I remember from my first year in the university is the anxiety associated with feeling like a total failure. Even for subjects I knew well, things didn’t quite go as I planned. Our English classes were very rudimentary, and I got a verbal approval from the teacher to skip most of them. But when I came for the final test, I wasn’t allowed to turn it in unless I pay money for hours of “catch up training” with the same teacher. This experience left me resentful and suspicious of higher education. Aside from being a lousy student, I was also in my first serious relationship — and it wasn’t going very well either. I was unhappy, but I thought that you can solve this by continuing to be unhappy and “fixing” it. Unfortunately, I didn’t have the wisdom to get out of a non-working relationship for a few more years. Now onto the bright side. Professionally, 2010 was an exciting year for me. I got my first job as a software developer! Here’s how that happened. There was a small venue close to my college that hosted different events. This venue was a “business incubator” — mind you, not a Silicon Valley kind of business incubator — but a tiny Russian one. I have no idea what businesses they “incubated”. However, they hosted a talk about software development, and I decided to check it out because I was starving for that kind of content. I didn’t know any programmers in real life, and I didn’t know meetups existed! I don’t remember what the talk was about now. But I knew the person who gave it was an executive in a Russian-American outsourcing company. I’ve been programming since 12, so I approached him and asked if they’re hiring. He gave me an email, I went through their test exercises, and in a few weeks got the job. I started at my first job during the summer of 2010. My salary was $18k/year (yes that’s 18 and not 180). This is peanuts in the developed world, but again, this was Russia — so the rent was cheap too. I immediately moved out of my mom’s apartment and started renting a room for $150 a month. I was excited. With my first salary, I bought an iPhone and marvelled at how good the UI was. Summer came and went, and then the second college year started. But it started without me. Now that I was doing actual work and people payed me for it, I lost my last bits of motivation for sitting at lectures and doing exercises."}',
url: 'https://api.openai.com/v1/embeddings' }, request: Request { [Symbol(realm)]: { settingsObject: [Object] },

  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 {
  [Symbol(kEvents)]: [SafeMap [Map]],
  [Symbol(events.maxEventTargetListeners)]: 10,
  [Symbol(events.maxEventTargetListenersWarned)]: false,
  [Symbol(kAborted)]: false,
  [Symbol(kReason)]: undefined,
  [Symbol(realm)]: [Object]
},
[Symbol(headers)]: Headers {
  [Symbol(headers list)]: [HeadersList],
  [Symbol(guard)]: 'request',
  [Symbol(realm)]: [Object]
}

}, response: { ok: false, status: 429, statusText: 'Too Many Requests', headers: Headers {

  [Symbol(guard)]: 'none'
},
config: {
  transitional: [Object],
  adapter: [Function: fetchAdapter2],
  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":"text-embedding-ada-002","input":"I started this decade as a first-year college student fresh out of high school. I was 17, didn’t have a job, didn’t have any industry connections, and really didn’t know shit. And now you’re reading my blog! I would have been proud. I’ve told bits and pieces of my story on different podcasts. Now feels like an appropriate time to write down the parts that were most memorable to me. Every person’s story is unique and not directly reproducible. I’ve benefited immensely from the privilege of being born in an upper middle class family and looking like a typical coder stereotype. People took chances on me. Still, I hope that sharing my story can be helpful to compare our experiences. Even if our circumstances are too different, at least you might find some of it entertaining. 2010 I was born in Russia and I finished the high school there in 2009. In Russia, higher education is free if you do well enough at tests. I tried my chances with a few colleges. I was particularly hoping to get into one college whose students often won programming competitions (which I thought was cool at the time). However, it turned out my math exam scores weren’t good enough. So there were not many options I could choose from that had to do with programming. From the remaining options, I picked a college that gave Macbooks to students. (Remember the white plastic ones with GarageBand? They were the best.) By the summer of 2010, I had just finished my first year there. It turned out that there wasn’t going to be much programming in the curriculum for two more years. But there was a lot of linear algebra, physics, and other subjects I didn’t find particularly interesting. Everything was well in the beginning, but I started slacking off and skipping lectures that I had to wake up early for. My gaps in knowledge gradually snowballed, and most of what I remember from my first year in the university is the anxiety associated with feeling like a total failure. Even for subjects I knew well, things didn’t quite go as I planned. Our English classes were very rudimentary, and I got a verbal approval from the teacher to skip most of them. But when I came for the final test, I wasn’t allowed to turn it in unless I pay money for hours of “catch up training” with the same teacher. This experience left me resentful and suspicious of higher education. Aside from being a lousy student, I was also in my first serious relationship — and it wasn’t going very well either. I was unhappy, but I thought that you can solve this by continuing to be unhappy and “fixing” it. Unfortunately, I didn’t have the wisdom to get out of a non-working relationship for a few more years. Now onto the bright side. Professionally, 2010 was an exciting year for me. I got my first job as a software developer! Here’s how that happened. There was a small venue close to my college that hosted different events. This venue was a “business incubator” — mind you, not a Silicon Valley kind of business incubator — but a tiny Russian one. I have no idea what businesses they “incubated”. However, they hosted a talk about software development, and I decided to check it out because I was starving for that kind of content. I didn’t know any programmers in real life, and I didn’t know meetups existed! I don’t remember what the talk was about now. But I knew the person who gave it was an executive in a Russian-American outsourcing company. I’ve been programming since 12, so I approached him and asked if they’re hiring. He gave me an email, I went through their test exercises, and in a few weeks got the job. I started at my first job during the summer of 2010. My salary was $18k/year (yes that’s 18 and not 180). This is peanuts in the developed world, but again, this was Russia — so the rent was cheap too. I immediately moved out of my mom’s apartment and started renting a room for $150 a month. I was excited. With my first salary, I bought an iPhone and marvelled at how good the UI was. Summer came and went, and then the second college year started. But it started without me. Now that I was doing actual work and people payed me for it, I lost my last bits of motivation for sitting at lectures and doing exercises."}', 
  url: 'https://api.openai.com/v1/embeddings'
},
request: Request {
  [Symbol(realm)]: [Object],
  [Symbol(state)]: [Object],
  [Symbol(signal)]: [AbortSignal],
  [Symbol(headers)]: [Headers]
},
data: { error: [Object] }

}, isAxiosError: true, toJSON: [Function: toJSON] }`

yisding commented 1 year ago

Thanks for the issue! We are migrating to OpenAI v4 npm shortly so will take a look at fixing this also.

logan-markewich commented 1 year ago

V4 is added! This should hopefully be less of an issue now. Please feel free to re-open this if not!