Skip to content

Releases: awaescher/OllamaSharp

Release 3.0.8

26 Sep 17:31
79b7fff
Compare
Choose a tag to compare
  • Allow SendToOllamaAsync() to be overridden #87 to support streaming responses in Blazor WASM #84
  • Update RequestOptions #88 with new properties MainGpu, UseMmap, LowVram and more.

Release 3.0.7

12 Sep 05:39
d0bc647
Compare
Choose a tag to compare
  • Exposed RequestOptions (to set the temperature, etc.) when using the Chat class #77

Release 3.0.6

11 Sep 15:24
a11d1b6
Compare
Choose a tag to compare

Release 3.0.5

11 Sep 05:27
Compare
Choose a tag to compare
  • Added OllamaApiClient.IncomingJsonSerializerOptions to control how responses from Ollama are deserialized #78

Release 3.0.4

06 Sep 21:20
Compare
Choose a tag to compare
  • Removed the OllamaApiConsole demo which is now located in an own repository to reduce package updates
  • Added OllamaApiClient.OutgoingJsonSerializerOptions to control how requests to Ollama are serialized #75

Release 3.0.3

06 Sep 21:00
f1f1a62
Compare
Choose a tag to compare
Update README.md

Release 3.0.2

05 Sep 19:31
Compare
Choose a tag to compare

Improved tool chat demos

Release 3.0.1

02 Sep 08:03
Compare
Choose a tag to compare

Fixed tool chat demo and added more unit tests

Release 3.0.0

26 Aug 12:46
Compare
Choose a tag to compare

As announced in discussion #63, this release went through major code changes (see pull request #64) and drops a lot of unnecessary code.

OllamaSharp now uses the IAsyncEnumerable syntax. The following paragraph shows the breaking changes from version 2 to 3.

Breaking changes

Methods on IOllamaApiClient

  • Chat() now returns IAsyncEnumerable<ChatResponseStream?> (prefer the Chat class to build interactive chats)
  • SendChat()/StreamChat() (sync/async) were removed in favor for the new Chat() method
  • CreateModel() overload accepting streaming callbacks was removed, use the IAsyncEnumerable<> syntax
  • PullModel() overload accepting streaming callbacks was removed, use the IAsyncEnumerable<> syntax
  • PushModel() overload accepting streaming callbacks was removed, use the IAsyncEnumerable<> syntax
  • GenerateEmbeddings() is now Embed() to follow the Ollama API naming
  • ShowModelInformation() is now ShowModel() to follow the Ollama API naming
  • StreamCompletion() is now Generate() to follow the Ollama API naming
  • GetCompletion() (sync) was removed in favor for Generate() method

Chat class

  • Send() & SendAs() overloads accepting streaming callbacks were removed, use the IAsyncEnumerable<> syntax
  • Constructor cannot use streamer callbacks anymore, as Send() & SendAs()stream directly

Classes

  • GenerateEmbeddingRequestEmbedRequest
  • GenerateEmbeddingResponseEmbedResponse
  • GenerateCompletionRequestGenerateRequest
  • GenerateCompletionResponseStreamGenerateResponseStream
  • GenerateCompletionDoneResponseStreamGenerateDoneResponseStream
  • ChatResponse was removed as it was only used by the old signature of the Chat() method

Streaming callbacks

A special note to the streaming callbacks that have been removed. Before version 3, it was possible to something like this:

var answer = await chat.Send("hi!", r => Console.Write(r.Message));

Since version 3, all the method overloads accepting these streaming callbacks have been removed in favor for the IAsyncEnumerable syntax:

await foreach (var answerToken in chat.Send("hi!"))
    Console.Write(answerToken);

The second approach, the IAsyncEnumerable syntax, is the modern one and easier to read. However, one tiny detail is missing: You cannot stream the responses and get the whole answer as result at the same time anymore.

Theoretically, you would have to do something like this if you wanted to get the whole result value:

var builder = new StringBuilder();
await foreach (var answerToken in chat.Send("hi!"))
    builder.Append(answerToken);
Console.WriteLine(builder.ToString());

StreamToEnd()

To make this easier, OllamaSharp provides an extension method for IAsyncEnumerable that streams its items to a single result value: StreamToEnd().

With this, you can simply stream the responses into a single value:

var answer = await chat.Send("hi!").StreamToEnd();

If you still want to do something with each item in the IAsyncEnumerable, you can even pass a item callback to the method:

var answer = await chat.Send("hi!").StreamToEnd(token => { ... });

This way, the OllamaApiClient can stream its results as IAsyncEnumerable and the stream processing is done in an extension method instead of having dozens confusing method overloads.

Release 2.1.3

23 Aug 13:20
Compare
Choose a tag to compare
Improve console demos