Skip to content

Commit 92fe0ca

Browse files
committed
Add 0 arity frame creation support + mute frames
1 parent 7a6f870 commit 92fe0ca

2 files changed

Lines changed: 60 additions & 26 deletions

File tree

resources/clj-kondo.exports/com.shipclojure/simulflow/hooks/defframe.clj

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,36 @@
77
frame-name (api/token-node (symbol (str name)))
88
pred-name (api/token-node (symbol (str name "?")))]
99
{:node (api/list-node
10-
[(api/token-node 'do)
11-
;; Multi-arity function definition
12-
(api/list-node
13-
[(api/token-node 'defn) frame-name docstring
14-
;; Single arity: (frame-name data)
15-
(api/list-node
16-
[(api/vector-node [(api/token-node 'data)])
10+
[(api/token-node 'do)
11+
;; Multi-arity function definition
12+
(api/list-node
13+
[(api/token-node 'defn) frame-name docstring
14+
;; Zero arity (frame name)
1715
(api/list-node
18-
[(api/token-node 'simulflow.frame/create-frame)
19-
frame-type
20-
(api/token-node 'data)])])
21-
;; Two arity: (frame-name data opts)
22-
(api/list-node
23-
[(api/vector-node [(api/token-node 'data) (api/token-node 'opts)])
16+
[(api/vector-node [])
17+
(api/list-node
18+
[(api/token-node 'simulflow.frame/create-frame)
19+
frame-type])])
20+
;; Single arity: (frame-name data)
2421
(api/list-node
25-
[(api/token-node 'simulflow.frame/create-frame)
26-
frame-type
27-
(api/token-node 'data)
28-
(api/token-node 'opts)])])])
29-
;; Predicate function
30-
(api/list-node
31-
[(api/token-node 'defn) pred-name (str "Checks if frame is of type " frame-name)
32-
(api/vector-node [(api/token-node 'frame)])
33-
(api/list-node
34-
[(api/token-node 'instance?)
35-
frame-name
36-
(api/token-node 'frame)])])])}))
22+
[(api/vector-node [(api/token-node 'data)])
23+
(api/list-node
24+
[(api/token-node 'simulflow.frame/create-frame)
25+
frame-type
26+
(api/token-node 'data)])])
27+
;; Two arity: (frame-name data opts)
28+
(api/list-node
29+
[(api/vector-node [(api/token-node 'data) (api/token-node 'opts)])
30+
(api/list-node
31+
[(api/token-node 'simulflow.frame/create-frame)
32+
frame-type
33+
(api/token-node 'data)
34+
(api/token-node 'opts)])])])
35+
;; Predicate function
36+
(api/list-node
37+
[(api/token-node 'defn) pred-name (str "Checks if frame is of type " frame-name)
38+
(api/vector-node [(api/token-node 'frame)])
39+
(api/list-node
40+
[(api/token-node 'instance?)
41+
frame-name
42+
(api/token-node 'frame)])])])}))

src/simulflow/frame.clj

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
(create-frame :test/frame \"data\")
5252
(create-frame :test/frame \"data\" {:timestamp 1696492800000})
5353
(create-frame :test/frame \"data\" {:timestamp #inst \"2024-10-05T05:00:00.000Z\"})"
54+
([type]
55+
(create-frame type nil {}))
5456
([type data]
5557
(create-frame type data {}))
5658
([type data {:keys [timestamp]}]
@@ -83,6 +85,8 @@
8385
(def ~name
8486
~docstring
8587
(fn
88+
([]
89+
(~name nil {}))
8690
([data#]
8791
(~name data# {}))
8892
([data# opts#]
@@ -378,6 +382,28 @@
378382
"Text input frame for LLM processing"
379383
{:type ::text-input})
380384

385+
;;
386+
;; Mute filter frames
387+
;;
388+
(defframe mute-input-start
389+
"Frame issued when the input in the pipeline should be dropped. Useful when
390+
you don't want to process user input. Either when a function call is in
391+
progress or when the bot is speaking."
392+
{:type ::mute-input-start
393+
:schema :any})
394+
395+
(defframe mute-input-stop
396+
"Frame issued when the input in the pipeline should be dropped. Useful when
397+
you don't want to process user input. Either when a function call is in
398+
progress or when the bot is speaking."
399+
{:type ::mute-input-stop
400+
:schema :any})
401+
402+
;;
403+
;; System frames
404+
;;
405+
;;
406+
381407
(def system-frames #{::system-start
382408
::system-stop
383409
::system-config-change
@@ -391,7 +417,9 @@
391417
::control-interrupt-start
392418
::control-interrupt-stop
393419
::scenario-context-update
394-
::speak-frame})
420+
::speak-frame
421+
::mute-input-start
422+
::mute-input-stop})
395423

396424
(defn system-frame?
397425
"Returns true if the frame is a system frame that should be processed immediately"

0 commit comments

Comments
 (0)