Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions penify_hook/llm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ def generate_commit_summary(self, diff: str, message: str, generate_description:
This function constructs a prompt for an LLM to produce a commit title and, if
requested, a detailed description. The summary adheres to Semantic Commit
Messages guidelines. If JIRA context is provided, it enriches the prompt with
relevant issue information.
relevant issue information. The function also handles token limits by
truncating large diffs and includes additional parameters for flexibility.

Args:
diff (str): Git diff of changes.
message (str): User-provided commit message or instructions.
generate_description (bool): Flag indicating whether to include a detailed description in the summary.
repo_details (Dict): Details about the repository.
jira_context (Dict?): Optional JIRA issue context to enhance the summary.
jira_context (Dict?): Optional JIRA issue context to enhance the summary. Defaults to None.
additonal_param (str?): An additional parameter for further customization. Defaults to "".
additonal_param_2 (str?): Another additional parameter for further customization. Defaults to "".

Returns:
Dict: A dictionary containing the title and description for the commit. If
`generate_description` is False, the 'description' key may be absent.
Dict: A dictionary containing 'title' and optionally 'description'.

Raises:
ValueError: If the LLM model is not configured.
ValueError: If the JSON structure from the LLM response is invalid.
Exception: Any other errors during the process, which will exit the script with an error
message.
"""
if not self.model:
raise ValueError("LLM model not configured. Please provide a model when initializing LLMClient.")
Expand Down
Loading