Module: Ollama

Defined in:
lib/ollama_client.rb,
lib/ollama/dto.rb,
lib/ollama/tool.rb,
lib/ollama/client.rb,
lib/ollama/config.rb,
lib/ollama/errors.rb,
lib/ollama/events.rb,
lib/ollama/openai.rb,
lib/ollama/params.rb,
lib/ollama/prompt.rb,
lib/ollama/options.rb,
lib/ollama/plugins.rb,
lib/ollama/request.rb,
lib/ollama/testing.rb,
lib/ollama/version.rb,
lib/ollama/messages.rb,
lib/ollama/pipeline.rb,
lib/ollama/response.rb,
lib/ollama/tool_dsl.rb,
lib/ollama/providers.rb,
lib/ollama/transport.rb,
lib/ollama/attachment.rb,
lib/ollama/client/raw.rb,
lib/ollama/embeddings.rb,
lib/ollama/middleware.rb,
lib/ollama/schema_dsl.rb,
lib/ollama/client/chat.rb,
lib/ollama/tool_intent.rb,
lib/ollama/api_key_pool.rb,
lib/ollama/capabilities.rb,
lib/ollama/parsers/base.rb,
lib/ollama/parsers/chat.rb,
lib/ollama/stream_event.rb,
lib/ollama/agent/planner.rb,
lib/ollama/chat_response.rb,
lib/ollama/model_profile.rb,
lib/ollama/policies/base.rb,
lib/ollama/tool/function.rb,
lib/ollama/agent/executor.rb,
lib/ollama/agent/messages.rb,
lib/ollama/policies/retry.rb,
lib/ollama/providers/base.rb,
lib/ollama/responses/base.rb,
lib/ollama/responses/chat.rb,
lib/ollama/transport/base.rb,
lib/ollama/transport/mock.rb,
lib/ollama/client/generate.rb,
lib/ollama/parsers/version.rb,
lib/ollama/prompt_adapters.rb,
lib/ollama/middleware/cache.rb,
lib/ollama/multimodal_input.rb,
lib/ollama/parsers/generate.rb,
lib/ollama/policies/timeout.rb,
lib/ollama/providers/ollama.rb,
lib/ollama/providers/openai.rb,
lib/ollama/schema_validator.rb,
lib/ollama/serializers/base.rb,
lib/ollama/serializers/chat.rb,
lib/ollama/client/web_search.rb,
lib/ollama/history_sanitizer.rb,
lib/ollama/middleware/logger.rb,
lib/ollama/policies/fallback.rb,
lib/ollama/transport/request.rb,
lib/ollama/client/tool_intent.rb,
lib/ollama/http_error_handler.rb,
lib/ollama/middleware/metrics.rb,
lib/ollama/middleware/tracing.rb,
lib/ollama/parsers/embeddings.rb,
lib/ollama/parsers/show_model.rb,
lib/ollama/policies/auto_pull.rb,
lib/ollama/rate_limit_handler.rb,
lib/ollama/responses/generate.rb,
lib/ollama/streaming_observer.rb,
lib/ollama/transport/net_http.rb,
lib/ollama/transport/response.rb,
lib/ollama/policies/rate_limit.rb,
lib/ollama/providers/llama_cpp.rb,
lib/ollama/schemas/tool_intent.rb,
lib/ollama/client/openai_compat.rb,
lib/ollama/parsers/list_running.rb,
lib/ollama/policies/repair_json.rb,
lib/ollama/prompt_adapters/base.rb,
lib/ollama/prompt_adapters/qwen.rb,
lib/ollama/prompts/tool_planner.rb,
lib/ollama/responses/embeddings.rb,
lib/ollama/serializers/generate.rb,
lib/ollama/policies/schema_repair.rb,
lib/ollama/prompt_adapters/gemma4.rb,
lib/ollama/serializers/embeddings.rb,
lib/ollama/client/model_management.rb,
lib/ollama/generate_stream_handler.rb,
lib/ollama/json_fragment_extractor.rb,
lib/ollama/prompt_adapters/generic.rb,
lib/ollama/prompt_adapters/deepseek.rb,
lib/ollama/tool/function/parameters.rb,
lib/ollama/client/chat/request_preparer.rb,
lib/ollama/client/chat_stream_processor.rb,
lib/ollama/policies/capability_validation.rb,
lib/ollama/policies/retry/strategies/fixed.rb,
lib/ollama/client/generate/request_preparer.rb,
lib/ollama/policies/retry/strategies/jitter.rb,
lib/ollama/policies/retry/strategies/linear.rb,
lib/ollama/tool/function/parameters/property.rb,
lib/ollama/client/generate/response_formatter.rb,
lib/ollama/policies/retry/strategies/exponential.rb,
sig/ollama/client.rbs

Overview

Ollama - A Ruby client for the Ollama API

Defined Under Namespace

Modules: Agent, Capabilities, Client, DTO, Errors, HttpErrorHandler, Params, Parsers, Policies, PromptAdapters, Prompts, Providers, RateLimitHandler, Responses, Schemas, Serializers, Testing, Transport Classes: ApiKeyPool, Attachment, Base, ChainLink, ChatNotAllowedError, ChatResponse, Config, ConnectionFailedError, Embeddings, Error, Events, GenerateStreamHandler, HTTPError, HistorySanitizer, InvalidJSONError, JsonFragmentExtractor, MalformedResponseError, MalformedStreamError, Messages, Middleware, ModelProfile, ModelUnavailableError, MultimodalInput, NotFoundError, Options, Pipeline, Plugins, Prompt, RateLimitError, RateLimitExhaustedError, Request, Response, RetryExhaustedError, SchemaDSL, SchemaValidator, SchemaViolationError, StreamError, StreamEvent, StreamingObserver, ThinkingFormatError, TimeoutError, Tool, ToolDSL, ToolIntent, UnauthorizedError, UnsupportedCapabilityError, UnsupportedThinkingModel

Constant Summary collapse

VERSION =
"1.4.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.pluginsOllama::Plugins (readonly)

Get the global plugin registry

Returns:



66
67
68
# File 'lib/ollama/plugins.rb', line 66

def plugins
  @plugins
end

Class Method Details

.apply_plugins(client) ⇒ Ollama::Plugins

Apply all plugins to a client

Parameters:

Returns:



79
80
81
# File 'lib/ollama/plugins.rb', line 79

def apply_plugins(client)
  @plugins.apply_all(client)
end

.chat(messages:, **args) ⇒ Object



82
83
84
# File 'lib/ollama_client.rb', line 82

def self.chat(messages:, **args)
  client.chat(messages: messages, **args)
end

.clientObject



77
78
79
80
# File 'lib/ollama_client.rb', line 77

def self.client
  # We clear the cached client if the config is changed/updated, or just instantiate dynamically
  @client ||= Client.new(config: config)
end

.configObject



69
70
71
# File 'lib/ollama_client.rb', line 69

def self.config
  OllamaClient.config
end

.configure(&block) ⇒ Object



73
74
75
# File 'lib/ollama_client.rb', line 73

def self.configure(&block)
  OllamaClient.configure(&block)
end

.embedObject



90
91
92
# File 'lib/ollama_client.rb', line 90

def self.embed(...)
  client.embeddings.embed(...)
end

.generate(prompt:, **args) ⇒ Object



86
87
88
# File 'lib/ollama_client.rb', line 86

def self.generate(prompt:, **args)
  client.generate(prompt: prompt, **args)
end

.plugin(plugin, config: {}) ⇒ Ollama::Plugins

Register a plugin globally

Parameters:

  • plugin (Module, Class)

    Plugin module/class

  • config (Hash) (defaults to: {})

    Plugin configuration

Returns:



72
73
74
# File 'lib/ollama/plugins.rb', line 72

def plugin(plugin, config: {})
  @plugins.register(plugin, config: config)
end