UnderOcean 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UnderOcean --version 1.0.0
                    
NuGet\Install-Package UnderOcean -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UnderOcean" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UnderOcean" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="UnderOcean" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UnderOcean --version 1.0.0
                    
#r "nuget: UnderOcean, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UnderOcean@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UnderOcean&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=UnderOcean&version=1.0.0
                    
Install as a Cake Tool

UnderOcean

A powerful .NET library for AI conversation management with Ollama integration, featuring mixture of experts routing, embedding services, and intelligent conversation handling.

Features

  • Ollama Integration: Seamless integration with Ollama for local AI model execution
  • Mixture of Experts (MoE) Routing: Intelligent routing to select the best model for each query
  • Embedding Services: Generate and work with text embeddings for semantic search
  • Conversation Management: Maintain conversation context and history
  • Tool Support: Extensible tool system for function calling
  • Performance Monitoring: Built-in performance tracking and monitoring

Installation

dotnet add package UnderOcean

Quick Start

Setup Dependency Injection

using Microsoft.Extensions.DependencyInjection;
using UnderOcean.Abstractions;
using UnderOcean.Services;

var services = new ServiceCollection();
services.AddHttpClient();
services.AddSingleton<IOllamaClient>(sp => new OllamaClient(sp.GetRequiredService<HttpClient>()));
services.AddSingleton<IEmbeddingService, EmbeddingService>();
services.AddSingleton<IMoERouter>(sp => new MoERouter(sp.GetRequiredService<IOllamaClient>()));
services.AddSingleton<IChatService, ChatService>();
services.AddSingleton<IConversationManager, ConversationManager>();

var provider = services.BuildServiceProvider();

Basic Conversation

var conversationManager = provider.GetRequiredService<IConversationManager>();

var request = new ConversationRequest(
    UserMessage: "Hello, how are you?",
    SystemPrompt: "You are a helpful assistant.",
    ConversationHistory: new List<ChatMessage>(),
    KnowledgeBase: new List<EmbeddingContext>(),
    AvailableTools: new List<ToolSchema>(),
    Mode: ConversationMode.Auto
);

var response = await conversationManager.ProcessAsync(request, CancellationToken.None);
Console.WriteLine($"Response: {response.Response}");

Working with Embeddings

var embeddingService = provider.GetRequiredService<IEmbeddingService>();

var texts = new[] { "Hello world", "How are you?" };
var embeddings = await embeddingService.EmbedAsync(texts, CancellationToken.None);

// Use embeddings for semantic search or similarity comparison

Tool Integration

var tools = new List<ToolSchema>
{
    new()
    {
        Function = new ToolFunction
        {
            Name = "get_weather",
            Description = "Get current weather information",
            Parameters = new
            {
                type = "object",
                properties = new
                {
                    city = new { type = "string", description = "The city name" }
                },
                required = new[] { "city" }
            }
        }
    }
};

var request = new ConversationRequest(
    UserMessage: "What's the weather in New York?",
    SystemPrompt: "You are a helpful assistant with access to weather data.",
    ConversationHistory: new List<ChatMessage>(),
    KnowledgeBase: new List<EmbeddingContext>(),
    AvailableTools: tools,
    Mode: ConversationMode.Auto
);

Core Components

IOllamaClient

Interface for communicating with Ollama API endpoints.

IEmbeddingService

Service for generating text embeddings using Ollama models.

IMoERouter

Mixture of Experts router that selects the best model for each query based on content analysis.

IConversationManager

High-level service for managing conversations, including context, tools, and routing.

IChatService

Core chat functionality for sending messages and receiving responses.

Configuration

The library supports various configuration options through the service constructors and request parameters:

  • Model Selection: Automatic or manual model selection
  • Conversation Modes: Auto, Direct, or Custom routing
  • Tool Integration: Extensible tool system for function calling
  • Knowledge Base: Semantic search integration with embeddings

Requirements

  • .NET 8.0 or later
  • Ollama running locally or accessible via network
  • Compatible Ollama models installed

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 194 8/28/2025
1.0.2 172 8/27/2025
1.0.1 172 8/27/2025
1.0.0 171 8/27/2025