identified performance issues with streamed markdown

This commit is contained in:
2026-03-06 13:39:32 -07:00
parent aee7aa7b16
commit c747f1d4ce
8 changed files with 257 additions and 96 deletions

View File

@@ -68,7 +68,8 @@ defmodule ElixirAi.ChatUtils do
{:cont, acc}
end
) do
{:ok, _} ->
{:ok, _response} ->
# Logger.info("AI request completed with response #{inspect(response)}")
:ok
{:error, reason} ->

View File

@@ -34,10 +34,15 @@ defmodule ElixirAi.AiUtils.StreamLineUtils do
end
# last streamed response
def handle_stream_line(server, %{
"choices" => [%{"finish_reason" => "stop"}],
"id" => id
}) do
def handle_stream_line(
server,
%{
"choices" => [%{"finish_reason" => "stop"}],
"id" => id
} = msg
) do
Logger.info("Received end of AI response stream for id #{id} with message: #{inspect(msg)}")
send(
server,
{:ai_text_stream_finish, id}
@@ -113,11 +118,14 @@ defmodule ElixirAi.AiUtils.StreamLineUtils do
end
# end tool call
def handle_stream_line(server, %{
"choices" => [%{"finish_reason" => "tool_calls"}],
"id" => id
}) do
# Logger.info("Received tool call end")
def handle_stream_line(
server,
%{
"choices" => [%{"finish_reason" => "tool_calls"}],
"id" => id
} = message
) do
Logger.info("Received tool_calls_finished with message: #{inspect(message)}")
send(server, {:ai_tool_call_end, id})
end