kasvith

kasvith

Any tips on streaming LLM responses from Phoenix Sockets?

Hi,

We are trying to develop a LLM chat agent. So far lot of libraries have been written in JS or Python. But Elixir provides an excellent WebSocket support

So we decided to use Elixir Phoenix Sockets to stream responses from LLMs for Chats

Has anyone done this? what are the libraries you used? Any drawbacks on this approach?

Will SSE would be a better option than phoenix sockets?

Most Liked

chrismccord

chrismccord

Creator of Phoenix

Req to chat completions with :into and process send and no other libs required. OpenAI compatible endpoints gives you plug and play with many LLMs, including google’s. You can see langchain here for higher level building blocks and integrations, but it’s shockingly easy to get streaming tokens out to a client wether LiveView or js channels client.

avi-turetsky

avi-turetsky

This has definitely been a pain point for us as well. I know it’s asking for a lot but an equivalent of something like AI SDK by Vercel for elixir would be huge. It’s one of the few times where we’ve really been bit by the smaller ecosystem of elixir. Most of the time you can just write it yourself but as @kasvith mentioned its a lot of manual work to implement streaming for each provider.

ndrean

ndrean

Last Post!

gtcode

gtcode

I’m working on gemini_ex, which will be a comprehensive adapter for Gemini both using Gemini keys and Vertex auth strategies:

https://github.com/nshkrdotcom/gemini_ex/

Today, I added streaming using SSE and a genserver:

https://github.com/nshkrdotcom/gemini_ex/blob/main/STREAMING_ARCHITECTURE.md

Colors for the mermaid diagram were chosen to be in the Elixir style. The implementation is still very much in alpha/unstable phase.

Open to feedback.

Where Next?

Popular in Questions Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement