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

feat: started working on always-fresh context message #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Nov 25, 2024

I've had this idea for a while to gather all the dynamic context, like files, and always output the most up-to-date versions of them right before a user message (not including previous/stale such messages).

This should save considerably on tokens, improve the reliability of patches, and unifies files handling.

Related to #151 and #150

We could also set the current date and time in such a message, instead of the system prompt (#137).


Important

Introduces fresh context message handling by including file paths as files and updating message preparation to ensure latest file versions are used.

  • Behavior:
    • Introduces fresh context message handling in chat.py by including paths as files instead of codeblocks.
    • Updates prepare_messages() in logmanager.py to strip old context and ensure latest file versions are included.
  • Misc:
    • Adds TODOs for handling git context and sorting files by recency and mentions in logmanager.py.
    • Adds Counter import in logmanager.py for file mention tracking.

This description was created by Ellipsis for 592a950. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 592a950 in 1 minute and 56 seconds

More details
  • Looked at 56 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. gptme/logmanager.py:321
  • Draft comment:
    The TODO comment about including git status -vv context is not yet implemented. Ensure this functionality is completed or tracked in an issue before merging.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. gptme/logmanager.py:325
  • Draft comment:
    The TODO comment about getting mentioned files and ensuring their latest versions are in context is not yet implemented. Ensure this functionality is completed or tracked in an issue before merging.
  • Reason this comment was not posted:
    Marked as duplicate.
3. gptme/logmanager.py:331
  • Draft comment:
    The TODO comment about stripping old patches and saves is not yet implemented. Ensure this functionality is completed or tracked in an issue before merging.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_CikcFQ4meMOMBZdj


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

# sort files by last modified time, and include the top N files by mentions and recency
# search for files mentioned in the conversation
files = Counter([f for msg in msgs for f in msg.files])
print(files)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the print(files) statement or replace it with a logging statement for better practice in production code.

Suggested change
print(files)

# First enhance messages with context
if _HAS_RAG:
msgs = enhance_messages(msgs)

# if latest message is a user message, prefix context
# if latest message is a system message (like patch applied), then...?
in_git_repo = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in_git_repo variable is hardcoded to True. Consider dynamically checking if the current directory is a git repository instead.

Suggested change
in_git_repo = True
in_git_repo = shutil.which('git') is not None

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.33%. Comparing base (bc79656) to head (592a950).
Report is 3 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #281      +/-   ##
==========================================
- Coverage   72.33%   72.33%   -0.01%     
==========================================
  Files          64       64              
  Lines        4331     4337       +6     
==========================================
+ Hits         3133     3137       +4     
- Misses       1198     1200       +2     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 70.99% <100.00%> (-0.06%) ⬇️
openai/gpt-4o-mini 70.97% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ErikBjare
Copy link
Owner Author

The more I think about this the more of an improvement I realize that it would be.

I should prioritize this.

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

Successfully merging this pull request may close these issues.

2 participants