@@ -38,11 +38,11 @@ defmodule Lightning.AiAssistant.MessageProcessor do
3838 @ impl Oban.Worker
3939 @ spec perform ( Oban.Job . t ( ) ) :: :ok
4040 def perform ( % Oban.Job { args: % { "message_id" => message_id } } ) do
41- Logger . info ( "[MessageProcessor] Processing message: #{ message_id } " )
41+ Logger . debug ( "[MessageProcessor] Processing message: #{ message_id } " )
4242
4343 case process_message ( message_id ) do
4444 { :ok , _updated_session } ->
45- Logger . info (
45+ Logger . debug (
4646 "[MessageProcessor] Successfully processed message: #{ message_id } "
4747 )
4848
@@ -57,7 +57,6 @@ defmodule Lightning.AiAssistant.MessageProcessor do
5757 end
5858 end
5959
60-
6160 @ doc """
6261 Defines the job timeout based on Apollo configuration.
6362
@@ -150,7 +149,11 @@ defmodule Lightning.AiAssistant.MessageProcessor do
150149 end
151150
152151 @ doc false
153- @ spec start_streaming_request ( AiAssistant.ChatSession . t ( ) , String . t ( ) , keyword ( ) ) :: :ok
152+ @ spec start_streaming_request (
153+ AiAssistant.ChatSession . t ( ) ,
154+ String . t ( ) ,
155+ keyword ( )
156+ ) :: :ok
154157 defp start_streaming_request ( session , content , options ) do
155158 # Build payload for Apollo
156159 context = build_context ( session , options )
@@ -173,11 +176,16 @@ defmodule Lightning.AiAssistant.MessageProcessor do
173176
174177 case Lightning.ApolloClient.SSEStream . start_stream ( apollo_url , sse_payload ) do
175178 { :ok , _pid } ->
176- Logger . info ( "[MessageProcessor] Started Apollo SSE stream for session #{ session . id } " )
179+ Logger . debug (
180+ "[MessageProcessor] Started Apollo SSE stream for session #{ session . id } "
181+ )
177182
178183 { :error , reason } ->
179- Logger . error ( "[MessageProcessor] Failed to start Apollo stream: #{ inspect ( reason ) } " )
180- Logger . info ( "[MessageProcessor] Falling back to HTTP client" )
184+ Logger . error (
185+ "[MessageProcessor] Failed to start Apollo stream: #{ inspect ( reason ) } "
186+ )
187+
188+ Logger . debug ( "[MessageProcessor] Falling back to HTTP client" )
181189 # Fall back to existing HTTP implementation
182190 raise "SSE stream failed, falling back to HTTP (not implemented yet)"
183191 end
@@ -239,21 +247,26 @@ defmodule Lightning.AiAssistant.MessageProcessor do
239247 end
240248
241249 @ doc false
242- @ spec start_workflow_streaming_request ( AiAssistant.ChatSession . t ( ) , String . t ( ) , String . t ( ) | nil ) :: :ok
250+ @ spec start_workflow_streaming_request (
251+ AiAssistant.ChatSession . t ( ) ,
252+ String . t ( ) ,
253+ String . t ( ) | nil
254+ ) :: :ok
243255 defp start_workflow_streaming_request ( session , content , code ) do
244256 # Build payload for Apollo workflow_chat
245257 history = get_chat_history ( session )
246258
247- payload = % {
248- "api_key" => Lightning.Config . apollo ( :ai_assistant_api_key ) ,
249- "content" => content ,
250- "existing_yaml" => code ,
251- "history" => history ,
252- "meta" => session . meta || % { } ,
253- "stream" => true
254- }
255- |> Enum . reject ( fn { _ , v } -> is_nil ( v ) end )
256- |> Enum . into ( % { } )
259+ payload =
260+ % {
261+ "api_key" => Lightning.Config . apollo ( :ai_assistant_api_key ) ,
262+ "content" => content ,
263+ "existing_yaml" => code ,
264+ "history" => history ,
265+ "meta" => session . meta || % { } ,
266+ "stream" => true
267+ }
268+ |> Enum . reject ( fn { _ , v } -> is_nil ( v ) end )
269+ |> Enum . into ( % { } )
257270
258271 # Add session ID for Lightning broadcasts
259272 sse_payload = Map . put ( payload , "lightning_session_id" , session . id )
@@ -263,11 +276,16 @@ defmodule Lightning.AiAssistant.MessageProcessor do
263276
264277 case Lightning.ApolloClient.SSEStream . start_stream ( apollo_url , sse_payload ) do
265278 { :ok , _pid } ->
266- Logger . info ( "[MessageProcessor] Started Apollo SSE stream for workflow session #{ session . id } " )
279+ Logger . debug (
280+ "[MessageProcessor] Started Apollo SSE stream for workflow session #{ session . id } "
281+ )
267282
268283 { :error , reason } ->
269- Logger . error ( "[MessageProcessor] Failed to start Apollo workflow stream: #{ inspect ( reason ) } " )
270- Logger . info ( "[MessageProcessor] Falling back to HTTP client" )
284+ Logger . error (
285+ "[MessageProcessor] Failed to start Apollo workflow stream: #{ inspect ( reason ) } "
286+ )
287+
288+ Logger . debug ( "[MessageProcessor] Falling back to HTTP client" )
271289 raise "SSE stream failed, triggering fallback to HTTP"
272290 end
273291
@@ -290,7 +308,6 @@ defmodule Lightning.AiAssistant.MessageProcessor do
290308 )
291309 end
292310
293-
294311 @ doc """
295312 Updates a message's status and broadcasts the change.
296313
@@ -389,7 +406,7 @@ defmodule Lightning.AiAssistant.MessageProcessor do
389406 |> case do
390407 % ChatMessage { id: message_id , status: status } = message
391408 when status in [ :pending , :processing ] ->
392- Logger . info (
409+ Logger . debug (
393410 "[AI Assistant] Updating message #{ message_id } to error status after exception"
394411 )
395412
@@ -466,7 +483,7 @@ defmodule Lightning.AiAssistant.MessageProcessor do
466483 |> case do
467484 % ChatMessage { id: message_id , status: status } = message
468485 when status in [ :pending , :processing ] ->
469- Logger . info (
486+ Logger . debug (
470487 "[AI Assistant] Updating message #{ message_id } to error status after stop=#{ other } "
471488 )
472489
0 commit comments