by StackOverlord · 3y ago · 0 comments
Here's how level-1 functions are defined. 'ctx-fn' is just an indirection macro for 'fn' I haven't really used yet.
(defn preserve-ctx [f & [at]]
(let [mem (or at (atom {:ctx true}))]
(ctx-fn
:preserve-ctx [ctx]
(if (->> ctx :it (cmd? :preserve-ctx))
(do (case (:it ctx)
:preserve-ctx/get @mem
:preserve-ctx/reset (doto {:ctx true}
(->> (reset! mem))))
(println (-> ctx :it) "done."))
(-> ctx
(when-not-> (-> :states :preserved)
(as-> $ (ctx-it (merge @mem $) (-> $ :it))))
f
(assoc-in [:states :preserved] true)
(doto (->> (reset! mem))))))))
Edit: reading what I wrote, 'endpoint' is in fact a function returning function, except that since it's the "end" of the chain, it doesn't take a function to call next as argument.The most advanced lib for dealing with LLMs is
https://github.com/zmedelis/bosquet
There is also https://github.com/cjbarre/multi-gpt/tree/main but it hasn't been update in 3 months and seems rather basic.
Alternatively, you can shoot me an email at
(->> '(102 117 110 116 97 105 110 64 109 101 46 99 111 109) (map char) (apply str))
and I'll prepare a repo for what I've been working on. It's usable but I wanted to clear some things up before a public release.