Crestapps core ollama

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core ollama is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for running local and self-hosted Ollama models in CrestApps.Core 2.0. Covers AddOllama and AddCoreAIOllama registration, connections with the Ollama client name and a required Endpoint, configured chat and embedding deployments that declare model capabilities through Features instead of the r

How to use this skill

Skill file

CrestApps.Core Ollama

The CrestApps.Core.AI.Ollama package uses OllamaApiClient (OllamaSharp) to talk to a local or self-hosted Ollama server. No API key is involved; data stays on your infrastructure.

Guidelines

Registration

using CrestApps.Core.AI.Ollama;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddOllama()
    )
);

Raw registration:

builder.Services
    .AddCoreAIServices()
    .AddCoreAIOrchestration()
    .AddCoreAIOllama();

It registers OllamaAIClientProvider, the ProviderAICompletionClient<OllamaClientMarker> completion client, a connection source, and a deployment provider for OllamaConstants.ClientName ("Ollama").

Configuration

{
  "CrestApps": {
    "AI": {
      "Connections": [
        {
          "Name": "local-ollama",
          "ClientName": "Ollama",
          "Endpoint": "http://localhost:11434"
        }
      ],
      "Deployments": [
        {
          "ClientName": "Ollama",
          "ConnectionName": "local-ollama",
          "Name": "llama3.1",
          "Features": [ "textGeneration", "toolCalling", "streaming" ]
        },
        {
          "ClientName": "Ollama",
          "ConnectionName": "local-ollama",
          "Name": "phi3",
          "Features": [ "textGeneration", "streaming" ]
        },
        {
          "ClientName": "Ollama",
          "ConnectionName": "local-ollama",
          "Name": "nomic-embed-text",
          "Features": [ "textEmbedding" ]
        }
      ]
    }
  }
}

Point the slot defaults at the local models:

using CrestApps.Core.AI.Models;

builder.Services.Configure<DefaultAIDeploymentSettings>(settings =>
{
    settings.DefaultChatDeploymentName = "llama3.1";
    settings.DefaultUtilityDeploymentName = "phi3";
    settings.DefaultEmbeddingDeploymentName = "nomic-embed-text";
});
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;

namespace MyApp.Services;

public sealed class LocalModelSelector
{
    private readonly IAIDeploymentManager _deploymentManager;

    public LocalModelSelector(IAIDeploymentManager deploymentManager)
    {
        _deploymentManager = deploymentManager;
    }

    public ValueTask<AIDeployment> GetUtilityModelAsync(CancellationToken cancellationToken = default)
        => _deploymentManager.ResolveSlotAsync(
            AIDeploymentSlotNames.Utility,
            clientName: "Ollama",
            cancellationToken: cancellationToken);
}

The utility slot falls back to the chat slot, so background work (titles, extraction, query rewriting) runs on the chat model when no utility model is set.

Running Ollama

# CPU
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

# NVIDIA GPU
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

docker exec -it ollama ollama pull llama3.1
docker exec -it ollama ollama pull nomic-embed-text
curl http://localhost:11434/api/tags

The CrestApps.Core repository's Aspire AppHost (src/Startup/CrestApps.Core.Aspire.AppHost) can start Ollama alongside the sample hosts.

Troubleshooting

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.