liter_llm 1.18.1-aarch64-linux → 1.18.3-aarch64-linux
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/liter_llm/native.rb +286 -286
- data/lib/liter_llm/version.rb +2 -2
- data/lib/liter_llm.rb +1 -1
- data/lib/liter_llm_rb.so +0 -0
- data/sig/types.rbs +613 -613
- metadata +2 -2
data/lib/liter_llm/native.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:e0640fa51c4d8734f18223e9237ba43259d3d74b3333b04e9697d07147818a61
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify
|
|
5
5
|
# frozen_string_literal: true
|
|
@@ -35,8 +35,11 @@ end
|
|
|
35
35
|
|
|
36
36
|
require native_extension
|
|
37
37
|
module LiterLlm
|
|
38
|
-
#
|
|
39
|
-
|
|
38
|
+
# One part of a structured assistant response.
|
|
39
|
+
#
|
|
40
|
+
# `#[serde(tag = "type", rename_all = "snake_case")]` matches OpenAI's
|
|
41
|
+
# parts-spec discriminator (`"type": "text"`, `"type": "output_image"`, …).
|
|
42
|
+
module AssistantPart
|
|
40
43
|
extend T::Helpers
|
|
41
44
|
extend T::Sig
|
|
42
45
|
|
|
@@ -47,178 +50,167 @@ module LiterLlm
|
|
|
47
50
|
# @return [variant_class] an instance of the appropriate variant
|
|
48
51
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
49
52
|
def self.from_hash(hash)
|
|
50
|
-
discriminator = hash[:
|
|
53
|
+
discriminator = hash[:type] || hash["type"]
|
|
51
54
|
case discriminator
|
|
52
|
-
when "
|
|
53
|
-
when "
|
|
54
|
-
when "
|
|
55
|
-
when "
|
|
56
|
-
when "developer" then MessageDeveloper.from_hash(hash)
|
|
57
|
-
when "function" then MessageFunction.from_hash(hash)
|
|
55
|
+
when "text" then AssistantPartText.from_hash(hash)
|
|
56
|
+
when "refusal" then AssistantPartRefusal.from_hash(hash)
|
|
57
|
+
when "output_image" then AssistantPartOutputImage.from_hash(hash)
|
|
58
|
+
when "output_audio" then AssistantPartOutputAudio.from_hash(hash)
|
|
58
59
|
else raise "Unknown discriminator: #{discriminator}"
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
end
|
|
62
|
-
##
|
|
63
|
-
|
|
64
|
-
include
|
|
63
|
+
## A text segment of the response.
|
|
64
|
+
AssistantPartText = Data.define(:text) do
|
|
65
|
+
include AssistantPart
|
|
65
66
|
extend T::Sig
|
|
66
67
|
|
|
67
|
-
#
|
|
68
|
-
sig { returns(
|
|
69
|
-
def
|
|
70
|
-
sig { returns(T::Boolean) }
|
|
71
|
-
def system? = true
|
|
72
|
-
sig { returns(T::Boolean) }
|
|
73
|
-
def user? = false
|
|
68
|
+
# The text content of this part.
|
|
69
|
+
sig { returns(String) }
|
|
70
|
+
def text = super # rubocop:disable Lint/UselessMethodDefinition
|
|
74
71
|
sig { returns(T::Boolean) }
|
|
75
|
-
def
|
|
72
|
+
def text? = true
|
|
76
73
|
sig { returns(T::Boolean) }
|
|
77
|
-
def
|
|
74
|
+
def refusal? = false
|
|
78
75
|
sig { returns(T::Boolean) }
|
|
79
|
-
def
|
|
76
|
+
def output_image? = false
|
|
80
77
|
sig { returns(T::Boolean) }
|
|
81
|
-
def
|
|
78
|
+
def output_audio? = false
|
|
82
79
|
# @param hash [Hash] deserialized from the native extension
|
|
83
80
|
# @return [self]
|
|
84
81
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
85
82
|
def self.from_hash(hash)
|
|
86
|
-
new(
|
|
83
|
+
new(text: hash[:text] || hash["text"])
|
|
87
84
|
end
|
|
88
85
|
end
|
|
89
|
-
##
|
|
90
|
-
|
|
91
|
-
include
|
|
86
|
+
## A refusal — the model declined to respond.
|
|
87
|
+
AssistantPartRefusal = Data.define(:refusal) do
|
|
88
|
+
include AssistantPart
|
|
92
89
|
extend T::Sig
|
|
93
90
|
|
|
94
|
-
#
|
|
95
|
-
sig { returns(
|
|
96
|
-
def
|
|
97
|
-
sig { returns(T::Boolean) }
|
|
98
|
-
def system? = false
|
|
99
|
-
sig { returns(T::Boolean) }
|
|
100
|
-
def user? = true
|
|
91
|
+
# The refusal reason.
|
|
92
|
+
sig { returns(String) }
|
|
93
|
+
def refusal = super # rubocop:disable Lint/UselessMethodDefinition
|
|
101
94
|
sig { returns(T::Boolean) }
|
|
102
|
-
def
|
|
95
|
+
def text? = false
|
|
103
96
|
sig { returns(T::Boolean) }
|
|
104
|
-
def
|
|
97
|
+
def refusal? = true
|
|
105
98
|
sig { returns(T::Boolean) }
|
|
106
|
-
def
|
|
99
|
+
def output_image? = false
|
|
107
100
|
sig { returns(T::Boolean) }
|
|
108
|
-
def
|
|
101
|
+
def output_audio? = false
|
|
109
102
|
# @param hash [Hash] deserialized from the native extension
|
|
110
103
|
# @return [self]
|
|
111
104
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
112
105
|
def self.from_hash(hash)
|
|
113
|
-
new(
|
|
106
|
+
new(refusal: hash[:refusal] || hash["refusal"])
|
|
114
107
|
end
|
|
115
108
|
end
|
|
116
|
-
##
|
|
117
|
-
|
|
118
|
-
include
|
|
109
|
+
## An image produced by the model (e.g. `gpt-image-1`, Gemini Imagen).
|
|
110
|
+
AssistantPartOutputImage = Data.define(:image_url) do
|
|
111
|
+
include AssistantPart
|
|
119
112
|
extend T::Sig
|
|
120
113
|
|
|
121
|
-
#
|
|
122
|
-
sig { returns(
|
|
123
|
-
def
|
|
124
|
-
sig { returns(T::Boolean) }
|
|
125
|
-
def system? = false
|
|
126
|
-
sig { returns(T::Boolean) }
|
|
127
|
-
def user? = false
|
|
114
|
+
# Image URL or data URI referencing the generated image.
|
|
115
|
+
sig { returns(ImageUrl) }
|
|
116
|
+
def image_url = super # rubocop:disable Lint/UselessMethodDefinition
|
|
128
117
|
sig { returns(T::Boolean) }
|
|
129
|
-
def
|
|
118
|
+
def text? = false
|
|
130
119
|
sig { returns(T::Boolean) }
|
|
131
|
-
def
|
|
120
|
+
def refusal? = false
|
|
132
121
|
sig { returns(T::Boolean) }
|
|
133
|
-
def
|
|
122
|
+
def output_image? = true
|
|
134
123
|
sig { returns(T::Boolean) }
|
|
135
|
-
def
|
|
124
|
+
def output_audio? = false
|
|
136
125
|
# @param hash [Hash] deserialized from the native extension
|
|
137
126
|
# @return [self]
|
|
138
127
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
139
128
|
def self.from_hash(hash)
|
|
140
|
-
new(
|
|
129
|
+
new(image_url: hash[:image_url] || hash["image_url"])
|
|
141
130
|
end
|
|
142
131
|
end
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
include
|
|
132
|
+
## Audio produced by the model (e.g. `gpt-4o-audio-preview`).
|
|
133
|
+
AssistantPartOutputAudio = Data.define(:audio) do
|
|
134
|
+
include AssistantPart
|
|
146
135
|
extend T::Sig
|
|
147
136
|
|
|
148
|
-
#
|
|
149
|
-
sig { returns(
|
|
150
|
-
def
|
|
151
|
-
sig { returns(T::Boolean) }
|
|
152
|
-
def system? = false
|
|
153
|
-
sig { returns(T::Boolean) }
|
|
154
|
-
def user? = false
|
|
137
|
+
# Base64-encoded audio data and its format.
|
|
138
|
+
sig { returns(AudioContent) }
|
|
139
|
+
def audio = super # rubocop:disable Lint/UselessMethodDefinition
|
|
155
140
|
sig { returns(T::Boolean) }
|
|
156
|
-
def
|
|
141
|
+
def text? = false
|
|
157
142
|
sig { returns(T::Boolean) }
|
|
158
|
-
def
|
|
143
|
+
def refusal? = false
|
|
159
144
|
sig { returns(T::Boolean) }
|
|
160
|
-
def
|
|
145
|
+
def output_image? = false
|
|
161
146
|
sig { returns(T::Boolean) }
|
|
162
|
-
def
|
|
147
|
+
def output_audio? = true
|
|
163
148
|
# @param hash [Hash] deserialized from the native extension
|
|
164
149
|
# @return [self]
|
|
165
150
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
166
151
|
def self.from_hash(hash)
|
|
167
|
-
new(
|
|
152
|
+
new(audio: hash[:audio] || hash["audio"])
|
|
168
153
|
end
|
|
169
154
|
end
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
module LiterLlm
|
|
158
|
+
# Storage backend for the response cache.
|
|
159
|
+
module CacheBackend
|
|
160
|
+
extend T::Helpers
|
|
161
|
+
extend T::Sig
|
|
162
|
+
|
|
163
|
+
interface!
|
|
164
|
+
|
|
165
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
166
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
167
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
168
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
169
|
+
def self.from_hash(hash)
|
|
170
|
+
discriminator = hash[:type] || hash["type"]
|
|
171
|
+
case discriminator
|
|
172
|
+
when "memory" then CacheBackendMemory.from_hash(hash)
|
|
173
|
+
when "open_dal" then CacheBackendOpenDal.from_hash(hash)
|
|
174
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
## In-memory LRU cache (default). No external dependencies.
|
|
179
|
+
CacheBackendMemory = Data.define do
|
|
180
|
+
include CacheBackend
|
|
173
181
|
extend T::Sig
|
|
174
182
|
|
|
175
|
-
# @return [DeveloperMessage]
|
|
176
|
-
sig { returns(DeveloperMessage) }
|
|
177
|
-
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
178
|
-
sig { returns(T::Boolean) }
|
|
179
|
-
def system? = false
|
|
180
|
-
sig { returns(T::Boolean) }
|
|
181
|
-
def user? = false
|
|
182
|
-
sig { returns(T::Boolean) }
|
|
183
|
-
def assistant? = false
|
|
184
|
-
sig { returns(T::Boolean) }
|
|
185
|
-
def tool? = false
|
|
186
183
|
sig { returns(T::Boolean) }
|
|
187
|
-
def
|
|
184
|
+
def memory? = true
|
|
188
185
|
sig { returns(T::Boolean) }
|
|
189
|
-
def
|
|
186
|
+
def open_dal? = false
|
|
190
187
|
# @param hash [Hash] deserialized from the native extension
|
|
191
188
|
# @return [self]
|
|
192
189
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
193
190
|
def self.from_hash(hash)
|
|
194
|
-
new
|
|
191
|
+
new
|
|
195
192
|
end
|
|
196
193
|
end
|
|
197
|
-
##
|
|
198
|
-
|
|
199
|
-
include
|
|
194
|
+
## OpenDAL-backed storage. Supports 40+ backends (S3, Redis, GCS, local FS, etc.).
|
|
195
|
+
CacheBackendOpenDal = Data.define(:scheme, :config) do
|
|
196
|
+
include CacheBackend
|
|
200
197
|
extend T::Sig
|
|
201
198
|
|
|
202
|
-
#
|
|
203
|
-
sig { returns(
|
|
204
|
-
def
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def user? = false
|
|
209
|
-
sig { returns(T::Boolean) }
|
|
210
|
-
def assistant? = false
|
|
211
|
-
sig { returns(T::Boolean) }
|
|
212
|
-
def tool? = false
|
|
199
|
+
# OpenDAL scheme name (e.g. "s3", "redis", "fs", "gcs", "azblob").
|
|
200
|
+
sig { returns(String) }
|
|
201
|
+
def scheme = super # rubocop:disable Lint/UselessMethodDefinition
|
|
202
|
+
# Backend-specific configuration as key-value pairs passed to OpenDAL.
|
|
203
|
+
sig { returns(T::Hash[String, String]) }
|
|
204
|
+
def config = super # rubocop:disable Lint/UselessMethodDefinition
|
|
213
205
|
sig { returns(T::Boolean) }
|
|
214
|
-
def
|
|
206
|
+
def memory? = false
|
|
215
207
|
sig { returns(T::Boolean) }
|
|
216
|
-
def
|
|
208
|
+
def open_dal? = true
|
|
217
209
|
# @param hash [Hash] deserialized from the native extension
|
|
218
210
|
# @return [self]
|
|
219
211
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
220
212
|
def self.from_hash(hash)
|
|
221
|
-
new(
|
|
213
|
+
new(scheme: hash[:scheme] || hash["scheme"], config: hash[:config] || hash["config"])
|
|
222
214
|
end
|
|
223
215
|
end
|
|
224
216
|
end
|
|
@@ -341,11 +333,8 @@ module LiterLlm
|
|
|
341
333
|
end
|
|
342
334
|
|
|
343
335
|
module LiterLlm
|
|
344
|
-
#
|
|
345
|
-
|
|
346
|
-
# `#[serde(tag = "type", rename_all = "snake_case")]` matches OpenAI's
|
|
347
|
-
# parts-spec discriminator (`"type": "text"`, `"type": "output_image"`, …).
|
|
348
|
-
module AssistantPart
|
|
336
|
+
# A content part in a multimodal embedding input.
|
|
337
|
+
module EmbeddingContentPart
|
|
349
338
|
extend T::Helpers
|
|
350
339
|
extend T::Sig
|
|
351
340
|
|
|
@@ -358,30 +347,27 @@ module LiterLlm
|
|
|
358
347
|
def self.from_hash(hash)
|
|
359
348
|
discriminator = hash[:type] || hash["type"]
|
|
360
349
|
case discriminator
|
|
361
|
-
when "text" then
|
|
362
|
-
when "
|
|
363
|
-
when "
|
|
364
|
-
when "output_audio" then AssistantPartOutputAudio.from_hash(hash)
|
|
350
|
+
when "text" then EmbeddingContentPartText.from_hash(hash)
|
|
351
|
+
when "image_url" then EmbeddingContentPartImageUrl.from_hash(hash)
|
|
352
|
+
when "image_base64" then EmbeddingContentPartImageBase64.from_hash(hash)
|
|
365
353
|
else raise "Unknown discriminator: #{discriminator}"
|
|
366
354
|
end
|
|
367
355
|
end
|
|
368
356
|
end
|
|
369
|
-
##
|
|
370
|
-
|
|
371
|
-
include
|
|
357
|
+
## Plain text.
|
|
358
|
+
EmbeddingContentPartText = Data.define(:text) do
|
|
359
|
+
include EmbeddingContentPart
|
|
372
360
|
extend T::Sig
|
|
373
361
|
|
|
374
|
-
#
|
|
362
|
+
# @return [String]
|
|
375
363
|
sig { returns(String) }
|
|
376
364
|
def text = super # rubocop:disable Lint/UselessMethodDefinition
|
|
377
365
|
sig { returns(T::Boolean) }
|
|
378
366
|
def text? = true
|
|
379
367
|
sig { returns(T::Boolean) }
|
|
380
|
-
def
|
|
381
|
-
sig { returns(T::Boolean) }
|
|
382
|
-
def output_image? = false
|
|
368
|
+
def image_url? = false
|
|
383
369
|
sig { returns(T::Boolean) }
|
|
384
|
-
def
|
|
370
|
+
def image_base64? = false
|
|
385
371
|
# @param hash [Hash] deserialized from the native extension
|
|
386
372
|
# @return [self]
|
|
387
373
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
@@ -389,95 +375,53 @@ module LiterLlm
|
|
|
389
375
|
new(text: hash[:text] || hash["text"])
|
|
390
376
|
end
|
|
391
377
|
end
|
|
392
|
-
##
|
|
393
|
-
|
|
394
|
-
include
|
|
378
|
+
## Image identified by a data URL or HTTP/HTTPS URL.
|
|
379
|
+
EmbeddingContentPartImageUrl = Data.define(:image_url) do
|
|
380
|
+
include EmbeddingContentPart
|
|
395
381
|
extend T::Sig
|
|
396
382
|
|
|
397
|
-
#
|
|
398
|
-
sig { returns(
|
|
399
|
-
def
|
|
383
|
+
# @return [ImageUrl]
|
|
384
|
+
sig { returns(ImageUrl) }
|
|
385
|
+
def image_url = super # rubocop:disable Lint/UselessMethodDefinition
|
|
400
386
|
sig { returns(T::Boolean) }
|
|
401
387
|
def text? = false
|
|
402
388
|
sig { returns(T::Boolean) }
|
|
403
|
-
def
|
|
404
|
-
sig { returns(T::Boolean) }
|
|
405
|
-
def output_image? = false
|
|
389
|
+
def image_url? = true
|
|
406
390
|
sig { returns(T::Boolean) }
|
|
407
|
-
def
|
|
391
|
+
def image_base64? = false
|
|
408
392
|
# @param hash [Hash] deserialized from the native extension
|
|
409
393
|
# @return [self]
|
|
410
394
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
411
395
|
def self.from_hash(hash)
|
|
412
|
-
new(
|
|
396
|
+
new(image_url: hash[:image_url] || hash["image_url"])
|
|
413
397
|
end
|
|
414
398
|
end
|
|
415
|
-
##
|
|
416
|
-
|
|
417
|
-
include
|
|
399
|
+
## Image encoded as a complete data URL.
|
|
400
|
+
EmbeddingContentPartImageBase64 = Data.define(:image_base64) do
|
|
401
|
+
include EmbeddingContentPart
|
|
418
402
|
extend T::Sig
|
|
419
403
|
|
|
420
|
-
#
|
|
421
|
-
sig { returns(
|
|
422
|
-
def
|
|
423
|
-
sig { returns(T::Boolean) }
|
|
424
|
-
def text? = false
|
|
425
|
-
sig { returns(T::Boolean) }
|
|
426
|
-
def refusal? = false
|
|
427
|
-
sig { returns(T::Boolean) }
|
|
428
|
-
def output_image? = true
|
|
429
|
-
sig { returns(T::Boolean) }
|
|
430
|
-
def output_audio? = false
|
|
431
|
-
# @param hash [Hash] deserialized from the native extension
|
|
432
|
-
# @return [self]
|
|
433
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
434
|
-
def self.from_hash(hash)
|
|
435
|
-
new(image_url: hash[:image_url] || hash["image_url"])
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
## Audio produced by the model (e.g. `gpt-4o-audio-preview`).
|
|
439
|
-
AssistantPartOutputAudio = Data.define(:audio) do
|
|
440
|
-
include AssistantPart
|
|
441
|
-
extend T::Sig
|
|
442
|
-
|
|
443
|
-
# Base64-encoded audio data and its format.
|
|
444
|
-
sig { returns(AudioContent) }
|
|
445
|
-
def audio = super # rubocop:disable Lint/UselessMethodDefinition
|
|
404
|
+
# @return [String]
|
|
405
|
+
sig { returns(String) }
|
|
406
|
+
def image_base64 = super # rubocop:disable Lint/UselessMethodDefinition
|
|
446
407
|
sig { returns(T::Boolean) }
|
|
447
408
|
def text? = false
|
|
448
409
|
sig { returns(T::Boolean) }
|
|
449
|
-
def
|
|
450
|
-
sig { returns(T::Boolean) }
|
|
451
|
-
def output_image? = false
|
|
410
|
+
def image_url? = false
|
|
452
411
|
sig { returns(T::Boolean) }
|
|
453
|
-
def
|
|
412
|
+
def image_base64? = true
|
|
454
413
|
# @param hash [Hash] deserialized from the native extension
|
|
455
414
|
# @return [self]
|
|
456
415
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
457
416
|
def self.from_hash(hash)
|
|
458
|
-
new(
|
|
417
|
+
new(image_base64: hash[:image_base64] || hash["image_base64"])
|
|
459
418
|
end
|
|
460
419
|
end
|
|
461
420
|
end
|
|
462
421
|
|
|
463
422
|
module LiterLlm
|
|
464
|
-
#
|
|
465
|
-
|
|
466
|
-
# # Provider mapping
|
|
467
|
-
#
|
|
468
|
-
# - **OpenAI** (and OpenAI-compatible providers): emitted verbatim as
|
|
469
|
-
# `{"type": "json_schema", "json_schema": {...}}` per the
|
|
470
|
-
# chat-completions spec.
|
|
471
|
-
# - **Gemini / Vertex AI**: translated to
|
|
472
|
-
# `generationConfig.responseMimeType = "application/json"` and
|
|
473
|
-
# `generationConfig.responseSchema = <schema>`. The `name`,
|
|
474
|
-
# `description`, and `strict` fields are dropped — Gemini's
|
|
475
|
-
# structured-output API does not consume them.
|
|
476
|
-
# - **Anthropic**: no native JSON mode. A system instruction is
|
|
477
|
-
# prepended asking the model to respond with valid JSON.
|
|
478
|
-
# `strict` is advisory only; callers should still validate the
|
|
479
|
-
# returned JSON if the schema is load-bearing.
|
|
480
|
-
module ResponseFormat
|
|
423
|
+
# A chat message in a conversation.
|
|
424
|
+
module Message
|
|
481
425
|
extend T::Helpers
|
|
482
426
|
extend T::Sig
|
|
483
427
|
|
|
@@ -488,157 +432,178 @@ module LiterLlm
|
|
|
488
432
|
# @return [variant_class] an instance of the appropriate variant
|
|
489
433
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
490
434
|
def self.from_hash(hash)
|
|
491
|
-
discriminator = hash[:
|
|
435
|
+
discriminator = hash[:role] || hash["role"]
|
|
492
436
|
case discriminator
|
|
493
|
-
when "
|
|
494
|
-
when "
|
|
495
|
-
when "
|
|
437
|
+
when "system" then MessageSystem.from_hash(hash)
|
|
438
|
+
when "user" then MessageUser.from_hash(hash)
|
|
439
|
+
when "assistant" then MessageAssistant.from_hash(hash)
|
|
440
|
+
when "tool" then MessageTool.from_hash(hash)
|
|
441
|
+
when "developer" then MessageDeveloper.from_hash(hash)
|
|
442
|
+
when "function" then MessageFunction.from_hash(hash)
|
|
496
443
|
else raise "Unknown discriminator: #{discriminator}"
|
|
497
444
|
end
|
|
498
445
|
end
|
|
499
446
|
end
|
|
500
|
-
##
|
|
501
|
-
|
|
502
|
-
include
|
|
447
|
+
## Variant MessageSystem of the Message sum type.
|
|
448
|
+
MessageSystem = Data.define(:value) do
|
|
449
|
+
include Message
|
|
503
450
|
extend T::Sig
|
|
504
451
|
|
|
452
|
+
# @return [SystemMessage]
|
|
453
|
+
sig { returns(SystemMessage) }
|
|
454
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
505
455
|
sig { returns(T::Boolean) }
|
|
506
|
-
def
|
|
456
|
+
def system? = true
|
|
507
457
|
sig { returns(T::Boolean) }
|
|
508
|
-
def
|
|
458
|
+
def user? = false
|
|
509
459
|
sig { returns(T::Boolean) }
|
|
510
|
-
def
|
|
460
|
+
def assistant? = false
|
|
461
|
+
sig { returns(T::Boolean) }
|
|
462
|
+
def tool? = false
|
|
463
|
+
sig { returns(T::Boolean) }
|
|
464
|
+
def developer? = false
|
|
465
|
+
sig { returns(T::Boolean) }
|
|
466
|
+
def function? = false
|
|
511
467
|
# @param hash [Hash] deserialized from the native extension
|
|
512
468
|
# @return [self]
|
|
513
469
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
514
470
|
def self.from_hash(hash)
|
|
515
|
-
new
|
|
471
|
+
new(value: hash[:_0] || hash["_0"])
|
|
516
472
|
end
|
|
517
473
|
end
|
|
518
|
-
##
|
|
519
|
-
|
|
520
|
-
include
|
|
474
|
+
## Variant MessageUser of the Message sum type.
|
|
475
|
+
MessageUser = Data.define(:value) do
|
|
476
|
+
include Message
|
|
521
477
|
extend T::Sig
|
|
522
478
|
|
|
479
|
+
# @return [UserMessage]
|
|
480
|
+
sig { returns(UserMessage) }
|
|
481
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
523
482
|
sig { returns(T::Boolean) }
|
|
524
|
-
def
|
|
483
|
+
def system? = false
|
|
525
484
|
sig { returns(T::Boolean) }
|
|
526
|
-
def
|
|
485
|
+
def user? = true
|
|
527
486
|
sig { returns(T::Boolean) }
|
|
528
|
-
def
|
|
487
|
+
def assistant? = false
|
|
488
|
+
sig { returns(T::Boolean) }
|
|
489
|
+
def tool? = false
|
|
490
|
+
sig { returns(T::Boolean) }
|
|
491
|
+
def developer? = false
|
|
492
|
+
sig { returns(T::Boolean) }
|
|
493
|
+
def function? = false
|
|
529
494
|
# @param hash [Hash] deserialized from the native extension
|
|
530
495
|
# @return [self]
|
|
531
496
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
532
497
|
def self.from_hash(hash)
|
|
533
|
-
new
|
|
498
|
+
new(value: hash[:_0] || hash["_0"])
|
|
534
499
|
end
|
|
535
500
|
end
|
|
536
|
-
##
|
|
537
|
-
|
|
538
|
-
include
|
|
501
|
+
## Variant MessageAssistant of the Message sum type.
|
|
502
|
+
MessageAssistant = Data.define(:value) do
|
|
503
|
+
include Message
|
|
539
504
|
extend T::Sig
|
|
540
505
|
|
|
541
|
-
# @return [
|
|
542
|
-
sig { returns(
|
|
543
|
-
def
|
|
506
|
+
# @return [AssistantMessage]
|
|
507
|
+
sig { returns(AssistantMessage) }
|
|
508
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
544
509
|
sig { returns(T::Boolean) }
|
|
545
|
-
def
|
|
510
|
+
def system? = false
|
|
546
511
|
sig { returns(T::Boolean) }
|
|
547
|
-
def
|
|
512
|
+
def user? = false
|
|
548
513
|
sig { returns(T::Boolean) }
|
|
549
|
-
def
|
|
514
|
+
def assistant? = true
|
|
515
|
+
sig { returns(T::Boolean) }
|
|
516
|
+
def tool? = false
|
|
517
|
+
sig { returns(T::Boolean) }
|
|
518
|
+
def developer? = false
|
|
519
|
+
sig { returns(T::Boolean) }
|
|
520
|
+
def function? = false
|
|
550
521
|
# @param hash [Hash] deserialized from the native extension
|
|
551
522
|
# @return [self]
|
|
552
523
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
553
524
|
def self.from_hash(hash)
|
|
554
|
-
new(
|
|
555
|
-
end
|
|
556
|
-
end
|
|
557
|
-
end
|
|
558
|
-
|
|
559
|
-
module LiterLlm
|
|
560
|
-
# A content part in a multimodal embedding input.
|
|
561
|
-
module EmbeddingContentPart
|
|
562
|
-
extend T::Helpers
|
|
563
|
-
extend T::Sig
|
|
564
|
-
|
|
565
|
-
interface!
|
|
566
|
-
|
|
567
|
-
# Dispatch from a Hash to the appropriate variant constructor.
|
|
568
|
-
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
569
|
-
# @return [variant_class] an instance of the appropriate variant
|
|
570
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
571
|
-
def self.from_hash(hash)
|
|
572
|
-
discriminator = hash[:type] || hash["type"]
|
|
573
|
-
case discriminator
|
|
574
|
-
when "text" then EmbeddingContentPartText.from_hash(hash)
|
|
575
|
-
when "image_url" then EmbeddingContentPartImageUrl.from_hash(hash)
|
|
576
|
-
when "image_base64" then EmbeddingContentPartImageBase64.from_hash(hash)
|
|
577
|
-
else raise "Unknown discriminator: #{discriminator}"
|
|
578
|
-
end
|
|
525
|
+
new(value: hash[:_0] || hash["_0"])
|
|
579
526
|
end
|
|
580
527
|
end
|
|
581
|
-
##
|
|
582
|
-
|
|
583
|
-
include
|
|
528
|
+
## Variant MessageTool of the Message sum type.
|
|
529
|
+
MessageTool = Data.define(:value) do
|
|
530
|
+
include Message
|
|
584
531
|
extend T::Sig
|
|
585
532
|
|
|
586
|
-
# @return [
|
|
587
|
-
sig { returns(
|
|
588
|
-
def
|
|
533
|
+
# @return [ToolMessage]
|
|
534
|
+
sig { returns(ToolMessage) }
|
|
535
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
589
536
|
sig { returns(T::Boolean) }
|
|
590
|
-
def
|
|
537
|
+
def system? = false
|
|
591
538
|
sig { returns(T::Boolean) }
|
|
592
|
-
def
|
|
539
|
+
def user? = false
|
|
593
540
|
sig { returns(T::Boolean) }
|
|
594
|
-
def
|
|
541
|
+
def assistant? = false
|
|
542
|
+
sig { returns(T::Boolean) }
|
|
543
|
+
def tool? = true
|
|
544
|
+
sig { returns(T::Boolean) }
|
|
545
|
+
def developer? = false
|
|
546
|
+
sig { returns(T::Boolean) }
|
|
547
|
+
def function? = false
|
|
595
548
|
# @param hash [Hash] deserialized from the native extension
|
|
596
549
|
# @return [self]
|
|
597
550
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
598
551
|
def self.from_hash(hash)
|
|
599
|
-
new(
|
|
552
|
+
new(value: hash[:_0] || hash["_0"])
|
|
600
553
|
end
|
|
601
554
|
end
|
|
602
|
-
##
|
|
603
|
-
|
|
604
|
-
include
|
|
555
|
+
## Variant MessageDeveloper of the Message sum type.
|
|
556
|
+
MessageDeveloper = Data.define(:value) do
|
|
557
|
+
include Message
|
|
605
558
|
extend T::Sig
|
|
606
559
|
|
|
607
|
-
# @return [
|
|
608
|
-
sig { returns(
|
|
609
|
-
def
|
|
560
|
+
# @return [DeveloperMessage]
|
|
561
|
+
sig { returns(DeveloperMessage) }
|
|
562
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
610
563
|
sig { returns(T::Boolean) }
|
|
611
|
-
def
|
|
564
|
+
def system? = false
|
|
612
565
|
sig { returns(T::Boolean) }
|
|
613
|
-
def
|
|
566
|
+
def user? = false
|
|
614
567
|
sig { returns(T::Boolean) }
|
|
615
|
-
def
|
|
568
|
+
def assistant? = false
|
|
569
|
+
sig { returns(T::Boolean) }
|
|
570
|
+
def tool? = false
|
|
571
|
+
sig { returns(T::Boolean) }
|
|
572
|
+
def developer? = true
|
|
573
|
+
sig { returns(T::Boolean) }
|
|
574
|
+
def function? = false
|
|
616
575
|
# @param hash [Hash] deserialized from the native extension
|
|
617
576
|
# @return [self]
|
|
618
577
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
619
578
|
def self.from_hash(hash)
|
|
620
|
-
new(
|
|
579
|
+
new(value: hash[:_0] || hash["_0"])
|
|
621
580
|
end
|
|
622
581
|
end
|
|
623
|
-
##
|
|
624
|
-
|
|
625
|
-
include
|
|
582
|
+
## Deprecated legacy function-role message; retained for API compatibility.
|
|
583
|
+
MessageFunction = Data.define(:value) do
|
|
584
|
+
include Message
|
|
626
585
|
extend T::Sig
|
|
627
586
|
|
|
628
|
-
# @return [
|
|
629
|
-
sig { returns(
|
|
630
|
-
def
|
|
587
|
+
# @return [FunctionMessage]
|
|
588
|
+
sig { returns(FunctionMessage) }
|
|
589
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
631
590
|
sig { returns(T::Boolean) }
|
|
632
|
-
def
|
|
591
|
+
def system? = false
|
|
633
592
|
sig { returns(T::Boolean) }
|
|
634
|
-
def
|
|
593
|
+
def user? = false
|
|
635
594
|
sig { returns(T::Boolean) }
|
|
636
|
-
def
|
|
595
|
+
def assistant? = false
|
|
596
|
+
sig { returns(T::Boolean) }
|
|
597
|
+
def tool? = false
|
|
598
|
+
sig { returns(T::Boolean) }
|
|
599
|
+
def developer? = false
|
|
600
|
+
sig { returns(T::Boolean) }
|
|
601
|
+
def function? = true
|
|
637
602
|
# @param hash [Hash] deserialized from the native extension
|
|
638
603
|
# @return [self]
|
|
639
604
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
640
605
|
def self.from_hash(hash)
|
|
641
|
-
new(
|
|
606
|
+
new(value: hash[:_0] || hash["_0"])
|
|
642
607
|
end
|
|
643
608
|
end
|
|
644
609
|
end
|
|
@@ -708,8 +673,23 @@ module LiterLlm
|
|
|
708
673
|
end
|
|
709
674
|
|
|
710
675
|
module LiterLlm
|
|
711
|
-
#
|
|
712
|
-
|
|
676
|
+
# Wire format for the chat completions `response_format` field.
|
|
677
|
+
#
|
|
678
|
+
# # Provider mapping
|
|
679
|
+
#
|
|
680
|
+
# - **OpenAI** (and OpenAI-compatible providers): emitted verbatim as
|
|
681
|
+
# `{"type": "json_schema", "json_schema": {...}}` per the
|
|
682
|
+
# chat-completions spec.
|
|
683
|
+
# - **Gemini / Vertex AI**: translated to
|
|
684
|
+
# `generationConfig.responseMimeType = "application/json"` and
|
|
685
|
+
# `generationConfig.responseSchema = <schema>`. The `name`,
|
|
686
|
+
# `description`, and `strict` fields are dropped — Gemini's
|
|
687
|
+
# structured-output API does not consume them.
|
|
688
|
+
# - **Anthropic**: no native JSON mode. A system instruction is
|
|
689
|
+
# prepended asking the model to respond with valid JSON.
|
|
690
|
+
# `strict` is advisory only; callers should still validate the
|
|
691
|
+
# returned JSON if the schema is load-bearing.
|
|
692
|
+
module ResponseFormat
|
|
713
693
|
extend T::Helpers
|
|
714
694
|
extend T::Sig
|
|
715
695
|
|
|
@@ -722,21 +702,24 @@ module LiterLlm
|
|
|
722
702
|
def self.from_hash(hash)
|
|
723
703
|
discriminator = hash[:type] || hash["type"]
|
|
724
704
|
case discriminator
|
|
725
|
-
when "
|
|
726
|
-
when "
|
|
705
|
+
when "text" then ResponseFormatText.from_hash(hash)
|
|
706
|
+
when "json_object" then ResponseFormatJsonObject.from_hash(hash)
|
|
707
|
+
when "json_schema" then ResponseFormatJsonSchema.from_hash(hash)
|
|
727
708
|
else raise "Unknown discriminator: #{discriminator}"
|
|
728
709
|
end
|
|
729
710
|
end
|
|
730
711
|
end
|
|
731
|
-
##
|
|
732
|
-
|
|
733
|
-
include
|
|
712
|
+
## Plain text output (default).
|
|
713
|
+
ResponseFormatText = Data.define do
|
|
714
|
+
include ResponseFormat
|
|
734
715
|
extend T::Sig
|
|
735
716
|
|
|
736
717
|
sig { returns(T::Boolean) }
|
|
737
|
-
def
|
|
718
|
+
def text? = true
|
|
738
719
|
sig { returns(T::Boolean) }
|
|
739
|
-
def
|
|
720
|
+
def json_object? = false
|
|
721
|
+
sig { returns(T::Boolean) }
|
|
722
|
+
def json_schema? = false
|
|
740
723
|
# @param hash [Hash] deserialized from the native extension
|
|
741
724
|
# @return [self]
|
|
742
725
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
@@ -744,26 +727,43 @@ module LiterLlm
|
|
|
744
727
|
new
|
|
745
728
|
end
|
|
746
729
|
end
|
|
747
|
-
##
|
|
748
|
-
|
|
749
|
-
include
|
|
730
|
+
## Output must be valid JSON object (no schema validation).
|
|
731
|
+
ResponseFormatJsonObject = Data.define do
|
|
732
|
+
include ResponseFormat
|
|
750
733
|
extend T::Sig
|
|
751
734
|
|
|
752
|
-
# OpenDAL scheme name (e.g. "s3", "redis", "fs", "gcs", "azblob").
|
|
753
|
-
sig { returns(String) }
|
|
754
|
-
def scheme = super # rubocop:disable Lint/UselessMethodDefinition
|
|
755
|
-
# Backend-specific configuration as key-value pairs passed to OpenDAL.
|
|
756
|
-
sig { returns(T::Hash[String, String]) }
|
|
757
|
-
def config = super # rubocop:disable Lint/UselessMethodDefinition
|
|
758
735
|
sig { returns(T::Boolean) }
|
|
759
|
-
def
|
|
736
|
+
def text? = false
|
|
760
737
|
sig { returns(T::Boolean) }
|
|
761
|
-
def
|
|
738
|
+
def json_object? = true
|
|
739
|
+
sig { returns(T::Boolean) }
|
|
740
|
+
def json_schema? = false
|
|
762
741
|
# @param hash [Hash] deserialized from the native extension
|
|
763
742
|
# @return [self]
|
|
764
743
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
765
744
|
def self.from_hash(hash)
|
|
766
|
-
new
|
|
745
|
+
new
|
|
746
|
+
end
|
|
747
|
+
end
|
|
748
|
+
## Output must conform to the specified JSON schema.
|
|
749
|
+
ResponseFormatJsonSchema = Data.define(:json_schema) do
|
|
750
|
+
include ResponseFormat
|
|
751
|
+
extend T::Sig
|
|
752
|
+
|
|
753
|
+
# @return [JsonSchemaFormat]
|
|
754
|
+
sig { returns(JsonSchemaFormat) }
|
|
755
|
+
def json_schema = super # rubocop:disable Lint/UselessMethodDefinition
|
|
756
|
+
sig { returns(T::Boolean) }
|
|
757
|
+
def text? = false
|
|
758
|
+
sig { returns(T::Boolean) }
|
|
759
|
+
def json_object? = false
|
|
760
|
+
sig { returns(T::Boolean) }
|
|
761
|
+
def json_schema? = true
|
|
762
|
+
# @param hash [Hash] deserialized from the native extension
|
|
763
|
+
# @return [self]
|
|
764
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
765
|
+
def self.from_hash(hash)
|
|
766
|
+
new(json_schema: hash[:json_schema] || hash["json_schema"])
|
|
767
767
|
end
|
|
768
768
|
end
|
|
769
769
|
end
|