Skip to content

Commit 87781b6

Browse files
committed
fix: disable pre-commit checks running before first user message, misc fixes
1 parent 01a8616 commit 87781b6

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

gptme/chat.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,26 @@ def prompt_input(prompt: str, value=None) -> str: # pragma: no cover
327327
def check_for_modifications(log: Log) -> bool:
328328
"""Check if there are any file modifications in last 3 messages or since last user message."""
329329
messages_since_user = []
330+
found_user_message = False
331+
330332
for m in reversed(log):
331333
if m.role == "user":
334+
found_user_message = True
332335
break
333336
messages_since_user.append(m)
334337

338+
# If no user message found, skip the check (only system messages so far)
339+
if not found_user_message:
340+
return False
341+
335342
# FIXME: this is hacky and unreliable
336343
has_modifications = any(
337344
tu.tool in ["save", "patch", "append"]
338345
for m in messages_since_user[:3]
339346
for tu in ToolUse.iter_from_content(m.content)
340347
)
341348
# logger.debug(
342-
# f"Found {len(messages_since_user)} messages since user ({has_modifications=})"
349+
# f"Found {len(messages_since_user)} messages since user ({found_user_message=}, {has_modifications=})"
343350
# )
344351
return has_modifications
345352

gptme/tools/browser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def init() -> ToolSpec:
118118
return tool
119119

120120

121-
# TODO: remove the unnecessary new .is_available property and the .available Callable type union (bool only for simplicity)
122121
@lru_cache
123122
def has_browser_tool():
124123
return browser is not None

gptme/util/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def tools_list(available: bool, langtags: bool):
174174
status = "✓" if tool.is_available else "✗"
175175
print(
176176
f"""
177-
{status} {tool.name}
177+
{status} {tool.name}
178178
{tool.desc}"""
179179
)
180180

0 commit comments

Comments
 (0)