Class IAsyncEnumerableExtensions
- Namespace
- OllamaSharp
- Assembly
- OllamaSharp.dll
Extension methods to stream IAsyncEnumerable to its end and return one single result value
public static class IAsyncEnumerableExtensions
- Inheritance
-
IAsyncEnumerableExtensions
- Inherited Members
Methods
StreamToEndAsync(IAsyncEnumerable<ChatResponseUpdate?>, Action<ChatResponseUpdate?>?)
Streams a given IAsyncEnumerable<T> of response chunks to its end and builds one single OllamaSharp.MicrosoftAi.ChatResponseUpdateAppender out of them.
public static Task<ChatResponseUpdate?> StreamToEndAsync(this IAsyncEnumerable<ChatResponseUpdate?> stream, Action<ChatResponseUpdate?>? itemCallback = null)
Parameters
streamIAsyncEnumerable<ChatResponseUpdate>The IAsyncEnumerable<T> to stream.
itemCallbackAction<ChatResponseUpdate>An optional callback to additionally process every single item from the IAsyncEnumerable.
Returns
- Task<ChatResponseUpdate>
A single OllamaSharp.MicrosoftAi.ChatResponseUpdateAppender built up from every single IAsyncEnumerable item.
StreamToEndAsync(IAsyncEnumerable<ChatResponseStream?>, Action<ChatResponseStream?>?)
Streams a given IAsyncEnumerable of response chunks to its end and builds one single ChatDoneResponseStream out of them.
public static Task<ChatDoneResponseStream?> StreamToEndAsync(this IAsyncEnumerable<ChatResponseStream?> stream, Action<ChatResponseStream?>? itemCallback = null)
Parameters
streamIAsyncEnumerable<ChatResponseStream>The IAsyncEnumerable to stream
itemCallbackAction<ChatResponseStream>An optional callback to additionally process every single item from the IAsyncEnumerable
Returns
- Task<ChatDoneResponseStream>
A single ChatDoneResponseStream built up from every single IAsyncEnumerable item
StreamToEndAsync(IAsyncEnumerable<GenerateResponseStream?>, Action<GenerateResponseStream?>?)
Streams a given IAsyncEnumerable of response chunks to its end and builds one single GenerateDoneResponseStream out of them.
public static Task<GenerateDoneResponseStream?> StreamToEndAsync(this IAsyncEnumerable<GenerateResponseStream?> stream, Action<GenerateResponseStream?>? itemCallback = null)
Parameters
streamIAsyncEnumerable<GenerateResponseStream>The IAsyncEnumerable to stream
itemCallbackAction<GenerateResponseStream>An optional callback to additionally process every single item from the IAsyncEnumerable
Returns
- Task<GenerateDoneResponseStream>
A single GenerateDoneResponseStream built up from every single IAsyncEnumerable item
StreamToEndAsync(IAsyncEnumerable<string>, Action<string>?)
Streams a given IAsyncEnumerable to its end and appends its items to a single response string
public static Task<string> StreamToEndAsync(this IAsyncEnumerable<string> stream, Action<string>? itemCallback = null)
Parameters
streamIAsyncEnumerable<string>The IAsyncEnumerable to stream
itemCallbackAction<string>An optional callback to additionally process every single item from the IAsyncEnumerable