Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/langchainrb_overrides/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class Assistant

alias_method :original_initialize, :initialize

def initialize(id: nil, **kwargs) # rubocop:disable Style/ArgumentsForwarding
def initialize(id: nil, **kwargs, &block) # rubocop:disable Style/ArgumentsForwarding
@id = id
original_initialize(**kwargs) # rubocop:disable Style/ArgumentsForwarding
original_initialize(**kwargs, &block) # rubocop:disable Style/ArgumentsForwarding
end

def save
Expand Down
10 changes: 9 additions & 1 deletion spec/langchainrb_overrides/assistant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ def update!(*)
end

RSpec.describe Langchain::Assistant do
let(:test_block) { proc { "test block executed" } }
let(:tools) { [] }
let(:llm) { Langchain::LLM::GoogleGemini.new(api_key: "123") }
let(:assistant) { described_class.new(llm: llm, id: nil, tools: tools, instructions: "Test instructions", tool_choice: "auto") }
let(:assistant) do
described_class.new(llm: llm, id: nil, tools: tools, instructions: "Test instructions", tool_choice: "auto", &test_block)
end

describe "#initialize" do
it "sets the id and calls original_initialize" do
Expand All @@ -55,6 +58,11 @@ def update!(*)
expect(assistant.instructions).to eq("Test instructions")
expect(assistant.tool_choice).to eq("auto")
end

it "passes the block to the original_initialize" do
assigned_block = assistant.instance_variable_get(:@block)
expect(assigned_block).to eq(test_block)
end
end

describe "#save" do
Expand Down
Loading