Skip to content

Commit

Permalink
Add explanation for full code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Feb 9, 2024
1 parent afdc5b9 commit 07a93f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/codergpt/explainer/explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ def explain(self, path: Union[str, Path], function: Optional[str] = None, classn
response = self.chain.invoke({"input": f"Explain the following code: \n\n```\n{code}\n```"})
# Pretty print the response
print(f"Explanation for '{classname}':\n{response.content}")
else:
# Explain full code
with open(path, "r") as file:
code = file.read()
response = self.chain.invoke({"input": f"Explain the following code: \n\n```\n{code}\n```"})
# Pretty print the response
print(f"Explanation for the code:\n{response.content}")

# # Ensure path is a string or Path object for consistency
# if isinstance(path, str):
Expand Down

0 comments on commit 07a93f5

Please sign in to comment.