eca icon indicating copy to clipboard operation
eca copied to clipboard

Add support for non stream API mode for OpenAI chat provider

Open ikappaki opened this issue 1 year ago • 16 comments

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

Currently, eca only appears to support the OpenAI provider in stream mode. However, some environments do not support streaming at all, which makes it impossible to use the OpenAI provider in those contexts.

At present, setting the stream option to false results in empty responses, indicating that non stream mode is not yet supported.

Could you please consider adding support for non stream API mode for OpenAI?

Thank you

ikappaki avatar Oct 26 '25 13:10 ikappaki

@ikappaki when I started ECA I didn't mean to support non stream APIs, but I think this might be achievable, I will take a look and consider it.

Can you describe if you have interest in openai responses or chat API?

ericdallo avatar Oct 26 '25 14:10 ericdallo

Hi @ericdallo, thanks for considering! I'm interested in the chat/completions API endpoint please.

ikappaki avatar Oct 26 '25 15:10 ikappaki

@ikappaki I have something almost finished in the non-stream branch in case you wanna take a look, it's only missing small fixes regarding threads blocking.

ericdallo avatar Oct 27 '25 12:10 ericdallo

Hi @ericdallo, I took a quick look at the branch, and it seems there’s a logic error in how the code handles the no-stream response. The prompt! function returns the response as a map, but sync-prompt! attempts to dereference it as an atom. Since it’s just a map, this causes an exception that isn’t caught, leaving the ECA chat window hanging with no indication of the error.

Here's a flowstorm screenshot showing prompt! (in green) just about to return a map value (clojure.lang.PersistentArrayMap visible on the top right):

Image

The response was returned from base-chat-request! below:

Image

I’m not yet familiar enough with the code to determine the correct handling here. Could you please have a look?

thanks

ikappaki avatar Oct 27 '25 22:10 ikappaki

Ah I'm sorry, it's still not finished, I'm aware and fixed that, adding support for tools now, I will let you know when I have something testable

ericdallo avatar Oct 27 '25 22:10 ericdallo

I pushed some improvements, it kinda works but failling the tool call loop, I need to think more how to make it loopable since it's sync, the code is not ideal yet.

ericdallo avatar Oct 27 '25 23:10 ericdallo

@ikappaki I think I fixed the loop! still need to fix tests, but a hand helping test would be nice!

ericdallo avatar Oct 28 '25 16:10 ericdallo

HI @ericdallo, thanks for completing the task 🙌I tested both the previous and latest commits, and everything works in the example session I tried. I’ll take a look at the test failures next and will reach out if I get stuck or need your input.

ikappaki avatar Oct 28 '25 19:10 ikappaki

I will fix the test failures and merge the branch, don't worry :) Thank you for testing!

ericdallo avatar Oct 28 '25 19:10 ericdallo

(Ref: #180)

Ah sorry, I thought you were asking for help with the PR test failures 😅. In which case, let me do some more testing. It looks like error responses aren't making it back to the chat window (unless this is one of the tests that is already failing...)

ikappaki avatar Oct 28 '25 19:10 ikappaki

Ah good catch, error messages from LLM may not be showing

ericdallo avatar Oct 28 '25 19:10 ericdallo

Done! LMK if any issues

ericdallo avatar Oct 28 '25 20:10 ericdallo

Thanks, error handling also works fine with latest update!

I’ve noticed that the MS-Windows integration tests are failing and aren’t included in the CI job. I have fixes almost ready, please let me know if you are someone else is already working on this.

ikappaki avatar Oct 29 '25 19:10 ikappaki

@ikappaki Would you mind telling me how you connected Flowstorm? I was having some issues with it.

zikajk avatar Nov 05 '25 16:11 zikajk

Hi @zikajk,

it works out of the box for me:

  1. Merge the ClojureStorm dependencies to eca's base deps or the :dev alias :


{...
 :aliases
 {:1.12-storm {:classpath-overrides {org.clojure/clojure nil}
               :extra-deps {com.github.flow-storm/clojure {:mvn/version "1.12.3-1"}
                            com.github.flow-storm/flow-storm-dbg {:mvn/version "4.5.9"}}}
  ...}}


  1. Either Use the eca :dev alias (which starts an nREPL), connect to it, and enter :dbg to open the FlowStorm UI.
  2. or use the vanila API, and add (fs-api/local-connect) as the first expression in src/eca/main.clj/main. after (require '[flow-storm.api :as fs-api]).

Let me know if you're still having trouble.

ikappaki avatar Nov 06 '25 07:11 ikappaki

@ikappaki Thanks! Works great with vanilla API. But were you able to use ClojureStorm with the running system? By it, I mean connecting to REPL by using its port from stderr? Starting a repl with :dev alias is not really helpful to debug what Eca <-> LLM does.

zikajk avatar Nov 20 '25 19:11 zikajk