Reformat.
This commit is contained in:
@@ -42,7 +42,10 @@ tools = [{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
def process_response(input_string, quotation_check_field):
|
def process_response(input_string, quotation_check_field):
|
||||||
if '{' in input_string:
|
if '{' in input_string:
|
||||||
try:
|
try:
|
||||||
@@ -71,6 +74,7 @@ def process_response(input_string, quotation_check_field):
|
|||||||
else:
|
else:
|
||||||
return input_string
|
return input_string
|
||||||
|
|
||||||
|
|
||||||
def parse_string(to_parse: str):
|
def parse_string(to_parse: str):
|
||||||
parsed_string = to_parse.replace("\"", "\\\"")
|
parsed_string = to_parse.replace("\"", "\\\"")
|
||||||
pattern = r"(?<!\w)'|'(?!\w)"
|
pattern = r"(?<!\w)'|'(?!\w)"
|
||||||
@@ -107,6 +111,7 @@ def parse_string_2(to_parse: str):
|
|||||||
to_parse = to_parse.replace(":", ": ")
|
to_parse = to_parse.replace(":", ": ")
|
||||||
return to_parse
|
return to_parse
|
||||||
|
|
||||||
|
|
||||||
def remove_special_chars_and_escapes(input_string):
|
def remove_special_chars_and_escapes(input_string):
|
||||||
parsed_string = input_string.replace("\\\"", "'")
|
parsed_string = input_string.replace("\\\"", "'")
|
||||||
parsed_string = parsed_string.replace("\n\n", " ")
|
parsed_string = parsed_string.replace("\n\n", " ")
|
||||||
@@ -149,6 +154,7 @@ def make_openai_call(model, messages, token_count, fields_to_check, temperature)
|
|||||||
try_count = 0
|
try_count = 0
|
||||||
return processed_response
|
return processed_response
|
||||||
|
|
||||||
|
|
||||||
def make_openai_instruct_call(model, message: str, token_count, fields_to_check, temperature):
|
def make_openai_instruct_call(model, message: str, token_count, fields_to_check, temperature):
|
||||||
global try_count
|
global try_count
|
||||||
response = openai.Completion.create(
|
response = openai.Completion.create(
|
||||||
@@ -222,4 +228,4 @@ def extract_existing_sections_from_body(my_dict, keys_to_extract):
|
|||||||
if 'sections' in my_dict and isinstance(my_dict['sections'], list) and len(my_dict['sections']) > 0:
|
if 'sections' in my_dict and isinstance(my_dict['sections'], list) and len(my_dict['sections']) > 0:
|
||||||
return list(filter(
|
return list(filter(
|
||||||
lambda item: 'code' in item and item['code'] in keys_to_extract and 'grade' in item and 'name' in item,
|
lambda item: 'code' in item and item['code'] in keys_to_extract and 'grade' in item and 'name' in item,
|
||||||
my_dict['sections']))
|
my_dict['sections']))
|
||||||
|
|||||||
Reference in New Issue
Block a user