File size: 478 Bytes
738b789 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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",
) |