Skip to content

Instantly share code, notes, and snippets.

@Curtis-64
Created October 22, 2023 12:41
Show Gist options
  • Save Curtis-64/d269e76d38a4712a1b4068c9f67d8c75 to your computer and use it in GitHub Desktop.
Save Curtis-64/d269e76d38a4712a1b4068c9f67d8c75 to your computer and use it in GitHub Desktop.
TextBindingFunctionSimulation
Text Binding Function by Curtis White + GPT-4 AD
The goal is to enable the LLM to check something that it cannot reliably perceive. In this case comparing strings.
# Modify the find_and_compare function to check all occurrences of the matching pattern
def find_and_compare(target_string, proximity_before, proximity_after, comparison_type, content_to_search):
# Use regex to find all actual target strings based on proximity text
pattern = re.escape(proximity_before) + r"(.*?)" + re.escape(proximity_after)
matches = re.findall(pattern, content_to_search)
# If matches are found, check each one against the target string
for actual_target_string in matches:
# Perform the specified type of comparison with each actual target string
if comparison_type == 'exact' and actual_target_string == target_string:
return True
elif comparison_type == 'case_insensitive' and actual_target_string.lower() == target_string.lower():
return True
elif comparison_type == 'whitespace_insensitive' and actual_target_string.strip() == target_string.strip():
return True
return False
# Re-run the test with the modified function
test_results_all_occurrences = {key: check_keys_in_program(key, web_config_content, python_program_content) for key in test_keys}
test_results_all_occurrences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment