OpenAIEmbeddings Timeout #5574
Replies: 1 comment 2 replies
-
Hello, @ZehuaZhang! I'm here to help you with bugs, questions, and becoming a contributor. If you need any assistance, feel free to ask! To resolve the timeout issue with the Here is an example of how to increase the timeout: import { OpenAIEmbeddings } from "@langchain/openai";
const embeddings = new OpenAIEmbeddings({
timeout: 5000, // 5s timeout
});
/* Embed documents */
const res = await embeddings.embedDocuments(['Hello']);
console.log(res); By increasing the timeout, you give the requests more time to complete, which should help resolve the timeout issue. Additionally, ensure that other parameters such as For example, you can set const embeddings = new OpenAIEmbeddings({
timeout: 5000, // 5s timeout
batchSize: 1,
maxConcurrency: 2,
}); These settings can help manage the load and concurrency of the requests, potentially improving performance and reducing the likelihood of timeouts [1][2][3][4].
|
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
⨯ Internal error: Error: Connection error.
at OpenAI.makeRequest (./node_modules/openai/core.mjs:321:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async eval (./node_modules/@langchain/openai/dist/embeddings.js:278:29)
at async RetryOperation.eval [as _fn] (./node_modules/p-retry/index.js:50:12)
digest: "1734331795"
Cause: FetchError: request to https://api.openai.com/v1/embeddings failed, reason: connect ETIMEDOUT 154.85.102.30:443
at ClientRequest.eval (webpack-internal:///(action-browser)/./node_modules/node-fetch/lib/index.mjs:1510:11)
at ClientRequest.emit (node:events:514:28)
at TLSSocket.socketErrorListener (node:_http_client:495:9)
at TLSSocket.emit (node:events:526:35)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT'
}
System Info
langchain@0.2.2 | MIT | deps: 16 | versions: 273
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/
keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores
dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.2.2.tgz
.shasum: 21605450458c77f022c88fdb7671bb82f4a9a17f
.integrity: sha512-4tt2QuwW8AXdIL8CRkQeGOCoYYH3QbLHfQ09yD0iWLV1rwUYJ8mIYFAz/+u6CB8YNEyR/HI105s4xrxFQbWa9g==
.unpackedSize: 3.4 MB
dependencies:
@langchain/core: ~0.2.0 js-tiktoken: ^1.0.12 langsmith: ~0.1.7 uuid: ^9.0.0
@langchain/openai: ~0.0.28 js-yaml: ^4.1.0 ml-distance: ^4.0.0 yaml: ^2.2.1
@langchain/textsplitters: ~0.0.0 jsonpointer: ^5.0.1 openapi-types: ^12.1.3 zod-to-json-schema: ^3.22.3
binary-extensions: ^2.2.0 langchainhub: ~0.0.8 p-retry: 4 zod: ^3.22.4
maintainers:
dist-tags:
latest: 0.2.2 next: 0.2.0
Beta Was this translation helpful? Give feedback.
All reactions