Skip to content

Commit 72161f3

Browse files
committed
Support moonshot models via anthropic API.
1 parent 9850085 commit 72161f3

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Support moonshot models via anthropic API.
6+
57
## 0.97.4
68

79
- Fix openai request when using non codex models but using openai subscription.

src/eca/llm_util.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
(if (= data-str "[DONE]")
4747
(recur event-line) ; skip [DONE]
4848
(let [event-type (if event-line
49-
(subs event-line 7)
49+
;; Handle both "event: foo" and "event:foo" formats
50+
(string/triml (subs event-line 6))
5051
(-> (json/parse-string data-str true)
5152
:type))]
5253
(cons [event-type (json/parse-string data-str true)]

test/eca/llm_util_test.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@
5454
(is (match?
5555
[["foo.bar" {:type "foo.bar"}]
5656
["foo.baz" {:type "foo.baz"}]]
57+
(llm-util/event-data-seq r)))))
58+
(testing "when no extra space after event: (moonshot/kimi format)"
59+
(with-open [r (io/reader (ByteArrayInputStream. (.getBytes (str "event:content_block_start\n"
60+
"data:{\"type\":\"content_block_start\",\"index\":0}\n"
61+
"\n"
62+
"event:content_block_delta\n"
63+
"data:{\"type\":\"content_block_delta\",\"index\":0}\n"
64+
"\n"
65+
"event:message_delta\n"
66+
"data:{\"type\":\"message_delta\"}"))))]
67+
(is (match?
68+
[["content_block_start" {:type "content_block_start" :index 0}]
69+
["content_block_delta" {:type "content_block_delta" :index 0}]
70+
["message_delta" {:type "message_delta"}]]
5771
(llm-util/event-data-seq r))))))
5872

5973
(deftest provider-api-key-with-key-rc-test

0 commit comments

Comments
 (0)