Closed nsadeh closed 9 months ago
Based on my digging, one would probably want to follow Martian's convention of having separate functions or potentially even Martian specs for sync and async and use different ones depending on the request. Here's where Martian implements that: https://github.com/oliyh/martian/blob/732be670cd26d2a401b3830867589e33817e7fec/hato/src/martian/hato.clj
I tried to refactor my fork to be async-default just so I understand how I'd go about making it support both, but at the moment I can't get it to return a future, only a nil
, by replacing the default interceptors with the async versions and modifying the sse.clj
code to run the async version if it's not streaming. I'll try to do a bit more tomorrow.
Do you see a way to do it?
I got something going: PR https://github.com/wkok/openai-clojure/pull/53
Could you try it out / use it as reference in your implementation?
Description
When passing request option
async?
as described in the documentation, I get aClassCastException: class jdk.internal.net.http.common.MinimalFuture cannot be cast to class clojure.lang.Associative
. This is traced back to the functionresponse-for
incore
.My guess is that there's some code that does something with the response and assumes that it is always a map/Associative when it isn't streaming. I use and like this library enough that I would be happy to fix if you have some initial direction for where the problem is.
Reproduction
I ran the following query:
And got the following stack trace: