Download tools.py from YZ03/YAQIN: direct link, hf CLI and curl.
- Browser
- Download file 561 Bytes
-
https://huggingface.co/spaces/YZ03/YAQIN/resolve/main/tools.py
- Command line
-
hf download hf://spaces/YZ03/YAQIN/tools.py
-
curl -L -o tools.py https://huggingface.co/spaces/YZ03/YAQIN/resolve/main/tools.py
561 Bytes
| from langchain.tools import Tool | |
| from datetime import datetime | |
| def save_to_txt(data: str, filename: str = "research_output.txt"): | |
| timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| formatted_text = f"--- Research Output ---\nTimestamp: {timestamp}\n\n{data}\n\n" | |
| with open(filename, "a", encoding="utf-8") as f: | |
| f.write(formatted_text) | |
| return f"Data successfully saved to {filename}" | |
| save_tool = Tool( | |
| name="save_text_to_file", | |
| func=save_to_txt, | |
| description="Saves structured research data to a text file.", | |
| ) | |