feat: chain of thought

This commit is contained in:
Florian Hönicke
2023-03-21 01:56:36 +01:00
parent 1163ab50f7
commit ab4c7bc090
7 changed files with 254 additions and 109 deletions

View File

@@ -1,3 +1,6 @@
import difflib
def find_between(input_string, start, end):
try:
start_index = input_string.index(start) + len(start)
@@ -10,7 +13,7 @@ def find_between(input_string, start, end):
def clean_content(content):
return content.replace('```', '').strip()
def print_colored(headline, text, color_code):
def print_colored(headline, text, color_code, end='\n'):
if color_code == 'black':
color_code = '30'
elif color_code == 'red':
@@ -30,5 +33,21 @@ def print_colored(headline, text, color_code):
color_start = f"\033[{color_code}m"
reset = "\033[0m"
bold_start = "\033[1m"
print(f"{bold_start}{color_start}{headline}{reset}")
print(f"{color_start}{text}{reset}")
if headline:
print(f"{bold_start}{color_start}{headline}{reset}")
print(f"{color_start}{text}{reset}", end=end)
def find_differences(a, b):
matcher = difflib.SequenceMatcher(None, a, b)
differences = set()
for tag, i1, i2, j1, j2 in matcher.get_opcodes():
if tag == 'replace':
diff_a = a[i1:i2]
diff_b = b[j1:j2]
# Check for mirrored results and only add non-mirrored ones
if (diff_b, diff_a) not in differences:
differences.add((diff_a, diff_b))
return differences