Class: Brute::Middleware::LLMCall
- Inherits:
-
Object
- Object
- Brute::Middleware::LLMCall
- Defined in:
- lib/brute/middleware/100_llm_call.rb
Overview
Terminal middleware. Calls the LLM with the current conversation, appends the response to the session, and fires events along the way.
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/brute/middleware/100_llm_call.rb', line 12 def call(env) available_tools = env[:tools].each_with_object({}) do |tool, hash| instance = tool.is_a?(Class) ? tool.new : tool instance = instance.to_ruby_llm if instance.respond_to?(:to_ruby_llm) hash[instance.name.to_sym] = instance end = { model: RubyLLM.models.find(env[:model], env[:provider]), tools: available_tools, temperature: env.fetch(:temperature, 0.7), } complete(, env).then do |response| env[:messages] << response end env end |