AspireOllamaSharpExtensions Methods
ClassMethods8 members
Extension methods for setting up OllamaSharp client in an
Hosting.IHostApplicationBuilder . AddKeyedOllamaApiClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddKeyedOllamaApiClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extensionAspire Adds
IOllamaApiClient services to the container using the connectionName as the service key. public static class AspireOllamaSharpExtensions{ public static AspireOllamaApiClientBuilder AddKeyedOllamaApiClient( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
UriFormatExceptionThrown when no Ollama endpoint is provided.AddKeyedOllamaApiClient(IHostApplicationBuilder, object, string, Action<OllamaSharpSettings>) Section titled AddKeyedOllamaApiClient(IHostApplicationBuilder, object, string, Action<OllamaSharpSettings>)extensionAspire Adds
IOllamaApiClient services to the container using the specified serviceKey . public static class AspireOllamaSharpExtensions{ public static AspireOllamaApiClientBuilder AddKeyedOllamaApiClient( this IHostApplicationBuilder builder, object serviceKey, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.serviceKey objectA unique key that identifies this instance of the Ollama client service.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
UriFormatExceptionThrown when no Ollama endpoint is provided.AddKeyedOllamaApiClient(IHostApplicationBuilder, object, OllamaSharpSettings) Section titled AddKeyedOllamaApiClient(IHostApplicationBuilder, object, OllamaSharpSettings)extensionAspire Adds
IOllamaApiClient services to the container using the specified serviceKey . public static class AspireOllamaSharpExtensions{ public static AspireOllamaApiClientBuilder AddKeyedOllamaApiClient( this IHostApplicationBuilder builder, object serviceKey, OllamaSharpSettings settings) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.serviceKey objectA unique key that identifies this instance of the Ollama client service.settingsOllamaIOllamaApiClient .Exceptions
UriFormatExceptionThrown when no Ollama endpoint is provided.AddKeyedOllamaSharpChatClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddKeyedOllamaSharpChatClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extension Adds
IOllamaApiClient and AI.IChatClient services to the container using the connectionName as the service key. public static class AspireOllamaSharpExtensions{ public static void AddKeyedOllamaSharpChatClient( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
InvalidOperationExceptionThrown when no Ollama endpoint is provided.AddKeyedOllamaSharpEmbeddingGenerator(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddKeyedOllamaSharpEmbeddingGenerator(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extension Adds
IOllamaApiClient and AI.IEmbeddingGenerator`2 services to the container using the connectionName as the service key. public static class AspireOllamaSharpExtensions{ public static void AddKeyedOllamaSharpEmbeddingGenerator( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
InvalidOperationExceptionThrown when no Ollama endpoint is provided.AddOllamaApiClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddOllamaApiClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extensionAspire Adds
IOllamaApiClient services to the container. public static class AspireOllamaSharpExtensions{ public static AspireOllamaApiClientBuilder AddOllamaApiClient( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
UriFormatExceptionThrown when no Ollama endpoint is provided.AddOllamaSharpChatClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddOllamaSharpChatClient(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extension Adds
IOllamaApiClient and AI.IChatClient services to the container. public static class AspireOllamaSharpExtensions{ public static void AddOllamaSharpChatClient( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
InvalidOperationExceptionThrown when no Ollama endpoint is provided.AddOllamaSharpEmbeddingGenerator(IHostApplicationBuilder, string, Action<OllamaSharpSettings>) Section titled AddOllamaSharpEmbeddingGenerator(IHostApplicationBuilder, string, Action<OllamaSharpSettings>)extension Adds
IOllamaApiClient and AI.IEmbeddingGenerator`2 services to the container. public static class AspireOllamaSharpExtensions{ public static void AddOllamaSharpEmbeddingGenerator( this IHostApplicationBuilder builder, string connectionName, Action<OllamaSharpSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OllamaSharpSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
InvalidOperationExceptionThrown when no Ollama endpoint is provided.