Skip to content

Commit e8c52e6

Browse files
committed
🚨 Refactor commit function and update tests
- Update CommitMessage model to use constr for max_length validation - Make git_message_detail optional in CommitMessage model - Adjust test_commit to use fixed token size of 250 - Remove TEST_RESPONSE_TOKEN_SIZE constant from tests
1 parent fdc04f6 commit e8c52e6

File tree

3 files changed

+100
-218
lines changed

3 files changed

+100
-218
lines changed

aicodebot/commands/commit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
from aicodebot.output import OurMarkdown, get_console
55
from aicodebot.prompts import get_prompt
66
from pathlib import Path
7-
from pydantic import BaseModel, Field
7+
from pydantic import BaseModel, Field, constr
88
from rich.panel import Panel
99
import click, os, shutil, subprocess, sys, tempfile
1010

1111

1212
class CommitMessage(BaseModel):
13-
# Important to put the detail first, as it improves the quality of the summary
14-
git_message_detail: str = Field(description="A detailed explanation of the changes made in this commit")
15-
git_message_summary: str = Field(description="A brief summary of the commit message")
13+
git_message_summary: constr(max_length=72) = Field(
14+
description="A brief summary of the commit message (max 72 characters)"
15+
)
16+
git_message_detail: str | None = Field(
17+
default=None, description="An optional detailed explanation of the changes made in this commit"
18+
)
1619

1720

1821
@click.command()

0 commit comments

Comments
 (0)