Spaces:
Sleeping
Sleeping
from db import DB | |
def validate_key(key, db: DB): | |
""" Validate the survey key. """ | |
generated_keys = db.get_document_ids('surveykeys') | |
survey_done = db.get_document_ids('responses') | |
if (key in generated_keys) and (key not in survey_done): | |
return True | |
return False | |
def label_speaker(speaker): | |
if speaker == 'You': | |
return '### Human' | |
elif speaker == 'Other Party': | |
return '### Assistant' | |
def expand_for(num): | |
if num < 2: | |
return True | |
else: | |
return False | |
def check_none_in_dict(dictionary): | |
for key, value in dictionary.items(): | |
if value is None: | |
print(f"Found 'None' value for key: {key}") | |
return True | |
print("No 'None' values found in the dictionary.") | |
return False | |
def check_conversation_input_validity(lst): | |
for i in range(len(lst)): | |
item = lst[i] | |
if item is None: | |
if i < 2: | |
return False | |
last_item = lst[i-1] | |
if last_item[0:9] == '### Human': | |
return True | |
else: | |
return False | |
def wrap_conversation(text: str): | |
wrapped_text = '### Human: ' + text + " ### Assistant:" | |
return wrapped_text | |