mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-28 19:04:21 +01:00
feat: chain of thought
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user