-
Notifications
You must be signed in to change notification settings - Fork 708
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
send a new copy of the code to the server only when the code changes #1687
Conversation
…anges previously the client chat feature will send 2 requests to the llm api. the first being a copy of the current code and then the chat message sent by the user. with these changes, we hash the code and only send a new copy of the code to the server when the hash of the current code in the editor is different from the previous one.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const newCodeHash = await sha256Hash(codeMirror.value?.state.doc.toString()!); | ||
if (newCodeHash !== codeHash) { | ||
setCodeHash(newCodeHash); | ||
await sendMessage(newSystemMessage.content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we fail gracefully if this fails...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll only set the code hash if the request is successful.
there error will also be bubbled-up and handle in the top-level try-catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz test carefully and ensure this functions as expected when llm calls fail
will also set code hash only if the the request was successful|
previously there were instances where the user message will reach the server before the code from the user got there (promises shenanigans). now, the message will be sent only if the code reached the server successfully otherwise it fails and bubbles the error
previously the client chat feature will send 2 requests to the llm api. the first being a copy of the current code and then the chat message sent by the user.
with these changes, we hash the code and only send a new copy of the code to the server when the hash of the current code in the editor is different from the previous one.