Skip to content

Commit afe9899

Browse files
committed
Support removing nullable values from LLM request body if the value in extraPayload is null.
Fixes #232
1 parent c21960d commit afe9899

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Support `~` in dynamic string parser.
6+
- Support removing nullable values from LLM request body if the value in extraPayload is null. #232
67

78
## 0.86.0
89

src/eca/llm_providers/openai_chat.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375
(when-let [reasoning-text (or (:reasoning delta)
376376
(:reasoning_content delta))]
377377
(when-not @reasoning-started*
378-
;; Generate new reason-id for each thinking block
378+
;; Generate new reason-id for each thinking block
379379
(let [new-reason-id (str (random-uuid))]
380380
(reset! current-reason-id* new-reason-id)
381381
(reset! reasoning-started* true)

src/eca/shared.clj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@
5959
(cond
6060
(nil? v1) v2
6161
(nil? v2) v1
62-
(and (map? v1) (map? v2)) (merge-with deep-merge v1 v2)
62+
(and (map? v1) (map? v2))
63+
(reduce-kv (fn [m k v]
64+
(if (nil? v)
65+
(dissoc m k)
66+
(assoc m k (rec-merge (get v1 k) v))))
67+
v1
68+
v2)
6369
:else v2))]
6470
(reduce rec-merge v vs)))
6571

test/eca/shared_test.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@
9090
{:a 2})))
9191
(is (= {:a {:b 1}}
9292
(shared/deep-merge {:a 2}
93-
{:a {:b 1}})))))
93+
{:a {:b 1}}))))
94+
(testing "Dissoc nil values"
95+
(is (match?
96+
{:a 1
97+
:b {:c {:e 3
98+
:f 4}}}
99+
(shared/deep-merge {:a 1
100+
:b {:c {:e 3}
101+
:d 2}}
102+
{:b {:c {:f 4}
103+
:d nil}})))))
94104

95105
(deftest future*-test
96106
(testing "on test env we run on same thread"

0 commit comments

Comments
 (0)