Skip to content

Commit 994df48

Browse files
committed
Clarify readme
1 parent 64607e1 commit 994df48

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,19 @@ end
115115
### 3. Use the Template
116116

117117
```ruby
118-
# Basic usage
119-
RubyLLM.chat.with_template(:extract_metadata, document: @document).complete
118+
chat = RubyLLM.chat
119+
chat.with_template(:extract_metadata, document: @document, additional_context: "Focus on technical details").complete
120+
```
120121

121-
# With context variables
122-
RubyLLM.chat.with_template(:extract_metadata,
123-
document: @document,
124-
additional_context: "Focus on technical details"
125-
).complete
122+
Under the hood, RubyLLM::Template will render the templates with the context variables and apply them to the chat instance using native RubyLLM methods:
126123

127-
# Chaining with other RubyLLM methods
128-
RubyLLM.chat
129-
.with_template(:extract_metadata, document: @document)
130-
.with_model("gpt-4")
131-
.complete
124+
```ruby
125+
chat.add_message(:system, rendered_system_message)
126+
chat.add_message(:user, rendered_user_message)
127+
chat.add_schema(instantiated_schema)
132128
```
133129

130+
134131
## Configuration
135132

136133
### Non-Rails Applications
@@ -166,7 +163,13 @@ Templates are processed in order: system → user → assistant → schema
166163

167164
All context variables passed to `with_template` are available in your ERB templates:
168165

166+
```ruby
167+
chat = RubyLLM.chat
168+
chat.with_template(:message, name: "Alice", urgent: true, documents: @documents)
169+
```
170+
169171
```erb
172+
<!-- /prompts/message/user.txt.erb -->
170173
Hello <%= name %>!
171174
172175
<% if urgent %>

0 commit comments

Comments
 (0)