-
Notifications
You must be signed in to change notification settings - Fork 770
Move context str generation into configurable function #1039
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
Conversation
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.
Pull Request Overview
This PR refactors the context string generation logic to make it configurable through a function parameter. Previously, the context generation was hardcoded within the aquery
method, but now users can provide custom functions to control how contexts are processed and formatted before being inserted into the final answer.
Key changes:
- Extracted context string generation logic into a configurable
context_str_fn
parameter - Created a
ContextStrFn
protocol to define the interface for custom context functions - Added a default implementation that preserves the original behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/paperqa/settings.py |
Adds ContextStrFn protocol and context_str_fn field to AnswerSettings with proper type configuration |
src/paperqa/docs.py |
Refactors aquery method to use configurable context function and extracts original logic to default_context_str_fn |
tests/test_paperqa.py |
Adds test coverage for custom context string function functionality |
Co-authored-by: Copilot <[email protected]>
…Future-House/paper-qa into move-context-str-into-custom-fn
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.
Nice work overall, thanks for going through the PR comments
Users may want custom control over how contexts are generated and munged before inserting into the final answer. This was previously locked into the
aquery
code, but this exposes it as a configurable function.We may not be the best, but by god, we'll be the most configurable.