Download note_engine.py from shukdevdatta123/Python_Data_Driven_ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/shukdevdatta123/Python_Data_Driven_ChatBot/resolve/2a82cf8c52fe7d16d0fc5abaf4fe0f466c9dcef8/note_engine.py
- Command line
-
hf download hf://spaces/shukdevdatta123/Python_Data_Driven_ChatBot@2a82cf8c52fe7d16d0fc5abaf4fe0f466c9dcef8/note_engine.py
-
curl -L -o note_engine.py https://huggingface.co/spaces/shukdevdatta123/Python_Data_Driven_ChatBot/resolve/2a82cf8c52fe7d16d0fc5abaf4fe0f466c9dcef8/note_engine.py
478 Bytes
| from llama_index.core.tools import FunctionTool | |
| import os | |
| note_file = os.path.join("data", "notes.txt") | |
| def save_note(note): | |
| if not os.path.exists(note_file): | |
| open(note_file, "w") | |
| with open(note_file, "a") as f: | |
| f.writelines([note + "\n"]) | |
| return "note saved" | |
| note_engine = FunctionTool.from_defaults( | |
| fn=save_note, | |
| name="note_saver", | |
| description="this tool can save a text based note to a file for the user", | |
| ) |