Skip to content

Commit

Permalink
docs: Updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed May 23, 2024
1 parent d622a1e commit 3448329
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,38 @@ Generated C# SDK based on Ollama OpenAPI specification and [official docs](https
### Initializing

```csharp
var ollama = new OllamaApiClient();
using var ollama = new OllamaApiClient();

var models = await ollama.ListModelsAsync();

// Pulling a model and reporting progress
await ollama.PullModelAsync("mistral", status => Console.WriteLine($"({status.Percent}%) {status.Status}"));
await foreach (var response in ollama.PullModelAsync("all-minilm", stream: true))
{
Console.WriteLine($"{response.Status}. Progress: {response.Completed}/{response.Total}");
}
// or just pull the model and wait for it to finish
await ollama.PullModelAndEnsureSuccessAsync("all-minilm");

// Generating an embedding
var embedding = await ollama.GenerateEmbeddingAsync(
model: "all-minilm",
prompt: "hello");

// Streaming a completion directly into the console
// keep reusing the context to keep the chat topic going
IList<long>? context = null;
var enumerable = api.GetCompletionAsync("mistral", "How are you today?");
var enumerable = ollama.GenerateCompletionAsync("llama3", "answer 5 random words", stream: true);
await foreach (var response in enumerable)
{
Console.Write(response.Response);
Console.WriteLine($"> {response.Response}");

context = response.Context;
}

var lastResponse = await api.GetCompletionAsync("mistral", "How are you today?", stream: false).WaitAsync();
context = response.lastResponse;
var lastResponse = await ollama.GenerateCompletionAsync("llama3", "answer 123", stream: false, context: context).WaitAsync();
Console.WriteLine(lastResponse.Response);

var chat = container.ApiClient.Chat("mistral");
var chat = ollama.Chat("mistral");
while (true)
{
var message = await chat.SendAsync("answer 123");
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<PropertyGroup Label="Nuget">
<Version>1.1.2</Version>
<Version>1.1.3</Version>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>tryAGI and contributors</Authors>
Expand Down

0 comments on commit 3448329

Please sign in to comment.