Table of Contents

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

stream IAsyncEnumerable<ChatResponseUpdate>

The IAsyncEnumerable<T> to stream.

itemCallback Action<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

stream IAsyncEnumerable<ChatResponseStream>

The IAsyncEnumerable to stream

itemCallback Action<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

stream IAsyncEnumerable<GenerateResponseStream>

The IAsyncEnumerable to stream

itemCallback Action<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

stream IAsyncEnumerable<string>

The IAsyncEnumerable to stream

itemCallback Action<string>

An optional callback to additionally process every single item from the IAsyncEnumerable

Returns

Task<string>

A single response stream append from every IAsyncEnumerable item