Fix backwards compatibility of -W flag.

This commit is contained in:
Oleksandr Kozachuk 2023-08-05 15:35:27 +02:00
parent 820d938060
commit ca3a53e68b

View File

@ -16,7 +16,7 @@ def read_file(fname: pathlib.Path, tags_only: bool = False) -> Dict[str, Any]:
question = "\n".join(text[question_idx:answer_idx]).strip()
answer = "\n".join(text[answer_idx + 1:]).strip()
return {"question": question, "answer": answer, "tags": tags,
"file": pathlib.Path(fname).name}
"file": fname.name}
def dump_data(data: Dict[str, Any]) -> str:
@ -74,6 +74,7 @@ def create_chat(question: Optional[str],
if file.suffix == '.yaml':
with open(file, 'r') as f:
data = yaml.load(f, Loader=yaml.FullLoader)
data['file'] = file.name
elif file.suffix == '.txt':
data = read_file(file)
else: