Module: Omakase
- Defined in:
- lib/omakase.rb,
lib/omakase/doc.rb,
lib/omakase/mcp.rb,
lib/omakase/type.rb,
lib/omakase/agent.rb,
lib/omakase/trace.rb,
lib/omakase/memory.rb,
lib/omakase/schema.rb,
lib/omakase/skills.rb,
lib/omakase/request.rb,
lib/omakase/version.rb,
lib/omakase/executor.rb,
lib/omakase/fake_chat.rb,
lib/omakase/generation.rb,
lib/omakase/strategies.rb,
lib/omakase/tools/ruby.rb,
lib/omakase/capabilities.rb,
lib/omakase/strategies/predict.rb,
lib/omakase/strategies/code_act.rb
Defined Under Namespace
Modules: Capabilities, Doc, Executor, MCP, Skills, Strategies, Tools Classes: Agent, FakeChat, Generation, Memory, Request, Schema, Trace, Type
Constant Summary collapse
- Error =
Class.new(StandardError)
- ContractError =
The answer did not match the declared return type.
Class.new(Error)
- ProviderError =
The model or its provider failed. RubyLLM has already retried what it retries.
Class.new(Error)
- CHAT_ARGUMENTS =
What RubyLLM.chat itself takes; every other option is a
with_*call on the chat. %i[model provider protocol assume_model_exists context].freeze
- VERSION =
"0.4.0"
Class Attribute Summary collapse
-
.listener ⇒ Object
Returns the value of attribute listener.
Class Method Summary collapse
-
.build_chat(**options) ⇒ Object
caching: true,thinking: {effort: :high},temperature: 0.2become the chat's own with_* calls. - .chat_factory ⇒ Object
-
.chat_factory=(factory) ⇒ Object
How an agent gets a chat when none was injected.
-
.configure ⇒ Object
Providers, keys, default model, timeouts, logging — all of it is RubyLLM's.
-
.configure_from_env(env = ENV) ⇒ Object
Reads every provider credential RubyLLM knows from the environment: ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OLLAMA_API_BASE, VERTEXAI_PROJECT_ID, ….
- .embedder ⇒ Object
-
.embedder=(embedder) ⇒ Object
How text becomes a vector, for Memory.
- .emit(event, **payload) ⇒ Object
- .executor ⇒ Object
-
.executor=(executor) ⇒ Object
Where generated code runs.
- .provider_options ⇒ Object
Class Attribute Details
.listener ⇒ Object
Returns the value of attribute listener.
102 103 104 |
# File 'lib/omakase.rb', line 102 def listener @listener end |
Class Method Details
.build_chat(**options) ⇒ Object
caching: true, thinking: {effort: :high}, temperature: 0.2 become the
chat's own with_* calls. Caching is on unless you say caching: false: the
tool loop resends the whole chat on every step.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/omakase.rb', line 78 def build_chat(**) chat = RubyLLM.chat(**.slice(*CHAT_ARGUMENTS)) {caching: true, **.except(*CHAT_ARGUMENTS)}.each do |name, value| setter = :"with_#{name}" raise Error, "unknown chat option #{name}: RubyLLM::Chat has no ##{setter}" unless chat.respond_to?(setter) keywords = chat.method(setter).parameters.any? { |kind, _| kind == :keyrest } case value when true then chat.public_send(setter) when Array then chat.public_send(setter, *value) when Hash then keywords ? chat.public_send(setter, **value) : chat.public_send(setter, value) else chat.public_send(setter, value) end end chat end |
.chat_factory ⇒ Object
73 |
# File 'lib/omakase.rb', line 73 def chat_factory = @chat_factory ||= method(:build_chat) |
.chat_factory=(factory) ⇒ Object
How an agent gets a chat when none was injected. Anything answering
call(**options) will do — one line in test_helper.rb keeps a whole suite
off the network, including the class-level calls a job makes.
69 70 71 |
# File 'lib/omakase.rb', line 69 def chat_factory=(factory) @chat_factory = callable!(factory, "chat_factory") end |
.configure ⇒ Object
Providers, keys, default model, timeouts, logging — all of it is RubyLLM's.
29 |
# File 'lib/omakase.rb', line 29 def configure(&) = RubyLLM.configure(&) |
.configure_from_env(env = ENV) ⇒ Object
Reads every provider credential RubyLLM knows from the environment: ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OLLAMA_API_BASE, VERTEXAI_PROJECT_ID, …
33 34 35 36 37 38 39 40 |
# File 'lib/omakase.rb', line 33 def configure_from_env(env = ENV) configure do |config| .each do |option| value = env[option.to_s.upcase] config.public_send(:"#{option}=", value) if value end end end |
.embedder ⇒ Object
64 |
# File 'lib/omakase.rb', line 64 def = @embedder ||= ->(text) { RubyLLM.(text).vectors } |
.embedder=(embedder) ⇒ Object
How text becomes a vector, for Memory. Anything answering call(text)
will do; the model and its provider are RubyLLM's to configure.
60 61 62 |
# File 'lib/omakase.rb', line 60 def () @embedder = callable!(, "embedder") end |
.emit(event, **payload) ⇒ Object
104 |
# File 'lib/omakase.rb', line 104 def emit(event, **payload) = @listener&.call(event, **payload) |
.executor ⇒ Object
56 |
# File 'lib/omakase.rb', line 56 def executor = @executor ||= Executor |
.executor=(executor) ⇒ Object
Where generated code runs. Anything answering call(agent, code, timeout:)
will do — Executor::Subprocess is the reference: a child process, so a
timeout cannot take this one with it.
52 53 54 |
# File 'lib/omakase.rb', line 52 def executor=(executor) @executor = callable!(executor, "executor") end |
.provider_options ⇒ Object
42 43 44 45 46 47 |
# File 'lib/omakase.rb', line 42 def slugs = RubyLLM::Provider.providers.keys RubyLLM::Configuration..select do |option| slugs.any? { |slug| option.to_s.start_with?("#{slug}_") } end end |