Spaces:
Runtime error
Runtime error
File size: 563 Bytes
3d44a49 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from typing import List, Union
ValueType = Union[str, List[str]]
def doc_to_text(doc: dict[str, ValueType]) -> str:
history_str = " ".join([f'[{"Human" if i % 2 == 0 else "Assistant"}] {m}' for i, m in enumerate(doc['history'])])
doc_text = f'#Knowledge#: {doc["knowledge"]}\n#Dialogue History#: {history_str}\n#Response#: {doc["response"]}\n#Hallucinated#:'
# breakpoint()
return doc_text
def doc_to_target(doc: dict[str, ValueType]) -> str:
res = "true" if "Hallucination" in doc["BEGIN"] else "false"
# breakpoint()
return res
|