supabase-community / postgres-new

In-browser Postgres sandbox with AI assistance
https://database.build
Apache License 2.0
2.34k stars 183 forks source link

Context length exceeded. High token consumption #98

Closed ChenZixinn closed 1 month ago

ChenZixinn commented 1 month ago
image

Environment:

Observed behavior:

  1. Multiple interactions needed for file import:

Expected behavior:

gregnr commented 1 month ago

Thanks for the issue @ChenZixinn. Do you have any sample files you could provide to help reproduce your two observations?

ChenZixinn commented 1 month ago

Thank you for your response.

I believe I’ve temporarily resolved the issues. The first problem was related to the CSV file, where some data fields were empty, causing failures and constant retries. By formatting the CSV file—such as filling empty rows with zeros or other values—it reduced the errors.

The second problem was likely caused by the first one, and as I continuously imported the file, it resulted in a large message context. However, setting a maxMessageContext seems to resolve the issue.

I’m sorry I can’t provide the data for reference, but here are two areas for optimization:

1.  Avoiding errors during CSV imports: If there are empty rows or inconsistent data types, it’s easy for errors to occur.
2.  Reducing the logging of non-essential information or simplifying the logs to minimize token consumption.
ChenZixinn commented 1 month ago

I’m really excited about the Private Alpha deployments, especially the idea of using a serverless PGlite instance outside the browser. I’ve already joined the waitlist and can’t wait to get access! Looking forward to hearing more about it soon.