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

fix: Use entire file as context in "Optimize Code" prompt #459

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bryanhuhta
Copy link
Contributor

✨ Description

Currently, we only use the snippet of code displayed to the user as context for the LLM prompt. This has the downside of making the LLM reason with less information. If we pass the entire file (if we have it) to the LLM prompt, this should improve its reasoning ability and give users the chance to ask follow up questions about portions of the code which might be in the same file, but not in the profiling snippet.

Here's an example of a short code snippet in a large file:

image-1

When asked about code in a different part of the same file, the LLM reports it can only reason about the current snippet:

image

With the changes in this PR, the LLM can now reason about the the entire file. Here's a snippet that's part of a larger file:

Screenshot 2025-03-11 at 5 17 43 PM

And here is the LLM's response to asking about a specific part of the file not found in the snippet:

Screenshot 2025-03-11 at 5 07 43 PM

🧪 How to test?

The unit tests should pass

@bryanhuhta bryanhuhta self-assigned this Mar 11, 2025
@bryanhuhta bryanhuhta requested a review from ifrost March 11, 2025 22:21
@github-actions github-actions bot added the fix label Mar 11, 2025
@bryanhuhta bryanhuhta requested review from simonswine, a team and grafakus March 11, 2025 22:21
Copy link
Contributor

Unit test coverage

Lines Statements Branches Functions
Coverage: 12%
12.52% (554/4423) 8.96% (137/1529) 9.23% (122/1321)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant