llm.rb 0.4.2 → 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 +132 -84
  3. data/lib/json/schema/array.rb +5 -0
  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 +11 -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 +2 -0
  12. data/lib/json/schema.rb +10 -10
  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 +28 -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.2
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-30 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.
@@ -165,6 +179,7 @@ files:
165
179
  - lib/llm/core_ext/ostruct.rb
166
180
  - lib/llm/error.rb
167
181
  - lib/llm/file.rb
182
+ - lib/llm/function.rb
168
183
  - lib/llm/message.rb
169
184
  - lib/llm/mime.rb
170
185
  - lib/llm/model.rb
@@ -173,29 +188,39 @@ files:
173
188
  - lib/llm/providers/anthropic.rb
174
189
  - lib/llm/providers/anthropic/error_handler.rb
175
190
  - lib/llm/providers/anthropic/format.rb
191
+ - lib/llm/providers/anthropic/format/completion_format.rb
176
192
  - lib/llm/providers/anthropic/models.rb
177
193
  - lib/llm/providers/anthropic/response_parser.rb
194
+ - lib/llm/providers/anthropic/response_parser/completion_parser.rb
178
195
  - lib/llm/providers/gemini.rb
179
196
  - lib/llm/providers/gemini/audio.rb
180
197
  - lib/llm/providers/gemini/error_handler.rb
181
198
  - lib/llm/providers/gemini/files.rb
182
199
  - lib/llm/providers/gemini/format.rb
200
+ - lib/llm/providers/gemini/format/completion_format.rb
183
201
  - lib/llm/providers/gemini/images.rb
184
202
  - lib/llm/providers/gemini/models.rb
185
203
  - lib/llm/providers/gemini/response_parser.rb
204
+ - lib/llm/providers/gemini/response_parser/completion_parser.rb
186
205
  - lib/llm/providers/ollama.rb
187
206
  - lib/llm/providers/ollama/error_handler.rb
188
207
  - lib/llm/providers/ollama/format.rb
208
+ - lib/llm/providers/ollama/format/completion_format.rb
189
209
  - lib/llm/providers/ollama/models.rb
190
210
  - lib/llm/providers/ollama/response_parser.rb
211
+ - lib/llm/providers/ollama/response_parser/completion_parser.rb
191
212
  - lib/llm/providers/openai.rb
192
213
  - lib/llm/providers/openai/audio.rb
193
214
  - lib/llm/providers/openai/error_handler.rb
194
215
  - lib/llm/providers/openai/files.rb
195
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
196
219
  - lib/llm/providers/openai/images.rb
197
220
  - lib/llm/providers/openai/models.rb
198
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
199
224
  - lib/llm/providers/openai/responses.rb
200
225
  - lib/llm/providers/voyageai.rb
201
226
  - lib/llm/providers/voyageai/error_handler.rb
@@ -211,7 +236,7 @@ files:
211
236
  - lib/llm/response/filelist.rb
212
237
  - lib/llm/response/image.rb
213
238
  - lib/llm/response/modellist.rb
214
- - lib/llm/response/output.rb
239
+ - lib/llm/response/respond.rb
215
240
  - lib/llm/utils.rb
216
241
  - lib/llm/version.rb
217
242
  - llm.gemspec