From c512af083e3c31022bc2d78b0b3c43d7d9356abb Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Mon, 5 Feb 2024 23:44:29 +0000 Subject: [PATCH] Fix #58 --- src/cwhy/conversation/utils.py | 3 +++ src/cwhy/cwhy.py | 1 - src/cwhy/prompts.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cwhy/conversation/utils.py b/src/cwhy/conversation/utils.py index 5ce36d2..b4c5013 100644 --- a/src/cwhy/conversation/utils.py +++ b/src/cwhy/conversation/utils.py @@ -27,4 +27,7 @@ def build_diagnostic_string() -> str: if count > args.max_error_tokens: list.pop() break + + if len(front) + len(back) == n: + return diagnostic return build_diagnostic_string() diff --git a/src/cwhy/cwhy.py b/src/cwhy/cwhy.py index a5c9a78..c7ab2fb 100755 --- a/src/cwhy/cwhy.py +++ b/src/cwhy/cwhy.py @@ -1,5 +1,4 @@ import argparse -import contextlib import os import subprocess import sys diff --git a/src/cwhy/prompts.py b/src/cwhy/prompts.py index e30ca98..832626f 100644 --- a/src/cwhy/prompts.py +++ b/src/cwhy/prompts.py @@ -110,6 +110,9 @@ def build_diagnostic_string() -> str: if count > self.args.max_error_tokens: list.pop() break + + if len(front) + len(back) == n: + return "```\n" + "\n".join(self.diagnostic_lines) + "\n```\n" return build_diagnostic_string() def get_code(self) -> Optional[str]: