Add temporary chat-request logging (diagnose SwiftChat error)

This commit is contained in:
hermes-agent
2026-09-11 18:44:45 +00:00
parent cb512a7f17
commit beb9b1b3ef
+18
View File
@@ -212,8 +212,26 @@ defmodule N8nOpenaiAdapter.Router do
end
end
# Temporary diagnostics: log the raw chat request (stream flag + headers) so
# we can see exactly what SwiftChat sends. Remove after diagnosis.
defp log_request(conn, data) do
stream = Map.get(data, "stream")
accept = get_req_header(conn, "accept") |> List.first()
content_type = get_req_header(conn, "content-type") |> List.first()
model = Map.get(data, "model")
IO.puts(
"CHAT_REQ model=#{inspect(model)} stream=#{inspect(stream)} " <>
"accept=#{inspect(accept)} content_type=#{inspect(content_type)} " <>
"body=#{Jason.encode!(data) |> String.slice(0, 500)}"
)
end
defp handle_chat(conn) do
data = conn.body_params
# Temporary diagnostics: log the raw chat request so we can see exactly what
# SwiftChat sends (stream flag, headers). Remove after diagnosis.
log_request(conn, data)
model = Map.get(data, "model")
messages = Map.get(data, "messages", [])