-
Notifications
You must be signed in to change notification settings - Fork 0
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
Control render formatting, add Daemon.get_document #9
Conversation
ragdaemon/context.py
Outdated
@@ -155,14 +152,23 @@ def remove_diff(self, id: str): | |||
del self.context[path_str] | |||
return id | |||
|
|||
def render(self) -> str: | |||
def render(self, use_xml=False, use_tags=False) -> str: |
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.
Consider documenting the new parameters use_xml
and use_tags
in the docstring to explain their purpose and effect on the output.
output += f"<{path_str}>{tags}\n" | ||
else: | ||
output += f"{path_str}{tags}\n" | ||
|
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 seems like the line_content
construction might be missing a - 1
when accessing file_lines[line]
. Array indices are 0-based, but your line numbers start from 1. This could lead to an IndexError
for the last line.
ragdaemon/daemon.py
Outdated
@@ -125,6 +125,11 @@ def search(self, query: str, n: Optional[int] = None) -> list[dict[str, Any]]: | |||
"""Return a sorted list of nodes that match the query.""" | |||
return self.db.query_graph(query, self.graph, n=n) | |||
|
|||
def get_document(self, filename: str): |
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.
Adding a method to retrieve documents is a good idea for encapsulation. However, it might be beneficial to handle the case where filename
is not present in self.graph.nodes
, to avoid a KeyError
.
MENTAT CODE REVIEW IN ACTIVE DEVELOPMENT. Only in use on mentat and internal repos. The pull request introduces useful features and improvements, particularly the ability to control the rendering format in |
No description provided.