wkok / openai-clojure

Clojure functions to drive the OpenAI API
https://cljdoc.org/d/net.clojars.wkok/openai-clojure
MIT License
208 stars 28 forks source link

Use buffer instead of sliding buffer and remove LinkedList #60

Closed jianghoy closed 6 months ago

jianghoy commented 6 months ago

Motivation

See #59. Basically, the use of LinkedList is not supported in babashka.

New Implementation

I switched to using a buffer instead of a sliding buffer, so now the buffer will not discard previous input, with the caveat that the streaming will be blocked when there's nothing on the other side of the channel taking streaming response out of the buffer (which I think is reasonable, if the consumer side cannot process fast enough then maybe they need to reconsider rather than just pile everything inside JVM heap). I also picked a arbitrarily large buffer size.

wkok commented 6 months ago

Thank you!