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

Error processing file. Please upload the correct file #2

Open
shivswami opened this issue Nov 2, 2024 · 5 comments
Open

Error processing file. Please upload the correct file #2

shivswami opened this issue Nov 2, 2024 · 5 comments

Comments

@shivswami
Copy link

shivswami commented Nov 2, 2024

Error processing file. Please upload the correct file. If you still face issues, create an issue on GitHub.
My chat history download is around 25 MB and I have tried uploading conversations.json file.
image

@meetpateltech
Copy link
Owner

please modify your onDrop function (in app/dashboard/page.tsx) as follows and check the console for errors:

const onDrop = useCallback(async (acceptedFiles: File[]) => {
    try {
      const file = acceptedFiles[0];
      console.log('Accepted file:', file); 
      const jsonData = await readJsonFile(file);
      console.log('JSON data read successfully:', jsonData);
      const newAnalysis = new ChatGPTDataAnalysis(jsonData);
      console.log('Analysis object created:', newAnalysis);
      setAnalysis(newAnalysis);

      const newDashboardData = {
        totalConversations: newAnalysis.getTotalConversations(),
        totalGPTConversations: newAnalysis.getTotalGPTsConversations(),
        totalMessages: newAnalysis.getTotalMessages(),
        totalGPTMessages: newAnalysis.getTotalGPTsMessages(),
        mostChattyDay: newAnalysis.getMostChattyDay(),
        timeSpentOnChatGPT: newAnalysis.getTimeSpentOnChatGPT(),
        averageDailyMessageCount: newAnalysis.getAverageDailyMessageCount(),
        totalArchivedConversations: newAnalysis.getTotalArchivedConversations(),
        totalVoiceMessages: newAnalysis.getTotalVoiceMessages(),
        totalImagesGenerated: newAnalysis.getDALLEImageCount() + newAnalysis.getDALLEImageCountWithoutGizmo(),
        roleBasedMessageData: {
          overall: newAnalysis.getRoleBasedMessageCount(),
          gpts: newAnalysis.getRoleBasedGPTsMessageCount(),
          voice: newAnalysis.getRoleBasedVoiceMessageCount()
        },
        shiftWiseMessageData: newAnalysis.getShiftWiseMessageCount(),
        modelWiseMessageData: newAnalysis.getModelWiseMessageCount(),
        usageTimelineData: newAnalysis.getFirstAndLastUsedDate(),
        defaultModelSlugData: newAnalysis.getDefaultModelSlugCount(),
        aiMessageStatusData: newAnalysis.getStatusCount(),
        modelAdjustmentsCount: newAnalysis.getModelAdjustmentsCount(),
        userAttachmentMimeTypeCount: newAnalysis.getUserAttachmentMimeTypeCount(),
        toolUsageData: newAnalysis.getToolNameCount(),
        locationData: newAnalysis.getLocationCodes(),
        finishDetailData: newAnalysis.getFinishDetailsTypeCount(),
        requestedModelData: newAnalysis.getRequestedModelCount(),
        codeBlockCount: newAnalysis.getAssistantGeneratedCodeBlockCount()
      };
      console.log('Dashboard data calculated:', newDashboardData);
      setDashboardData(newDashboardData);
      setShowConfetti(true);
      setTimeout(() => setShowConfetti(false), 5000);

      /* router.push('?success=true', { scroll: false }); */
    } catch (error) {
      console.error('Error processing file:', error);
      toast.error('Error processing file. Please upload the correct file. If you still face issues, create an issue on GitHub.');
    }
  }, []);

Check the console for any errors after making these changes and let me know what you find.

@shivswami
Copy link
Author

Still same error "Error processing file. Please upload the correct file. If you still face issues, create an issue on GitHub.'
No messages on console at all.
Probably will help if you can share a sample that worked for you with few msgs.

convelyze>bun install
bun install v1.1.33 (247456b6)

Checked 746 installs across 795 packages (no changes) [6.46s]

convelyze>bun run dev
$ next dev
▲ Next.js 14.2.11

✓ Starting...
✓ Ready in 3.1s
○ Compiling /dashboard ...
✓ Compiled / in 17.5s (5030 modules)
GET / 200 in 15898ms
GET / 200 in 96ms
GET / 200 in 79ms
GET /dashboard 200 in 56ms

@meetpateltech
Copy link
Owner

since data processing happens on the client side, please check the browser console instead, as server-side logs won't capture any errors during file processing.

@flyingsloth304
Copy link

I had a similar issue when I uploaded my 45 MB file, and I noticed in the console it was failing with the console error message:

Error processing file: TypeError: Cannot read properties of undefined (reading 'some')
    at eval (ChatGPTDataAnalysis.ts:439:21)
    at Array.forEach (<anonymous>)
    at eval (ChatGPTDataAnalysis.ts:436:43)
    at Array.forEach (<anonymous>)
    at ChatGPTDataAnalysis.getDALLEImageCount (ChatGPTDataAnalysis.ts:435:15)
    at eval (page.tsx:102:43)

So I modified ChatGPTDataAnalysis.ts to

public getDALLEImageCount(): number {
    const dalleGizmoId = 'g-2fkFE8rbu';
    let dalleImageCount = 0;

    this.data.forEach(conversation => {
      Object.values(conversation.mapping).forEach(node => {
        if (node.message !== null && node.message.author.role === 'assistant' && node.message.metadata.gizmo_id === dalleGizmoId) {
		  if(node.message.content && node.message.content.parts) { // sometimes parts isn't defined
			  const parts = node.message.content.parts;
			  if (parts.some(part => part.toLowerCase().includes('prompt'))) {
				dalleImageCount++;
			  }
		  }
        }
      });
    });

    return dalleImageCount;
  }

It seems like in a few of my nodes, parts wasn't defined, so I just did a quick patch to get it working. I didn't spend too much time figuring out the accuracy of the data, I just wanted to let you know that's the issue I noticed. Great work on this btw!

@meetpateltech
Copy link
Owner

Thanks for pointing this out and sharing the fix! I’ve patched it similarly, and it’s working now. Appreciate your help!

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

3 participants