Error to create chat
GheorgheMocanu opened this issue · 14 comments
I have this problem, dont know actually how to solved, learning by your video.
if somebody can help me please?
this is my terminal:
⚠ ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in '/Users/goga/Documents/myProjects/chatpdf/node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
⚠ ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in '/Users/goga/Documents/myProjects/chatpdf/node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
⚠ ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in '/Users/goga/Documents/myProjects/chatpdf/node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
⚠ ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in '/Users/goga/Documents/myProjects/chatpdf/node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/lib/s3.ts
./src/components/FileUpload.tsx
./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/goga/Documents/myProjects/chatpdf/node_modules/node-fetch/lib'
Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/cross-fetch/dist/node-ponyfill.js
./node_modules/@pinecone-database/pinecone/dist/pinecone.js
./node_modules/@pinecone-database/pinecone/dist/index.js
./src/lib/pincecone.ts
./src/app/api/create-chat/route.ts
uploads/1695248226308the-weekend.pdf the weekend.pdf
downloading s3 into file system
loading pdf into memory/tmp/elliott1695248229781.pdf
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 2)
at async loadS3IntoPinecone (webpack-internal:///(rsc)/./src/lib/pincecone.ts:41:21)
at async POST (webpack-internal:///(rsc)/./src/app/api/create-chat/route.ts:31:9)
at async /Users/goga/Documents/myProjects/chatpdf/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:66877
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 2)
at async loadS3IntoPinecone (webpack-internal:///(rsc)/./src/lib/pincecone.ts:41:21)
at async POST (webpack-internal:///(rsc)/./src/app/api/create-chat/route.ts:31:9)
at async /Users/goga/Documents/myProjects/chatpdf/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:66877
TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 2)
at async loadS3IntoPinecone (webpack-internal:///(rsc)/./src/lib/pincecone.ts:41:21)
at async POST (webpack-internal:///(rsc)/./src/app/api/create-chat/route.ts:31:9)
at async /Users/goga/Documents/myProjects/chatpdf/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:66877
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 3)
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 3)
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 4)
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 4)
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 1)
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 1)
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 0)
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 0)
error calling openai embeddings api TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 5)
error embedding document TypeError: Cannot read properties of undefined (reading '0')
at getEmbeddings (webpack-internal:///(rsc)/./src/lib/embeddings.ts:18:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async embedDocument (webpack-internal:///(rsc)/./src/lib/pincecone.ts:52:28)
at async Promise.all (index 5)
if you found a solution, let me know
What steps did I take?
At first I followed the video and learned how you showed me, but I got to this problem at 2:30:00.
I thought it was a problem on my part or maybe I didn't write something correctly in the code, then:
I downloaded the project from github
I replaced the keys in .env
But I get the same error
In S3 bucket, the files are loaded, but in pinecone nothing is sent
maybe the problem is because of pinecone
maybe the problem is because of pinecone
for you its work ?
no I have the same issue as you
Hi @AymanBoumait and @GheorgheMocanu ,
The error coming 2 things:
- Pinecone: You need to create index
chatpf
on Pinecone dashboard - Open AI API Token
In my case, because of my Open AI token. I didn't setup payment methods on OpenAI, so my token is not available to use. So I get the same error like you guys.
The error come from line const vectors = await Promise.all(documents.flat().map(embedDocument))
(image attached).
I'm having the same issue. getting held up ~2:30.
I started throwing a type error following the video on loadS3IntoPinecone() relating to namespace
. In diagnosing I noticed changes made to the libraries imported from Pinecone for pinecone.ts. I've reviewed and tried to make necessary changes, but am now receiving the same errors described here.
Hi @AymanBoumait and @GheorgheMocanu ,
The error coming 2 things:
- Pinecone: You need to create index
chatpf
on Pinecone dashboard- Open AI API Token
In my case, because of my Open AI token. I didn't setup payment methods on OpenAI, so my token is not available to use. So I get the same error like you guys. The error come from line
const vectors = await Promise.all(documents.flat().map(embedDocument))
(image attached).
Hmmmm, I tried to follow the steps you mentioned.
" const pineconeIndex = await client.index("chatpdf"); " it have same name like in pinecone dashboard
- I connected the credit card to the open ai account
but that didn't solve the problem, I get exactly the same error
Same here, is there anyone found a solution?
meow {file_key: 'uploads/1699375092777C23-81-Performans Analizi Kriterleri R01.pdf', file_name: 'C23-81 Performans Analizi Kriterleri R01.pdf'}
xhr.js:251
POST http://localhost:3000/api/create-chat 500 (Internal Server Error)
dispatchXhrRequest @ xhr.js:251
xhr @ xhr.js:49
dispatchRequest @ dispatchRequest.js:51
request @ Axios.js:146
httpMethod @ Axios.js:185
wrap @ bind.js:5
mutationFn @ FileUpload.tsx:24
fn @ mutation.mjs:87
run @ retryer.mjs:101
createRetryer @ retryer.mjs:149
executeMutation @ mutation.mjs:81
execute @ mutation.mjs:138
await in execute (async)
mutate @ mutationObserver.mjs:85
eval @ useMutation.mjs:19
onDrop @ FileUpload.tsx:51
await in onDrop (async)
eval @ index.js:708
eval @ index.js:759
Promise.then (async)
eval @ index.js:758
eval @ index.js:831
eval @ index.js:192
eval @ index.js:190
callCallback @ react-dom.development.js:19467
invokeGuardedCallbackImpl @ react-dom.development.js:19516
invokeGuardedCallback @ react-dom.development.js:19591
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:19605
executeDispatch @ react-dom.development.js:30661
processDispatchQueueItemsInOrder @ react-dom.development.js:30693
processDispatchQueue @ react-dom.development.js:30706
dispatchEventsForPlugins @ react-dom.development.js:30717
eval @ react-dom.development.js:30907
batchedUpdates$1 @ react-dom.development.js:23771
batchedUpdates @ react-dom.development.js:27623
dispatchEventForPluginEventSystem @ react-dom.development.js:30906
dispatchEvent @ react-dom.development.js:28679
dispatchDiscreteEvent @ react-dom.development.js:28650
app-index.js:31 AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
window.console.error @ app-index.js:31
console.error @ hydration-error-info.js:45
execute @ mutation.mjs:158
await in execute (async)
mutate @ mutationObserver.mjs:85
eval @ useMutation.mjs:19
onDrop @ FileUpload.tsx:51
await in onDrop (async)
eval @ index.js:708
eval @ index.js:759
Promise.then (async)
eval @ index.js:758
eval @ index.js:831
eval @ index.js:192
eval @ index.js:190
callCallback @ react-dom.development.js:19467
invokeGuardedCallbackImpl @ react-dom.development.js:19516
invokeGuardedCallback @ react-dom.development.js:19591
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:19605
executeDispatch @ react-dom.development.js:30661
processDispatchQueueItemsInOrder @ react-dom.development.js:30693
processDispatchQueue @ react-dom.development.js:30706
dispatchEventsForPlugins @ react-dom.development.js:30717
eval @ react-dom.development.js:30907
batchedUpdates$1 @ react-dom.development.js:23771
batchedUpdates @ react-dom.development.js:27623
dispatchEventForPluginEventSystem @ react-dom.development.js:30906
dispatchEvent @ react-dom.development.js:28679
dispatchDiscreteEvent @ react-dom.development.js:28650
app-index.js:31 AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
window.console.error @ app-index.js:31
console.error @ hydration-error-info.js:45
onError @ FileUpload.tsx:58
eval @ mutationObserver.mjs:113
batch @ notifyManager.mjs:20
notify @ mutationObserver.mjs:102
onMutationUpdate @ mutationObserver.mjs:59
eval @ mutation.mjs:236
eval @ mutation.mjs:235
batch @ notifyManager.mjs:20
dispatch @ mutation.mjs:234
execute @ mutation.mjs:167
await in execute (async)
mutate @ mutationObserver.mjs:85
eval @ useMutation.mjs:19
onDrop @ FileUpload.tsx:51
await in onDrop (async)
eval @ index.js:708
eval @ index.js:759
Promise.then (async)
eval @ index.js:758
eval @ index.js:831
eval @ index.js:192
eval @ index.js:190
callCallback @ react-dom.development.js:19467
invokeGuardedCallbackImpl @ react-dom.development.js:19516
invokeGuardedCallback @ react-dom.development.js:19591
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:19605
executeDispatch @ react-dom.development.js:30661
processDispatchQueueItemsInOrder @ react-dom.development.js:30693
processDispatchQueue @ react-dom.development.js:30706
dispatchEventsForPlugins @ react-dom.development.js:30717
eval @ react-dom.development.js:30907
batchedUpdates$1 @ react-dom.development.js:23771
batchedUpdates @ react-dom.development.js:27623
dispatchEventForPluginEventSystem @ react-dom.development.js:30906
dispatchEvent @ react-dom.development.js:28679
dispatchDiscreteEvent @ react-dom.development.js:28650
i am also getting same axios error is anybody solve this issue. @ybekocak @GheorgheMocanu @AymanBoumait @0xalphaprime @huynextlevel
Same I'm getting that same error , any resolutions ?
Had the same issue.
It might be that you are out of credits. You can try to check result.data in the embeddings.ts file like this:
import {OpenAIApi, Configuration} from 'openai-edge'
const config = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(config);
export async function getEmbeddings(text: string) {
try{
const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
input: text.replace(/\n/g, " "),
});
const result = await response.json();
console.log('API response:', result); // Debug log
console.log('Embeddings:', result.data[0].embedding); // Debug log
return result.data[0].embedding as number[];
}catch(error){
console.log('error calling openai embeddings api', error);
throw error;
}
}
Hey guys i have found a simple solution for this..
While i was debugging this Axios error: internal server error 500 :
IF you notice your concole in code editor there might be written file/module not found error.
Solution:
When you are trying to upload a File....
- Check if the file is successfully uploaded to S3. If yes, then your connection with S3 is all good and UploadtoS3() function has no issues.
- Now, check if you follow the code of route.ts. It calls the function loads3intoPinecone() which takes us to pinecone.ts.
- Now in pinecone.ts under the method loads3intoPinecone(), the method downloadfrons3 is called which helps us to download our document from S3.
- This takes us s3-server.ts file , here we are using fs module to write our downloaded file into a tmp file.
fs.writeFileSync(file_name, obj.Body as Buffer)
**i suggest try cosole.log(file_name) tocheck if you are getting the file_name ** if not which was in my case you can follow the next step. - Now , As the file_name is not available since the module/file is not downloaded from s3 a server-side error is poping up and also module not found error.
- Finally, To fix this issue, you can try creating the /tmp directory manually and setting the correct permissions to make it writable. For this-
- Go to the folder of your Project
- NOTE: This is for windows
- open the path in terminal and type the following command
- mkdir /tmp
- icacls C:\tmp /grant Everyone:F