Skip to content

Commit 29f8f5e

Browse files
committed
chat.with_instructions(replace: true) now available for POROs
1 parent 15a5cd2 commit 29f8f5e

12 files changed

+1178
-330
lines changed

lib/ruby_llm/chat.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def ask(message = nil, with: {}, &block)
3232

3333
alias say ask
3434

35-
def with_instructions(instructions)
35+
def with_instructions(instructions, replace: false)
36+
@messages = @messages.reject! { |msg| msg.role == :system } if replace
37+
3638
add_message role: :system, content: instructions
3739
self
3840
end

spec/fixtures/vcr_cassettes/chat_basic_chat_functionality_anthropic_claude-3-5-haiku-20241022_replaces_previous_system_messages_when_replace_true.yml

Lines changed: 180 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/vcr_cassettes/chat_basic_chat_functionality_anthropic_claude-3-5-haiku-20241022_successfully_uses_the_system_prompt.yml

Lines changed: 41 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)