How awaescher/ollamasharp works
Project type and purpose
• This is an open-source .NET SDK / client library (“OllamaSharp”) that wraps the Ollama REST API.
• It provides:
• A core HTTP client (OllamaApiClient) for all Ollama endpoints (chat, embeddings, model management, etc.)
• Protocol definitions (OllamaSharp.ModelContextProtocol) for client/server communication and JSON schema types
• A tools engine with C# source generators to generate client‐side stubs for server tools
• A demo console app showcasing usage patterns
• Integration points with Microsoft.Extensions.AI abstractions
File structure
• Top-level directories:
• src/OllamaSharp.ModelContextProtocol – protocol contracts, server classes, JSON schema types
• src/OllamaSharp – the main client library (HttpClient extensions, models, constants, tools, async streaming)
• src/SourceGenerators – a C# source generator for tool support
• demo – a .NET console application demonstrating core scenarios (chat, image chat, model management)
• test & tests – unit and functional tests for both the protocol project and the client library
• Config files: Directory.Build.targets/Packages.props, .github/workflows (CI and docs), docfx.json for API docs
README for additional insights
• Confirms full API coverage, real-time streaming, progress reporting, tools engine via source generators
• Mentions integration as IChatClient/IEmbeddingGenerator in Microsoft.Extensions.AI
Be detailed but focused on core elements
• Data flow (REST calls, streaming tokens, progress events).
• Do not overcomplicate: separate protocol, business logic, extensibility, and runtime calls.