Skip to content

Commit 2ee1d0d

Browse files
committed
feat(Chat+Rails): Add with_context method to change configuration during a conversation
1 parent ec4a33d commit 2ee1d0d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/ruby_llm/active_record/acts_as.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ def with_temperature(...)
133133
self
134134
end
135135

136+
def with_context(...)
137+
to_llm.with_context(...)
138+
self
139+
end
140+
136141
def on_new_message(...)
137142
to_llm.on_new_message(...)
138143
self

lib/ruby_llm/chat.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def with_temperature(temperature)
7171
self
7272
end
7373

74+
def with_context(context)
75+
@context = context
76+
@config = context.config
77+
with_model(@model.id, provider: @provider.slug, assume_exists: true)
78+
self
79+
end
80+
7481
def on_new_message(&block)
7582
@on[:new_message] = block
7683
self

0 commit comments

Comments
 (0)