llm.rb 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +134 -88
  3. data/lib/json/schema/array.rb +6 -2
  4. data/lib/json/schema/boolean.rb +4 -0
  5. data/lib/json/schema/integer.rb +23 -1
  6. data/lib/json/schema/leaf.rb +38 -0
  7. data/lib/json/schema/null.rb +4 -0
  8. data/lib/json/schema/number.rb +23 -1
  9. data/lib/json/schema/object.rb +6 -2
  10. data/lib/json/schema/string.rb +26 -1
  11. data/lib/json/schema/version.rb +8 -0
  12. data/lib/json/schema.rb +34 -23
  13. data/lib/llm/buffer.rb +28 -10
  14. data/lib/llm/chat.rb +26 -1
  15. data/lib/llm/core_ext/ostruct.rb +14 -8
  16. data/lib/llm/file.rb +6 -1
  17. data/lib/llm/function.rb +81 -0
  18. data/lib/llm/message.rb +46 -1
  19. data/lib/llm/providers/anthropic/format/completion_format.rb +73 -0
  20. data/lib/llm/providers/anthropic/format.rb +7 -33
  21. data/lib/llm/providers/anthropic/response_parser/completion_parser.rb +51 -0
  22. data/lib/llm/providers/anthropic/response_parser.rb +1 -9
  23. data/lib/llm/providers/anthropic.rb +4 -3
  24. data/lib/llm/providers/gemini/audio.rb +4 -4
  25. data/lib/llm/providers/gemini/files.rb +5 -4
  26. data/lib/llm/providers/gemini/format/completion_format.rb +54 -0
  27. data/lib/llm/providers/gemini/format.rb +28 -27
  28. data/lib/llm/providers/gemini/images.rb +9 -4
  29. data/lib/llm/providers/gemini/response_parser/completion_parser.rb +46 -0
  30. data/lib/llm/providers/gemini/response_parser.rb +13 -20
  31. data/lib/llm/providers/gemini.rb +3 -12
  32. data/lib/llm/providers/ollama/format/completion_format.rb +72 -0
  33. data/lib/llm/providers/ollama/format.rb +10 -30
  34. data/lib/llm/providers/ollama/response_parser/completion_parser.rb +42 -0
  35. data/lib/llm/providers/ollama/response_parser.rb +8 -11
  36. data/lib/llm/providers/ollama.rb +3 -11
  37. data/lib/llm/providers/openai/audio.rb +6 -6
  38. data/lib/llm/providers/openai/files.rb +3 -3
  39. data/lib/llm/providers/openai/format/completion_format.rb +81 -0
  40. data/lib/llm/providers/openai/format/respond_format.rb +69 -0
  41. data/lib/llm/providers/openai/format.rb +25 -58
  42. data/lib/llm/providers/openai/images.rb +4 -2
  43. data/lib/llm/providers/openai/response_parser/completion_parser.rb +55 -0
  44. data/lib/llm/providers/openai/response_parser/respond_parser.rb +56 -0
  45. data/lib/llm/providers/openai/response_parser.rb +8 -44
  46. data/lib/llm/providers/openai/responses.rb +10 -11
  47. data/lib/llm/providers/openai.rb +5 -16
  48. data/lib/llm/response/{output.rb → respond.rb} +2 -2
  49. data/lib/llm/response.rb +1 -1
  50. data/lib/llm/version.rb +1 -1
  51. data/lib/llm.rb +28 -0
  52. data/llm.gemspec +1 -0
  53. metadata +29 -3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antar Azri
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-04-29 00:00:00.000000000 Z
12
+ date: 2025-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: webmock
@@ -137,6 +137,20 @@ dependencies:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: '6.0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: dotenv
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '2.8'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '2.8'
140
154
  description: llm.rb is a lightweight Ruby library that provides a common interface
141
155
  and set of functionality for multple Large Language Models (LLMs). It is designed
142
156
  to be simple, flexible, and easy to use.
@@ -158,12 +172,14 @@ files:
158
172
  - lib/json/schema/number.rb
159
173
  - lib/json/schema/object.rb
160
174
  - lib/json/schema/string.rb
175
+ - lib/json/schema/version.rb
161
176
  - lib/llm.rb
162
177
  - lib/llm/buffer.rb
163
178
  - lib/llm/chat.rb
164
179
  - lib/llm/core_ext/ostruct.rb
165
180
  - lib/llm/error.rb
166
181
  - lib/llm/file.rb
182
+ - lib/llm/function.rb
167
183
  - lib/llm/message.rb
168
184
  - lib/llm/mime.rb
169
185
  - lib/llm/model.rb
@@ -172,29 +188,39 @@ files:
172
188
  - lib/llm/providers/anthropic.rb
173
189
  - lib/llm/providers/anthropic/error_handler.rb
174
190
  - lib/llm/providers/anthropic/format.rb
191
+ - lib/llm/providers/anthropic/format/completion_format.rb
175
192
  - lib/llm/providers/anthropic/models.rb
176
193
  - lib/llm/providers/anthropic/response_parser.rb
194
+ - lib/llm/providers/anthropic/response_parser/completion_parser.rb
177
195
  - lib/llm/providers/gemini.rb
178
196
  - lib/llm/providers/gemini/audio.rb
179
197
  - lib/llm/providers/gemini/error_handler.rb
180
198
  - lib/llm/providers/gemini/files.rb
181
199
  - lib/llm/providers/gemini/format.rb
200
+ - lib/llm/providers/gemini/format/completion_format.rb
182
201
  - lib/llm/providers/gemini/images.rb
183
202
  - lib/llm/providers/gemini/models.rb
184
203
  - lib/llm/providers/gemini/response_parser.rb
204
+ - lib/llm/providers/gemini/response_parser/completion_parser.rb
185
205
  - lib/llm/providers/ollama.rb
186
206
  - lib/llm/providers/ollama/error_handler.rb
187
207
  - lib/llm/providers/ollama/format.rb
208
+ - lib/llm/providers/ollama/format/completion_format.rb
188
209
  - lib/llm/providers/ollama/models.rb
189
210
  - lib/llm/providers/ollama/response_parser.rb
211
+ - lib/llm/providers/ollama/response_parser/completion_parser.rb
190
212
  - lib/llm/providers/openai.rb
191
213
  - lib/llm/providers/openai/audio.rb
192
214
  - lib/llm/providers/openai/error_handler.rb
193
215
  - lib/llm/providers/openai/files.rb
194
216
  - lib/llm/providers/openai/format.rb
217
+ - lib/llm/providers/openai/format/completion_format.rb
218
+ - lib/llm/providers/openai/format/respond_format.rb
195
219
  - lib/llm/providers/openai/images.rb
196
220
  - lib/llm/providers/openai/models.rb
197
221
  - lib/llm/providers/openai/response_parser.rb
222
+ - lib/llm/providers/openai/response_parser/completion_parser.rb
223
+ - lib/llm/providers/openai/response_parser/respond_parser.rb
198
224
  - lib/llm/providers/openai/responses.rb
199
225
  - lib/llm/providers/voyageai.rb
200
226
  - lib/llm/providers/voyageai/error_handler.rb
@@ -210,7 +236,7 @@ files:
210
236
  - lib/llm/response/filelist.rb
211
237
  - lib/llm/response/image.rb
212
238
  - lib/llm/response/modellist.rb
213
- - lib/llm/response/output.rb
239
+ - lib/llm/response/respond.rb
214
240
  - lib/llm/utils.rb
215
241
  - lib/llm/version.rb
216
242
  - llm.gemspec