mayooear / gpt4-pdf-chatbot-langchain

GPT4 & LangChain Chatbot for large PDF docs
https://www.youtube.com/watch?v=ih9PBGVVOO4
14.91k stars 3.02k forks source link

Error: Failed to ingest your data - 401 but credentials are valid #55

Closed deweyai closed 1 year ago

deweyai commented 1 year ago

Hello all. Looking for a little help - I've walked through this step by step and apparently I need another set of eyes.

I read through the issues but none were quite the same as this. :\

I have double checked all API keys and I've tried multiple Pinecone databases, although this seems to point to unauthorized which doesn't make sense because the OpenAI key is valid.

If anyone can see what I'm missing I'd appreciate it. đź’Ż

` 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 { aborted: false },
[Symbol(headers)]: HeadersList {
  [Symbol(headers map)]: [Map],
  [Symbol(headers map sorted)]: null
}

}, response: { ok: false, status: 401, statusText: 'Unauthorized', headers: HeadersList {

  [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":"text-embedding-ada-002","input":["551US2 Unit: $U68 [09-20-11 18:50:10]    PAGES    PGT: OPIN 393 OCTOBER  TERM,  2006  Syllabus  MORSE et al. v. FREDERICK  certiorari to  the united states court of appeals for  the ninth circuit  No.  06–278.    Argued  March  19,  2007—Decided  June  25,  2007  At  a  school-sanctioned  and  school-supervised  event,  petitioner  Morse,  the  high  school  principal,  saw  students  unfurl  a  banner  stating  “BONG  HiTS  4  JESUS,”  which  she  regarded  as  promoting  illegal  drug  use.  Consistent  with  established  school  policy  prohibiting  such  messages  at  school  events,  Morse  directed  the  students  to  take  down  the  banner.  When  one  of  the  students  who  had  brought  the  banner  to  the  event—  respondent  Frederick—refused,  Morse  confiscated  the  banner  and  later  suspended  him.    The  school  superintendent  upheld  the  suspension,  ex­ plaining, inter  alia, that  Frederick  was  disciplined  because  his  banner","suspended  him.    The  school  superintendent  upheld  the  suspension,  ex­ plaining, inter  alia, that  Frederick  was  disciplined  because  his  banner  appeared to advocate illegal drug use in violation of school policy.    Peti­ tioner  school  board  also  upheld  the  suspension.    Frederick  filed  suit  under  42  U. S. C.  § 1983,  alleging  that  the  school  board  and  Morse  had  violated his First Amendment rights.    The District Court granted peti­ tioners  summary  judgment,  ruling  that  they  were  entitled  to  qualified  immunity  and  that  they  had  not  infringed  Frederick’s  speech  rights.  The  Ninth  Circuit  reversed.    Accepting  that  Frederick  acted  during  a  school-authorized activity and that the banner expressed a positive sen­ timent about marijuana use, the court nonetheless found a First Amend­ ment  violation  because  the  school  punished  Frederick  without  demon­ strating  that  his  speech  threatened  substantial  disruption.    It  also","ment  violation  because  the  school  punished  Frederick  without  demon­ strating  that  his  speech  threatened  substantial  disruption.    It  also  concluded  that  Morse  was  not  entitled  to  qualified  immunity  because  Frederick’s  right  to  display  the  banner  was  so  clearly  established  that  a  reasonable  principal  in  Morse’s  position  would  have  understood  that  her  actions  were  unconstitutional.  Held: Because schools  may  take  steps  to  safeguard  those  entrusted  to  their  care  from  speech  that  can  reasonably  be  regarded  as  encouraging  illegal drug use, the school officials in this case did not violate the First  Amendment  by  confiscating  the  pro-drug  banner  and  suspending  Fred­ erick.    Pp.  400–410.  (a) Frederick’s  argument  that  this  is  not  a  school  speech  case  is  re­ jec ted.    The event in question occurred during normal school hours and  was  sanctioned  by  Morse  as  an  approved  social  event  at  which  the  dis­","jec ted.    The event in question occurred during normal school hours and  was  sanctioned  by  Morse  as  an  approved  social  event  at  which  the  dis­ trict’s  student  conduct  rules  expressly  applied.    Teachers  and  adminis­ trators  were  among  the  students  and  were  charged  with  supervising  them.    Frederick  stood  among  other  students  across  the  street  from"]}',
  url: 'https://api.openai.com/v1/embeddings'
},
request: Request {
  [Symbol(realm)]: [Object],
  [Symbol(state)]: [Object],
  [Symbol(signal)]: [AbortSignal],
  [Symbol(headers)]: [HeadersList]
},
data: { error: [Object] }

}, isAxiosError: true, toJSON: [Function: toJSON] } e:\DEV\LANG\gpt4-pdf-chatbot-langchain\scripts\ingest-data.ts:51 throw new Error('Failed to ingest your data'); ^

[Error: Failed to ingest your data]

Node.js v18.14.0  ELIFECYCLE  Command failed with exit code 1.`

mayooear commented 1 year ago

Hey, I think this is a 401 unauthorized error, so there's an issue with your API key not the repo. Have you used up your 'usage' for the api key or violated any moderation terms or exceeded rate limits? Does the api key work through direct calls i.e. postman

deweyai commented 1 year ago

Thanks mayooear - I checked with postman and using the same api key I can successfully get embeddings from https://api.openai.com/v1/embeddings

deweyai commented 1 year ago

Strange - I noticed the Bearer in the error message is not the API key from my .env file.

Guess I need to figure out where that's coming from - it doesn't match any OpenAI api I have. đź‘Ž

] error [Error: Request failed with status code 401] { 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 sk-NOT_MY_API_KEY' },

hakimhaniff commented 1 year ago

you can add in advance system settings under User Variable to match the Authorization but now my error code is 429. Too Many request

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

image

deweyai commented 1 year ago

@hakimhaniff YOU ROCK.

Not sure how I missed that but I had an OLD env variable that had that key... saved my life. đź‘Ť