feat. Review foot note, docker fix, pass message to reviewer , update tests
This commit is contained in:
@@ -34,9 +34,13 @@ def format_unsupported_ack(command: ParsedCommand) -> str:
|
||||
|
||||
|
||||
def format_result_comment(head_sha: str, result: dict) -> str:
|
||||
usage_note = _format_usage_note(result)
|
||||
markdown_comment = result.get("markdown_comment")
|
||||
if isinstance(markdown_comment, str) and markdown_comment.strip():
|
||||
return _inject_head_sha_marker(head_sha, markdown_comment)
|
||||
body = markdown_comment.strip()
|
||||
if usage_note:
|
||||
body = f"{body}\n\n{usage_note}"
|
||||
return _inject_head_sha_marker(head_sha, body)
|
||||
|
||||
verdict = result.get("verdict", "has_issues")
|
||||
confidence = float(result.get("confidence", 0.0))
|
||||
@@ -64,4 +68,32 @@ def format_result_comment(head_sha: str, result: dict) -> str:
|
||||
f" Suggestion: {suggestion}" if suggestion else " Suggestion: n/a",
|
||||
]
|
||||
)
|
||||
return _inject_head_sha_marker(head_sha, "\n".join(lines).strip())
|
||||
body = "\n".join(lines).strip()
|
||||
if usage_note:
|
||||
body = f"{body}\n\n{usage_note}"
|
||||
return _inject_head_sha_marker(head_sha, body)
|
||||
|
||||
|
||||
def _format_usage_note(result: dict) -> str:
|
||||
meta = result.get("_meta")
|
||||
if not isinstance(meta, dict):
|
||||
return ""
|
||||
|
||||
model = meta.get("model")
|
||||
model_text = model.strip() if isinstance(model, str) and model.strip() else "unknown"
|
||||
|
||||
usage = meta.get("usage")
|
||||
if not isinstance(usage, dict):
|
||||
return f"_Note: model `{model_text}`._"
|
||||
|
||||
input_tokens = usage.get("input_tokens")
|
||||
output_tokens = usage.get("output_tokens")
|
||||
total_tokens = usage.get("total_tokens")
|
||||
parts = [f"model `{model_text}`"]
|
||||
if isinstance(input_tokens, int):
|
||||
parts.append(f"input `{input_tokens}`")
|
||||
if isinstance(output_tokens, int):
|
||||
parts.append(f"output `{output_tokens}`")
|
||||
if isinstance(total_tokens, int):
|
||||
parts.append(f"total `{total_tokens}`")
|
||||
return f"_Note: {', '.join(parts)} tokens used._"
|
||||
|
||||
Reference in New Issue
Block a user