LemonAi.Providers.StreamingHelper (lemon_ai v0.1.0)

View Source

Shared helper for the identical stream/3 setup pattern across all AI providers.

Each provider's stream/3 follows the same structure:

  1. Start an EventStream with owner monitoring and timeout
  2. Spawn a supervised task that calls the provider's do_stream logic
  3. Attach the task to the stream for lifecycle management

Summary

Functions

Sets up the standard streaming infrastructure and spawns the provider's streaming function under supervision.

Functions

start_streaming(model, context, opts, do_stream_fn)

Sets up the standard streaming infrastructure and spawns the provider's streaming function under supervision.

do_stream_fn must be a function with arity 4: (stream, model, context, opts).