You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
-4
Original file line number
Diff line number
Diff line change
@@ -185,10 +185,6 @@ When adding new features, please include documentation updates:
185
185
- Add inline documentation using YARD comments
186
186
- Keep the README clean and focused on helping new users get started quickly
187
187
188
-
## Philosophy
189
-
190
-
RubyLLM follows certain design philosophies and conventions. Please refer to our [Philosophy Guide](https://rubyllm.com/philosophy) to ensure your contributions align with the project's vision.
191
-
192
188
## Discussions and Issues
193
189
194
190
- For questions and discussions, please use [GitHub Discussions](https://github.com/crmne/ruby_llm/discussions)
> The following model aliases and provider selection features are available in the upcoming version.
50
-
51
46
RubyLLM supports model aliases, so you don't need to remember specific version numbers:
52
47
53
48
```ruby
@@ -69,11 +64,6 @@ See [Working with Models]({% link guides/models.md %}) for more details on model
69
64
70
65
## Instructions (aka System Prompts)
71
66
72
-
{: .warning-title }
73
-
> Coming in v1.1.0
74
-
>
75
-
> chat.with_instructions is coming in 1.1.0. 1.0.x users should use `add_message role: system, content: PROMPT`
76
-
77
67
System prompts allow you to set specific instructions or context that guide the AI's behavior throughout the conversation. These prompts are not directly visible to the user but help shape the AI's responses:
78
68
79
69
```ruby
@@ -86,7 +76,7 @@ chat.with_instructions "You are a helpful Ruby programming assistant. Always inc
86
76
# Now the AI will follow these instructions in all responses
87
77
response = chat.ask "How do I handle file operations in Ruby?"
88
78
89
-
# You can add multiple system messages or update them during the conversation - available from 1.1.0
79
+
# You can add multiple system messages or update them during the conversation
90
80
chat.with_instructions "Always format your code using proper Ruby style conventions and include comments."
Copy file name to clipboardExpand all lines: docs/guides/error-handling.md
+10-4
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,7 @@ end
97
97
98
98
## Handling Tool Errors
99
99
100
-
When using tools, errors can be handled within the tool or in the calling code:
100
+
There are two kinds of errors when working with tools: those the LLM should know about and retry, and those that should bubble up to your application code. Let's handle them appropriately:
101
101
102
102
```ruby
103
103
# Error handling within tools
@@ -110,13 +110,17 @@ class Weather < RubyLLM::Tool
# Return errors the LLM should know about and can retry
115
116
{ error: e.message }
116
117
end
117
118
end
119
+
```
120
+
121
+
Handle program-ending errors at the application level:
118
122
119
-
# Error handling when using tools
123
+
```ruby
120
124
begin
121
125
chat =RubyLLM.chat.with_tool(Calculator)
122
126
chat.ask "What's 1/0?"
@@ -125,6 +129,8 @@ rescue RubyLLM::Error => e
125
129
end
126
130
```
127
131
132
+
Return errors to the LLM when it should try a different approach (like invalid parameters or temporary failures), but let serious problems bubble up to be handled by your application's error tracking. The LLM is smart enough to work with error messages and try alternative approaches, but it shouldn't have to deal with program-ending problems.
133
+
128
134
## Automatic Retries
129
135
130
136
RubyLLM automatically retries on certain transient errors:
Copy file name to clipboardExpand all lines: docs/guides/rails.md
+2-7
Original file line number
Diff line number
Diff line change
@@ -153,25 +153,20 @@ end
153
153
154
154
## Instructions (aka System Prompts)
155
155
156
-
{: .warning-title }
157
-
> Coming in v1.1.0
158
-
>
159
-
> chat.with_instructions is coming in 1.1.0. 1.0.x users should use `chat.messages.create! role: system, content: PROMPT`
160
-
161
156
Instructions help guide the AI's behavior throughout a conversation. With Rails integration, these messages are automatically persisted just like regular chat messages:
162
157
163
158
```ruby
164
159
# Create a new chat
165
160
chat =Chat.create!(model_id:'gpt-4o-mini')
166
161
167
-
# Add instructions (these are persisted) - available from 1.1.0
162
+
# Add instructions (these are persisted)
168
163
chat.with_instructions("You are a helpful Ruby programming assistant. Always include code examples in your responses and explain them line by line.")
169
164
170
165
# Ask questions - the AI will follow the instructions
171
166
response = chat.ask("How do I handle file operations in Ruby?")
172
167
puts response.content # Will include detailed code examples
173
168
174
-
# Add additional instructions - available from 1.1.0
169
+
# Add additional instructions
175
170
chat.with_instructions("Always format your code using proper Ruby style conventions and include comments.")
# When there's an error, the model will receive and explain it
206
-
chat.ask "What's the weather at invalid coordinates 1000, 1000?"
207
-
# => "The coordinates 1000, 1000 are not valid for any location on Earth, as latitude must be between -90 and 90, and longitude must be between -180 and 180. Please provide valid coordinates or a city name for weather information."
230
+
```ruby
231
+
begin
232
+
chat =RubyLLM.chat.with_tool(Weather)
233
+
response = chat.ask "What's the weather in Berlin?"
0 commit comments