Liking cljdoc? Tell your friends :D

bosquet.agent.graph


defagentcljmacro

(defagent name graph entry-node node-map)

One-stop macro to define and run an agent To run the agent call (<name> graph entry-node nodemap)

One-stop macro to define and run an agent
To run the agent call (<name> graph entry-node nodemap)
sourceraw docstring

defgraphcljmacro

(defgraph name & edge-defs)

Create a loom digraph that can be run within the agent (edges + optional labels)

Create a loom digraph that can be run within the agent (edges + optional labels)
sourceraw docstring

defnodecljmacro

(defnode name args & body)

Define each node behavior get the current state and execut the body on the state The node function must always return a map with the values to be used in the future states Anything saved in the :completion key will be pushed into history. will be traversed to under the :next key The state in general is of the form {:key1 <output for node behavior> :key2 ... :history [[:node-name {:bosquet/completion....}]..] :trace [[:node1 :node2]...[:node-n :end]] ;the actual path taken by this agent run } Return any keys that you would like to return in the state that you want future nodes to use {:my-key 'some value returned by the llm or the result of a search' :completion 'the result of an llm call that will be added to history' }

Define each node behavior get the current state and execut the body on the state
The node function must always return a map with the values to be used in the future states
Anything saved in the :completion key will be pushed into history.
will be traversed to under the :next key
The state in general is of the form
{:key1  <output for node behavior>
 :key2 ...
 :history [[:node-name {:bosquet/completion....}]..]
 :trace [[:node1 :node2]...[:node-n :end]]   ;the actual path taken by this agent run
} 
Return any keys that you would like to return in the state that you want future nodes to use 
{:my-key 'some value returned by the llm or the result of a search'
 :completion 'the result of an llm call that will be added to history'
}
sourceraw docstring

resume-graphclj

(resume-graph interrupted-result updated-state)

Resume graph execution after human intervention Takes the interrupted state and updated user input to continue execution

Resume graph execution after human intervention
Takes the interrupted state and updated user input to continue execution
sourceraw docstring

run-graphclj

(run-graph graph-def
           node-map
           entry-node
           {:keys [trace __pos history] :as input})

Graph executor run a digraph given

  • graph-def - a loom digraph, branch-conditions and functions to select branches {:graph <loom graph> :condition-maps <optional {:source-node {condition destination-node}..}> :condition-fns <optional {:source-node (fn[state] return values in condi}tion in the condtions map to branch on)}> }
  • a node-map mapping the nodes to behaviors
  • the entry node recording the history(completions) as it traverses the graph
    If a node returns {:interrupt true}, execution pauses and returns interrupt state
Graph executor
run a digraph given 
- graph-def - a loom digraph, branch-conditions and functions to select branches
{:graph <loom graph>
 :condition-maps <optional {:source-node {condition destination-node}..}>
 :condition-fns <optional {:source-node (fn[state] return values in condi}tion in the condtions map to branch on)}>
}
- a node-map mapping the nodes to behaviors
- the entry node 
recording the history(completions) as it traverses the graph  
If a node returns {:interrupt true}, execution pauses and returns interrupt state
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close