Changes from https://github.com/juk0de/ChatMastermind.git #1

Closed
ok wants to merge 176 commits from main into juk
Showing only changes of commit ca3a53e68b - Show all commits

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