openchatai / OpenChat

LLMs custom-chatbots console ⚡
https://open.cx
MIT License
5.17k stars 642 forks source link

Question about authorization #70

Closed MantasLukauskas closed 1 year ago

MantasLukauskas commented 1 year ago

Hi, Have a problem with the service; I changed common.env with the OpenAI and Pinecone tokens, and everything is running correctly (the front end is up), but when I give bot text, something is not correct.

Also, is it possible to directly access the backend chat and bypass the frontend from the remote server?

Logs: req.body { question: 'Hello', history: [ 'Hello' ], namespace: 'b16cc0d8-2fd0-4414-bb7a-4f7832de5fed', mode: 'assistant' } { question: 'Hello', history: [ 'Hello' ], namespace: 'b16cc0d8-2fd0-4414-bb7a-4f7832de5fed', mode: 'assistant' } error AxiosError: Request failed with status code 401 at createError (file:///usr/src/app/node_modules/langchain/dist/util/axios-fetch-adapter.js:310:16) at settle (file:///usr/src/app/node_modules/langchain/dist/util/axios-fetch-adapter.js:25:16) at file:///usr/src/app/node_modules/langchain/dist/util/axios-fetch-adapter.js:175:19 at new Promise () at fetchAdapter (file:///usr/src/app/node_modules/langchain/dist/util/axios-fetch-adapter.js:167:12) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RetryOperation._fn (/usr/src/app/node_modules/p-retry/index.js:50:12) { 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 MY TOKEN' }, method: 'post', data: '{"model":"gpt-3.5-turbo","temperature":0,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"n":1,"stream":false,"messages":[{"role":"user","content":"Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.\n\nChat History:\nHello\nFollow Up Input: Hello\nStandalone question:"}]}', url: 'https://api.openai.com/v1/chat/completions' }, 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 {
  cookies: null,
  [Symbol(headers map)]: [Map],
  [Symbol(headers map sorted)]: null
}

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

  [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,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"n":1,"stream":false,"messages":[{"role":"user","content":"Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.\\n\\nChat History:\\nHello\\nFollow Up Input: Hello\\nStandalone question:"}]}',
  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] }

}, attemptNumber: 7, retriesLeft: 0 }

MantasLukauskas commented 1 year ago

Little update:

About the problem more details:

@gharbat