extendable-agents / tools /record_interestingness.py
NeuralNotwork's picture
Update record_interestingness.py
1ce200c verified
raw
history blame
953 Bytes
"""Template for custom function or Pydantic model."""
import csv
from pathlib import Path
def record_interestingness(titles: list[str], uninteresting: list[bool]) -> None:
"""Label the interestingness of the entries.
Args:
titles (list[str]): The titles of the entries to label.
uninteresting (list[bool]): The list of booleans indicating whether the
entry is uninteresting.
"""
assert len(titles) == len(uninteresting)
# Create result.csv if it doesn't exist
result_file = Path("result.csv")
file_exists = result_file.exists()
with open(result_file, "a", newline="") as f:
writer = csv.writer(f)
# Write header if file is new
if not file_exists:
writer.writerow(["title", "uninteresting"])
# Write results
for title, is_uninteresting in zip(titles, uninteresting, strict=True):
writer.writerow([title, int(is_uninteresting)])