Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/skills.metta
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
WRITE-FILE-SUCCESS))

(= (append-file $file $str)
(progn (translatePredicate (exists_file $file))
(translatePredicate (open $file append $Out))
(translatePredicate (write $Out $str))
(translatePredicate (nl $Out)),
(translatePredicate (close $Out))
APPEND-FILE-SUCCESS))
(let $sep (line_separator $file)
(progn (translatePredicate (exists_file $file))
(translatePredicate (open $file append $Out))
(translatePredicate (write $Out $sep))
(translatePredicate (write $Out $str))
(translatePredicate (nl $Out))
(translatePredicate (close $Out))
APPEND-FILE-SUCCESS)))

(= (tavily-search $query)
(py-call (agentverse.tavily_search $query)))
Expand All @@ -57,7 +59,7 @@
(= (websearch $msg)
(py-call (websearch.search $msg)))

!(import_prolog_functions_from_file (library OmegaClaw-Core ./src/skills.pl) (shell first_char gc read_file_tail))
!(import_prolog_functions_from_file (library OmegaClaw-Core ./src/skills.pl) (shell first_char gc read_file_tail line_separator))

(= (metta $str)
(let $code (sread $str)
Expand Down
10 changes: 10 additions & 0 deletions src/skills.pl
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@
),
close(In)
).

%Newline needed to start a new line at the end of Path, empty if already at one:
line_separator(Path, Sep) :-
( exists_file(Path),
read_file_tail(Path, 1, Tail),
Tail \== "",
Tail \== "\n"
-> Sep = "\n"
; Sep = ""
).