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

The package works in development but does not work in production. #46

Open
SahilAujla opened this issue Dec 12, 2021 · 2 comments
Open

Comments

@SahilAujla
Copy link

I created a simple question-answering bot using this package and it runs perfectly fine on my local machine but when I deployed it to Vercel it stopped working and is giving 401 error.

I have checked everything, everything is fine -- the environment variables etc.

Here is my GitHub repository - Github Repo

Here is the deployed app on Vercel - App

Please look into it and what's causing the issue?

@SahilAujla
Copy link
Author

Here is a complete log of the error:

e: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 253,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular 1],
_currentUrl: 'https://api.openai.com/v1/answers',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
authorization: [Array],
'user-agent': [Array],
'content-length': [Array],
host: [Array]
}
},
response: {
status: 401,
statusText: 'UNAUTHORIZED',
headers: {
date: 'Sun, 12 Dec 2021 14:22:01 GMT',
'content-type': 'application/json',
'content-length': '251',
connection: 'close',
'www-authenticate': 'Basic realm="OpenAI API"',
'access-control-allow-origin': '
',
'openai-version': '2020-10-01',
'x-request-id': 'e4ce97e771ae5316d6a93c7dc8f5709a',
'openai-processing-ms': '393',
'strict-transport-security': 'max-age=15724800; includeSubDomains'
},
config: {
url: 'https://api.openai.com/v1/answers',
method: 'post',
data: '{"documents":[],"question":"Who is the prime Minister of India?","search_model":"ada","model":"ada","examples_context":"","examples":[["What is human life expectancy in the United States?","78 years."]],"max_tokens":64,"stop":["\n","<|endoftext|>","."]}',
headers: [Object],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: [Object]
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
_header: 'POST /v1/answers HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Bearer "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"\r\n' +
'User-Agent: axios/0.21.4\r\n' +
'Content-Length: 253\r\n' +
'Host: api.openai.com\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/v1/answers',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'api.openai.com',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
data: { error: [Object] }
},
isAxiosError: true,
toJSON: [Function: toJSON]
}

@LKNSI
Copy link

LKNSI commented Mar 29, 2023

Here is a complete log of the error:

e: Writable { _writableState: [WritableState], _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, _options: [Object], _ended: true, _ending: true, _redirectCount: 0, _redirects: [], _requestBodyLength: 253, _requestBodyBuffers: [], _onNativeResponse: [Function (anonymous)], _currentRequest: [Circular _1], currentUrl: 'https://api.openai.com/v1/answers', [Symbol(kCapture)]: false }, [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: [Object: null prototype] { accept: [Array], 'content-type': [Array], authorization: [Array], 'user-agent': [Array], 'content-length': [Array], host: [Array] } }, response: { status: 401, statusText: 'UNAUTHORIZED', headers: { date: 'Sun, 12 Dec 2021 14:22:01 GMT', 'content-type': 'application/json', 'content-length': '251', connection: 'close', 'www-authenticate': 'Basic realm="OpenAI API"', 'access-control-allow-origin': '', 'openai-version': '2020-10-01', 'x-request-id': 'e4ce97e771ae5316d6a93c7dc8f5709a', 'openai-processing-ms': '393', 'strict-transport-security': 'max-age=15724800; includeSubDomains' }, config: { url: 'https://api.openai.com/v1/answers', method: 'post', data: '{"documents":[],"question":"Who is the prime Minister of India?","search_model":"ada","model":"ada","examples_context":"","examples":[["What is human life expectancy in the United States?","78 years."]],"max_tokens":64,"stop":["\n","<|endoftext|>","."]}', headers: [Object], transformRequest: [Array], transformResponse: [Array], timeout: 0, adapter: [Function: httpAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], transitional: [Object] }, request: <ref *1> ClientRequest { _events: [Object: null prototype], _eventsCount: 7, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [TLSSocket], _header: 'POST /v1/answers HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'Content-Type: application/json\r\n' + 'Authorization: Bearer "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"\r\n' + 'User-Agent: axios/0.21.4\r\n' + 'Content-Length: 253\r\n' + 'Host: api.openai.com\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: noopPendingOutput], agent: [Agent], socketPath: undefined, method: 'POST', maxHeaderSize: undefined, insecureHTTPParser: undefined, path: '/v1/answers', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: 'api.openai.com', protocol: 'https:', _redirectable: [Writable], [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: [Object: null prototype] }, data: { error: [Object] } }, isAxiosError: true, toJSON: [Function: toJSON] }

I was browsing the issue because I was board and I see you've posted your OpenAI API key/credentials into the wild above. Please change your key!

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

2 participants