disable elixir streaming - not compatible with vLLM endpoints in openai_ex 0.9.18 (returns full response instead of SSE chunks)

This commit is contained in:
Russell Ballestrini 2025-10-15 19:43:23 -04:00
parent c30b3af2de
commit 7fc375a598

View file

@ -54,38 +54,7 @@ end
# Streaming chat with Model 1
IO.puts("=== Streaming Chat (Model 1) ===")
stream_req1 = OpenaiEx.Chat.Completions.new(
model: model_1_id,
messages: [
%{role: "user", content: "Explain quantum entanglement in one sentence."}
],
temperature: 0.5,
max_tokens: 150,
stream: true
)
IO.write("Response: ")
case OpenaiEx.Chat.Completions.create(client1, stream_req1) do
{:ok, stream} ->
stream
|> Stream.each(fn
{:data, chunk} ->
case chunk do
%{"choices" => [%{"delta" => %{"content" => content}} | _]} when not is_nil(content) ->
IO.write(content)
_ ->
:ok
end
_ ->
:ok
end)
|> Stream.run()
IO.puts("\n")
{:error, error} ->
IO.puts("Error: #{inspect(error)}\n")
end
IO.puts("[SKIPPED] Streaming not compatible with vLLM endpoints in openai_ex 0.9.18\n")
# Non-streaming chat with Model 2
IO.puts("=== Non-Streaming Chat (Model 2) ===")
@ -112,38 +81,7 @@ end
# Streaming chat with Model 2
IO.puts("=== Streaming Chat (Model 2) ===")
stream_req2 = OpenaiEx.Chat.Completions.new(
model: model_2_id,
messages: [
%{role: "user", content: "Give a Python Fizzbuzz solution in one line of code?"}
],
temperature: 0.5,
max_tokens: 150,
stream: true
)
IO.write("Response: ")
case OpenaiEx.Chat.Completions.create(client2, stream_req2) do
{:ok, stream} ->
stream
|> Stream.each(fn
{:data, chunk} ->
case chunk do
%{"choices" => [%{"delta" => %{"content" => content}} | _]} when not is_nil(content) ->
IO.write(content)
_ ->
:ok
end
_ ->
:ok
end)
|> Stream.run()
IO.puts("\n")
{:error, error} ->
IO.puts("Error: #{inspect(error)}\n")
end
IO.puts("[SKIPPED] Streaming not compatible with vLLM endpoints in openai_ex 0.9.18\n")
# TTS example
IO.puts("=== TTS Speech Generation ===")