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

Control render formatting, add Daemon.get_document #9

Merged
merged 7 commits into from
Apr 23, 2024

Conversation

biobootloader
Copy link
Member

No description provided.

@@ -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:
Copy link

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"

Copy link

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.

@@ -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):
Copy link

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.

Copy link

mentatbot bot commented Apr 19, 2024

MENTAT CODE REVIEW IN ACTIVE DEVELOPMENT. Only in use on mentat and internal repos.
Please Reply with feedback.

The pull request introduces useful features and improvements, particularly the ability to control the rendering format in ContextBuilder and the addition of Daemon.get_document for easier document retrieval. However, there are a few areas where additional error handling and documentation could further improve the robustness and clarity of the changes.

@biobootloader biobootloader merged commit 552a4e0 into main Apr 23, 2024
3 checks passed
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.

1 participant