Class: DeepAgents::Models::MockModel

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

Overview

Mock model for testing

Instance Attribute Summary

Attributes inherited from BaseModel

#model

Instance Method Summary collapse

Constructor Details

#initialize(model: "mock-model") ⇒ MockModel



183
184
185
# File 'lib/deepagents/models.rb', line 183

def initialize(model: "mock-model")
  super(model: model)
end

Instance Method Details

#generate(prompt, tools = nil) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/deepagents/models.rb', line 187

def generate(prompt, tools = nil)
  if tools && !tools.empty? && prompt.include?("use tool")
    tool = tools.first
    return {
      content: nil,
      tool_calls: [{
        name: tool.name,
        arguments: Hash[tool.parameters.map { |param| [param, "test_value"] }]
      }]
    }
  else
    return {
      content: "This is a mock response for: #{prompt}",
      tool_calls: []
    }
  end
end

#to_langchain_modelObject



205
206
207
208
209
210
211
212
213
214
# File 'lib/deepagents/models.rb', line 205

def to_langchain_model
  # Create and return a langchainrb mock model
  require 'langchain'
  Langchain::LLM::Base.new.tap do |model|
    # Override the complete method to return mock responses
    def model.complete(prompt:, **_kwargs)
      "This is a mock response from langchain for: #{prompt}"
    end
  end
end