Skip to content

Commit

Permalink
fix(structuredbot)🐛: Fix model construction to use parsed codeblock d…
Browse files Browse the repository at this point in the history
…irectly.

- Updated the StructuredBot to use the parsed codeblock directly in model construction.
- Modified the CommitMessage model to require the footer field explicitly.
  • Loading branch information
ericmjl committed Dec 20, 2024
1 parent 083e749 commit e363690
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions llamabot/bot/structuredbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ def __call__(
if attempt == num_attempts - 1:
if self.allow_failed_validation and last_codeblock is not None:
# If we allow failed validation, return the last attempt
return self.pydantic_model.model_construct(
**json.loads(last_codeblock)
)
return self.pydantic_model.model_construct(**last_codeblock)
raise e

# Otherwise, if we failed, give the LLM the validation error and try again.
Expand Down
4 changes: 3 additions & 1 deletion llamabot/cli/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class CommitMessage(BaseModel):
..., description="Whether or not there is a breaking change in the commit. "
)

footer: str = Field("", description="An optional footer.")
footer: str = Field(
..., description="An optional footer. Most of the time should be empty."
)
emoji: str = Field(..., description="An emoji that represents the commit content.")

@model_validator(mode="after")
Expand Down

0 comments on commit e363690

Please sign in to comment.