Class: DeepAgents::Models::MockModel
- Defined in:
- lib/deepagents/models.rb
Overview
Mock model for testing
Instance Attribute Summary
Attributes inherited from BaseModel
Instance Method Summary collapse
- #generate(prompt, tools = nil) ⇒ Object
-
#initialize(model: "mock-model") ⇒ MockModel
constructor
A new instance of MockModel.
- #to_langchain_model ⇒ Object
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_model ⇒ Object
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 |