Class: DeepAgentsRb::Models::MockModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/deepagents/deepagentsrb/models.rb

Overview

Mock model for testing

Instance Method Summary collapse

Methods inherited from BaseModel

#stream_generate

Constructor Details

#initialize(responses = {}) ⇒ MockModel



118
119
120
121
# File 'lib/deepagents/deepagentsrb/models.rb', line 118

def initialize(responses = {})
  @responses = responses
  @default_response = "I'll help you with that task."
end

Instance Method Details

#generate(prompt, messages) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/deepagents/deepagentsrb/models.rb', line 123

def generate(prompt, messages)
  # Try to match the last user message to a predefined response
  last_user_message = messages.reverse.find { |m| m[:role] == "user" || m["role"] == "user" }
  
  if last_user_message
    content = last_user_message[:content] || last_user_message["content"]
    
    # Check if we have a matching response
    @responses.each do |key, response|
      return response if content.include?(key)
    end
  end
  
  # Return default response if no match found
  @default_response
end