liter_llm 1.4.0.pre.rc.27-x86_64-linux → 1.4.0.pre.rc.29-x86_64-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/Steepfile +0 -12
- data/lib/liter_llm/native.rb +628 -0
- data/lib/liter_llm/version.rb +10 -0
- data/lib/liter_llm.rb +11 -1
- data/lib/liter_llm_rb.so +0 -0
- data/sig/types.rbs +460 -355
- metadata +12 -149
- data/README.md +0 -235
- data/sig/liter_llm.rbs +0 -416
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1fbe232a406fd0fdee9c5616c4800a0e6a7baa4caac9a3b0a215285cecf72f1
|
|
4
|
+
data.tar.gz: 7f3cc7ddb324164d38ef8f7d6152d53254ef560b5e812f1a139953c17fb30183
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 651e9e2f47a8b7c74224f4b69cf48d3a7d8c4529d8ba68f30c27c396430c25bdac4ba8650255395bfb8bd8f0d59ce7769cc05b266122d693f1d35b03211eaaa6
|
|
7
|
+
data.tar.gz: 5728b31387997e1994d10940cbbc4640f97d6ce1e1fccb7ce89cc5a4bc6e57335c8e7f7d4929860cb754a8d976bbf8fd05e20bf58593352f73f421523f9cc1b1
|
data/Steepfile
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Steep configuration for the LiterLlm Ruby package.
|
|
4
|
-
|
|
5
3
|
target :lib do
|
|
6
4
|
signature 'sig'
|
|
7
|
-
|
|
8
5
|
check 'lib'
|
|
9
|
-
|
|
10
|
-
# Standard library used by the wrapper layer.
|
|
11
|
-
library 'json'
|
|
12
|
-
|
|
13
|
-
# Strategic ignores:
|
|
14
|
-
|
|
15
|
-
# 1. Native extension entry point — methods are defined in Rust via Magnus
|
|
16
|
-
# and cannot be resolved by Steep's static analysis.
|
|
17
|
-
ignore 'lib/liter_llm_rb.rb' if File.exist?('lib/liter_llm_rb.rb')
|
|
18
6
|
end
|
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
+
# alef:hash:5eaeda34a14cac3162d7a94cbbc45e5fe3cea5acf5327a1a76bbf2a3f99f4b8f
|
|
3
|
+
# To regenerate: alef generate
|
|
4
|
+
# To verify freshness: alef verify --exit-code
|
|
5
|
+
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
6
|
+
# frozen_string_literal: true
|
|
7
|
+
|
|
8
|
+
require 'json'
|
|
9
|
+
require 'sorbet-runtime'
|
|
10
|
+
require 'liter_llm_rb'
|
|
11
|
+
module LiterLlm
|
|
12
|
+
# A chat message in a conversation.
|
|
13
|
+
module Message
|
|
14
|
+
extend T::Helpers
|
|
15
|
+
extend T::Sig
|
|
16
|
+
interface!
|
|
17
|
+
|
|
18
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
19
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
20
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
21
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
22
|
+
def self.from_hash(hash)
|
|
23
|
+
discriminator = hash[:role] || hash["role"]
|
|
24
|
+
case discriminator
|
|
25
|
+
when "system" then MessageSystem.from_hash(hash)
|
|
26
|
+
when "user" then MessageUser.from_hash(hash)
|
|
27
|
+
when "assistant" then MessageAssistant.from_hash(hash)
|
|
28
|
+
when "tool" then MessageTool.from_hash(hash)
|
|
29
|
+
when "developer" then MessageDeveloper.from_hash(hash)
|
|
30
|
+
when "function" then MessageFunction.from_hash(hash)
|
|
31
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Variant MessageSystem of the Message sum type.
|
|
38
|
+
MessageSystem = Data.define(:value) do
|
|
39
|
+
include Message
|
|
40
|
+
extend T::Sig
|
|
41
|
+
|
|
42
|
+
# @return [SystemMessage]
|
|
43
|
+
sig { returns(SystemMessage) }
|
|
44
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
45
|
+
|
|
46
|
+
sig { returns(T::Boolean) }
|
|
47
|
+
def system? = true
|
|
48
|
+
|
|
49
|
+
sig { returns(T::Boolean) }
|
|
50
|
+
def user? = false
|
|
51
|
+
|
|
52
|
+
sig { returns(T::Boolean) }
|
|
53
|
+
def assistant? = false
|
|
54
|
+
|
|
55
|
+
sig { returns(T::Boolean) }
|
|
56
|
+
def tool? = false
|
|
57
|
+
|
|
58
|
+
sig { returns(T::Boolean) }
|
|
59
|
+
def developer? = false
|
|
60
|
+
|
|
61
|
+
sig { returns(T::Boolean) }
|
|
62
|
+
def function? = false
|
|
63
|
+
|
|
64
|
+
# @param hash [Hash] deserialized from the native extension
|
|
65
|
+
# @return [self]
|
|
66
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
67
|
+
def self.from_hash(hash)
|
|
68
|
+
new(value: hash[:_0] || hash["_0"])
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Variant MessageUser of the Message sum type.
|
|
73
|
+
MessageUser = Data.define(:value) do
|
|
74
|
+
include Message
|
|
75
|
+
extend T::Sig
|
|
76
|
+
|
|
77
|
+
# @return [UserMessage]
|
|
78
|
+
sig { returns(UserMessage) }
|
|
79
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
80
|
+
|
|
81
|
+
sig { returns(T::Boolean) }
|
|
82
|
+
def system? = false
|
|
83
|
+
|
|
84
|
+
sig { returns(T::Boolean) }
|
|
85
|
+
def user? = true
|
|
86
|
+
|
|
87
|
+
sig { returns(T::Boolean) }
|
|
88
|
+
def assistant? = false
|
|
89
|
+
|
|
90
|
+
sig { returns(T::Boolean) }
|
|
91
|
+
def tool? = false
|
|
92
|
+
|
|
93
|
+
sig { returns(T::Boolean) }
|
|
94
|
+
def developer? = false
|
|
95
|
+
|
|
96
|
+
sig { returns(T::Boolean) }
|
|
97
|
+
def function? = false
|
|
98
|
+
|
|
99
|
+
# @param hash [Hash] deserialized from the native extension
|
|
100
|
+
# @return [self]
|
|
101
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
102
|
+
def self.from_hash(hash)
|
|
103
|
+
new(value: hash[:_0] || hash["_0"])
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Variant MessageAssistant of the Message sum type.
|
|
108
|
+
MessageAssistant = Data.define(:value) do
|
|
109
|
+
include Message
|
|
110
|
+
extend T::Sig
|
|
111
|
+
|
|
112
|
+
# @return [AssistantMessage]
|
|
113
|
+
sig { returns(AssistantMessage) }
|
|
114
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
115
|
+
|
|
116
|
+
sig { returns(T::Boolean) }
|
|
117
|
+
def system? = false
|
|
118
|
+
|
|
119
|
+
sig { returns(T::Boolean) }
|
|
120
|
+
def user? = false
|
|
121
|
+
|
|
122
|
+
sig { returns(T::Boolean) }
|
|
123
|
+
def assistant? = true
|
|
124
|
+
|
|
125
|
+
sig { returns(T::Boolean) }
|
|
126
|
+
def tool? = false
|
|
127
|
+
|
|
128
|
+
sig { returns(T::Boolean) }
|
|
129
|
+
def developer? = false
|
|
130
|
+
|
|
131
|
+
sig { returns(T::Boolean) }
|
|
132
|
+
def function? = false
|
|
133
|
+
|
|
134
|
+
# @param hash [Hash] deserialized from the native extension
|
|
135
|
+
# @return [self]
|
|
136
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
137
|
+
def self.from_hash(hash)
|
|
138
|
+
new(value: hash[:_0] || hash["_0"])
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Variant MessageTool of the Message sum type.
|
|
143
|
+
MessageTool = Data.define(:value) do
|
|
144
|
+
include Message
|
|
145
|
+
extend T::Sig
|
|
146
|
+
|
|
147
|
+
# @return [ToolMessage]
|
|
148
|
+
sig { returns(ToolMessage) }
|
|
149
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
150
|
+
|
|
151
|
+
sig { returns(T::Boolean) }
|
|
152
|
+
def system? = false
|
|
153
|
+
|
|
154
|
+
sig { returns(T::Boolean) }
|
|
155
|
+
def user? = false
|
|
156
|
+
|
|
157
|
+
sig { returns(T::Boolean) }
|
|
158
|
+
def assistant? = false
|
|
159
|
+
|
|
160
|
+
sig { returns(T::Boolean) }
|
|
161
|
+
def tool? = true
|
|
162
|
+
|
|
163
|
+
sig { returns(T::Boolean) }
|
|
164
|
+
def developer? = false
|
|
165
|
+
|
|
166
|
+
sig { returns(T::Boolean) }
|
|
167
|
+
def function? = false
|
|
168
|
+
|
|
169
|
+
# @param hash [Hash] deserialized from the native extension
|
|
170
|
+
# @return [self]
|
|
171
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
172
|
+
def self.from_hash(hash)
|
|
173
|
+
new(value: hash[:_0] || hash["_0"])
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Variant MessageDeveloper of the Message sum type.
|
|
178
|
+
MessageDeveloper = Data.define(:value) do
|
|
179
|
+
include Message
|
|
180
|
+
extend T::Sig
|
|
181
|
+
|
|
182
|
+
# @return [DeveloperMessage]
|
|
183
|
+
sig { returns(DeveloperMessage) }
|
|
184
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
185
|
+
|
|
186
|
+
sig { returns(T::Boolean) }
|
|
187
|
+
def system? = false
|
|
188
|
+
|
|
189
|
+
sig { returns(T::Boolean) }
|
|
190
|
+
def user? = false
|
|
191
|
+
|
|
192
|
+
sig { returns(T::Boolean) }
|
|
193
|
+
def assistant? = false
|
|
194
|
+
|
|
195
|
+
sig { returns(T::Boolean) }
|
|
196
|
+
def tool? = false
|
|
197
|
+
|
|
198
|
+
sig { returns(T::Boolean) }
|
|
199
|
+
def developer? = true
|
|
200
|
+
|
|
201
|
+
sig { returns(T::Boolean) }
|
|
202
|
+
def function? = false
|
|
203
|
+
|
|
204
|
+
# @param hash [Hash] deserialized from the native extension
|
|
205
|
+
# @return [self]
|
|
206
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
207
|
+
def self.from_hash(hash)
|
|
208
|
+
new(value: hash[:_0] || hash["_0"])
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Deprecated legacy function-role message; retained for API compatibility.
|
|
213
|
+
MessageFunction = Data.define(:value) do
|
|
214
|
+
include Message
|
|
215
|
+
extend T::Sig
|
|
216
|
+
|
|
217
|
+
# @return [FunctionMessage]
|
|
218
|
+
sig { returns(FunctionMessage) }
|
|
219
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
220
|
+
|
|
221
|
+
sig { returns(T::Boolean) }
|
|
222
|
+
def system? = false
|
|
223
|
+
|
|
224
|
+
sig { returns(T::Boolean) }
|
|
225
|
+
def user? = false
|
|
226
|
+
|
|
227
|
+
sig { returns(T::Boolean) }
|
|
228
|
+
def assistant? = false
|
|
229
|
+
|
|
230
|
+
sig { returns(T::Boolean) }
|
|
231
|
+
def tool? = false
|
|
232
|
+
|
|
233
|
+
sig { returns(T::Boolean) }
|
|
234
|
+
def developer? = false
|
|
235
|
+
|
|
236
|
+
sig { returns(T::Boolean) }
|
|
237
|
+
def function? = true
|
|
238
|
+
|
|
239
|
+
# @param hash [Hash] deserialized from the native extension
|
|
240
|
+
# @return [self]
|
|
241
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
242
|
+
def self.from_hash(hash)
|
|
243
|
+
new(value: hash[:_0] || hash["_0"])
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
module LiterLlm
|
|
250
|
+
# A single content part in a user message — text, image, document, or audio.
|
|
251
|
+
module ContentPart
|
|
252
|
+
extend T::Helpers
|
|
253
|
+
extend T::Sig
|
|
254
|
+
interface!
|
|
255
|
+
|
|
256
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
257
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
258
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
259
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
260
|
+
def self.from_hash(hash)
|
|
261
|
+
discriminator = hash[:type] || hash["type"]
|
|
262
|
+
case discriminator
|
|
263
|
+
when "text" then ContentPartText.from_hash(hash)
|
|
264
|
+
when "image_url" then ContentPartImageUrl.from_hash(hash)
|
|
265
|
+
when "document" then ContentPartDocument.from_hash(hash)
|
|
266
|
+
when "input_audio" then ContentPartInputAudio.from_hash(hash)
|
|
267
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Plain text.
|
|
274
|
+
ContentPartText = Data.define(:text) do
|
|
275
|
+
include ContentPart
|
|
276
|
+
extend T::Sig
|
|
277
|
+
|
|
278
|
+
# @return [String]
|
|
279
|
+
sig { returns(String) }
|
|
280
|
+
def text = super # rubocop:disable Lint/UselessMethodDefinition
|
|
281
|
+
|
|
282
|
+
sig { returns(T::Boolean) }
|
|
283
|
+
def text? = true
|
|
284
|
+
|
|
285
|
+
sig { returns(T::Boolean) }
|
|
286
|
+
def image_url? = false
|
|
287
|
+
|
|
288
|
+
sig { returns(T::Boolean) }
|
|
289
|
+
def document? = false
|
|
290
|
+
|
|
291
|
+
sig { returns(T::Boolean) }
|
|
292
|
+
def input_audio? = false
|
|
293
|
+
|
|
294
|
+
# @param hash [Hash] deserialized from the native extension
|
|
295
|
+
# @return [self]
|
|
296
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
297
|
+
def self.from_hash(hash)
|
|
298
|
+
new(text: hash[:text] || hash["text"])
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Image identified by URL (with optional detail level).
|
|
303
|
+
ContentPartImageUrl = Data.define(:image_url) do
|
|
304
|
+
include ContentPart
|
|
305
|
+
extend T::Sig
|
|
306
|
+
|
|
307
|
+
# @return [ImageUrl]
|
|
308
|
+
sig { returns(ImageUrl) }
|
|
309
|
+
def image_url = super # rubocop:disable Lint/UselessMethodDefinition
|
|
310
|
+
|
|
311
|
+
sig { returns(T::Boolean) }
|
|
312
|
+
def text? = false
|
|
313
|
+
|
|
314
|
+
sig { returns(T::Boolean) }
|
|
315
|
+
def image_url? = true
|
|
316
|
+
|
|
317
|
+
sig { returns(T::Boolean) }
|
|
318
|
+
def document? = false
|
|
319
|
+
|
|
320
|
+
sig { returns(T::Boolean) }
|
|
321
|
+
def input_audio? = false
|
|
322
|
+
|
|
323
|
+
# @param hash [Hash] deserialized from the native extension
|
|
324
|
+
# @return [self]
|
|
325
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
326
|
+
def self.from_hash(hash)
|
|
327
|
+
new(image_url: hash[:image_url] || hash["image_url"])
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Document file (PDF, CSV, etc.) as base64 or URL.
|
|
332
|
+
ContentPartDocument = Data.define(:document) do
|
|
333
|
+
include ContentPart
|
|
334
|
+
extend T::Sig
|
|
335
|
+
|
|
336
|
+
# @return [DocumentContent]
|
|
337
|
+
sig { returns(DocumentContent) }
|
|
338
|
+
def document = super # rubocop:disable Lint/UselessMethodDefinition
|
|
339
|
+
|
|
340
|
+
sig { returns(T::Boolean) }
|
|
341
|
+
def text? = false
|
|
342
|
+
|
|
343
|
+
sig { returns(T::Boolean) }
|
|
344
|
+
def image_url? = false
|
|
345
|
+
|
|
346
|
+
sig { returns(T::Boolean) }
|
|
347
|
+
def document? = true
|
|
348
|
+
|
|
349
|
+
sig { returns(T::Boolean) }
|
|
350
|
+
def input_audio? = false
|
|
351
|
+
|
|
352
|
+
# @param hash [Hash] deserialized from the native extension
|
|
353
|
+
# @return [self]
|
|
354
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
355
|
+
def self.from_hash(hash)
|
|
356
|
+
new(document: hash[:document] || hash["document"])
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Audio input as base64.
|
|
361
|
+
ContentPartInputAudio = Data.define(:input_audio) do
|
|
362
|
+
include ContentPart
|
|
363
|
+
extend T::Sig
|
|
364
|
+
|
|
365
|
+
# @return [AudioContent]
|
|
366
|
+
sig { returns(AudioContent) }
|
|
367
|
+
def input_audio = super # rubocop:disable Lint/UselessMethodDefinition
|
|
368
|
+
|
|
369
|
+
sig { returns(T::Boolean) }
|
|
370
|
+
def text? = false
|
|
371
|
+
|
|
372
|
+
sig { returns(T::Boolean) }
|
|
373
|
+
def image_url? = false
|
|
374
|
+
|
|
375
|
+
sig { returns(T::Boolean) }
|
|
376
|
+
def document? = false
|
|
377
|
+
|
|
378
|
+
sig { returns(T::Boolean) }
|
|
379
|
+
def input_audio? = true
|
|
380
|
+
|
|
381
|
+
# @param hash [Hash] deserialized from the native extension
|
|
382
|
+
# @return [self]
|
|
383
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
384
|
+
def self.from_hash(hash)
|
|
385
|
+
new(input_audio: hash[:input_audio] || hash["input_audio"])
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
module LiterLlm
|
|
392
|
+
# Response format constraint.
|
|
393
|
+
module ResponseFormat
|
|
394
|
+
extend T::Helpers
|
|
395
|
+
extend T::Sig
|
|
396
|
+
interface!
|
|
397
|
+
|
|
398
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
399
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
400
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
401
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
402
|
+
def self.from_hash(hash)
|
|
403
|
+
discriminator = hash[:type] || hash["type"]
|
|
404
|
+
case discriminator
|
|
405
|
+
when "text" then ResponseFormatText.from_hash(hash)
|
|
406
|
+
when "json_object" then ResponseFormatJsonObject.from_hash(hash)
|
|
407
|
+
when "json_schema" then ResponseFormatJsonSchema.from_hash(hash)
|
|
408
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# Plain text output (default).
|
|
415
|
+
ResponseFormatText = Data.define do
|
|
416
|
+
include ResponseFormat
|
|
417
|
+
extend T::Sig
|
|
418
|
+
|
|
419
|
+
sig { returns(T::Boolean) }
|
|
420
|
+
def text? = true
|
|
421
|
+
|
|
422
|
+
sig { returns(T::Boolean) }
|
|
423
|
+
def json_object? = false
|
|
424
|
+
|
|
425
|
+
sig { returns(T::Boolean) }
|
|
426
|
+
def json_schema? = false
|
|
427
|
+
|
|
428
|
+
# @param hash [Hash] deserialized from the native extension
|
|
429
|
+
# @return [self]
|
|
430
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
431
|
+
def self.from_hash(hash)
|
|
432
|
+
new
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# Output must be valid JSON object (no schema validation).
|
|
437
|
+
ResponseFormatJsonObject = Data.define do
|
|
438
|
+
include ResponseFormat
|
|
439
|
+
extend T::Sig
|
|
440
|
+
|
|
441
|
+
sig { returns(T::Boolean) }
|
|
442
|
+
def text? = false
|
|
443
|
+
|
|
444
|
+
sig { returns(T::Boolean) }
|
|
445
|
+
def json_object? = true
|
|
446
|
+
|
|
447
|
+
sig { returns(T::Boolean) }
|
|
448
|
+
def json_schema? = false
|
|
449
|
+
|
|
450
|
+
# @param hash [Hash] deserialized from the native extension
|
|
451
|
+
# @return [self]
|
|
452
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
453
|
+
def self.from_hash(hash)
|
|
454
|
+
new
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
# Output must conform to the specified JSON schema.
|
|
459
|
+
ResponseFormatJsonSchema = Data.define(:json_schema) do
|
|
460
|
+
include ResponseFormat
|
|
461
|
+
extend T::Sig
|
|
462
|
+
|
|
463
|
+
# @return [JsonSchemaFormat]
|
|
464
|
+
sig { returns(JsonSchemaFormat) }
|
|
465
|
+
def json_schema = super # rubocop:disable Lint/UselessMethodDefinition
|
|
466
|
+
|
|
467
|
+
sig { returns(T::Boolean) }
|
|
468
|
+
def text? = false
|
|
469
|
+
|
|
470
|
+
sig { returns(T::Boolean) }
|
|
471
|
+
def json_object? = false
|
|
472
|
+
|
|
473
|
+
sig { returns(T::Boolean) }
|
|
474
|
+
def json_schema? = true
|
|
475
|
+
|
|
476
|
+
# @param hash [Hash] deserialized from the native extension
|
|
477
|
+
# @return [self]
|
|
478
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
479
|
+
def self.from_hash(hash)
|
|
480
|
+
new(json_schema: hash[:json_schema] || hash["json_schema"])
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
module LiterLlm
|
|
487
|
+
# Document input for OCR — either a URL or inline base64 data.
|
|
488
|
+
module OcrDocument
|
|
489
|
+
extend T::Helpers
|
|
490
|
+
extend T::Sig
|
|
491
|
+
interface!
|
|
492
|
+
|
|
493
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
494
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
495
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
496
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
497
|
+
def self.from_hash(hash)
|
|
498
|
+
discriminator = hash[:type] || hash["type"]
|
|
499
|
+
case discriminator
|
|
500
|
+
when "document_url" then OcrDocumentUrl.from_hash(hash)
|
|
501
|
+
when "base64" then OcrDocumentBase64.from_hash(hash)
|
|
502
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
# A publicly accessible document URL.
|
|
509
|
+
OcrDocumentUrl = Data.define(:url) do
|
|
510
|
+
include OcrDocument
|
|
511
|
+
extend T::Sig
|
|
512
|
+
|
|
513
|
+
# The document URL (HTTP/HTTPS).
|
|
514
|
+
sig { returns(String) }
|
|
515
|
+
def url = super # rubocop:disable Lint/UselessMethodDefinition
|
|
516
|
+
|
|
517
|
+
sig { returns(T::Boolean) }
|
|
518
|
+
def url? = true
|
|
519
|
+
|
|
520
|
+
sig { returns(T::Boolean) }
|
|
521
|
+
def base64? = false
|
|
522
|
+
|
|
523
|
+
# @param hash [Hash] deserialized from the native extension
|
|
524
|
+
# @return [self]
|
|
525
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
526
|
+
def self.from_hash(hash)
|
|
527
|
+
new(url: hash[:url] || hash["url"])
|
|
528
|
+
end
|
|
529
|
+
end
|
|
530
|
+
|
|
531
|
+
# Inline base64-encoded document data.
|
|
532
|
+
OcrDocumentBase64 = Data.define(:data, :media_type) do
|
|
533
|
+
include OcrDocument
|
|
534
|
+
extend T::Sig
|
|
535
|
+
|
|
536
|
+
# Base64-encoded document content.
|
|
537
|
+
sig { returns(String) }
|
|
538
|
+
def data = super # rubocop:disable Lint/UselessMethodDefinition
|
|
539
|
+
|
|
540
|
+
# MIME type (e.g. `"application/pdf"`, `"image/png"`, `"image/jpeg"`).
|
|
541
|
+
sig { returns(String) }
|
|
542
|
+
def media_type = super # rubocop:disable Lint/UselessMethodDefinition
|
|
543
|
+
|
|
544
|
+
sig { returns(T::Boolean) }
|
|
545
|
+
def url? = false
|
|
546
|
+
|
|
547
|
+
sig { returns(T::Boolean) }
|
|
548
|
+
def base64? = true
|
|
549
|
+
|
|
550
|
+
# @param hash [Hash] deserialized from the native extension
|
|
551
|
+
# @return [self]
|
|
552
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
553
|
+
def self.from_hash(hash)
|
|
554
|
+
new(data: hash[:data] || hash["data"], media_type: hash[:media_type] || hash["media_type"])
|
|
555
|
+
end
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
module LiterLlm
|
|
561
|
+
# Storage backend for the response cache.
|
|
562
|
+
module CacheBackend
|
|
563
|
+
extend T::Helpers
|
|
564
|
+
extend T::Sig
|
|
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 "memory" then CacheBackendMemory.from_hash(hash)
|
|
575
|
+
when "open_dal" then CacheBackendOpenDal.from_hash(hash)
|
|
576
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
# In-memory LRU cache (default). No external dependencies.
|
|
583
|
+
CacheBackendMemory = Data.define do
|
|
584
|
+
include CacheBackend
|
|
585
|
+
extend T::Sig
|
|
586
|
+
|
|
587
|
+
sig { returns(T::Boolean) }
|
|
588
|
+
def memory? = true
|
|
589
|
+
|
|
590
|
+
sig { returns(T::Boolean) }
|
|
591
|
+
def open_dal? = false
|
|
592
|
+
|
|
593
|
+
# @param hash [Hash] deserialized from the native extension
|
|
594
|
+
# @return [self]
|
|
595
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
596
|
+
def self.from_hash(hash)
|
|
597
|
+
new
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
# OpenDAL-backed storage. Supports 40+ backends (S3, Redis, GCS, local FS, etc.).
|
|
602
|
+
CacheBackendOpenDal = Data.define(:scheme, :config) do
|
|
603
|
+
include CacheBackend
|
|
604
|
+
extend T::Sig
|
|
605
|
+
|
|
606
|
+
# OpenDAL scheme name (e.g. "s3", "redis", "fs", "gcs", "azblob").
|
|
607
|
+
sig { returns(String) }
|
|
608
|
+
def scheme = super # rubocop:disable Lint/UselessMethodDefinition
|
|
609
|
+
|
|
610
|
+
# Backend-specific configuration as key-value pairs passed to OpenDAL.
|
|
611
|
+
sig { returns(T::Hash[String, String]) }
|
|
612
|
+
def config = super # rubocop:disable Lint/UselessMethodDefinition
|
|
613
|
+
|
|
614
|
+
sig { returns(T::Boolean) }
|
|
615
|
+
def memory? = false
|
|
616
|
+
|
|
617
|
+
sig { returns(T::Boolean) }
|
|
618
|
+
def open_dal? = true
|
|
619
|
+
|
|
620
|
+
# @param hash [Hash] deserialized from the native extension
|
|
621
|
+
# @return [self]
|
|
622
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
623
|
+
def self.from_hash(hash)
|
|
624
|
+
new(scheme: hash[:scheme] || hash["scheme"], config: hash[:config] || hash["config"])
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
+
# alef:hash:bb4ea25903074aa895a421146740df576392e90d6785c18ec57ce6b8d9347fda
|
|
3
|
+
# To regenerate: alef generate
|
|
4
|
+
# To verify freshness: alef verify --exit-code
|
|
5
|
+
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
6
|
+
# frozen_string_literal: true
|
|
7
|
+
|
|
8
|
+
module LiterLlm
|
|
9
|
+
VERSION = '1.4.0.pre.rc.29'
|
|
10
|
+
end
|
data/lib/liter_llm.rb
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
+
# alef:hash:012bd4e1dc47a9ae9de57cc0db4d8edc929648b7f8b829b96afe0410c1979847
|
|
3
|
+
# To regenerate: alef generate
|
|
4
|
+
# To verify freshness: alef verify --exit-code
|
|
5
|
+
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
1
6
|
# frozen_string_literal: true
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
require_relative 'liter_llm/version'
|
|
9
|
+
require_relative 'liter_llm/native'
|
|
10
|
+
|
|
11
|
+
module LiterLlm
|
|
12
|
+
# Re-export all types and functions from native extension
|
|
13
|
+
end
|
data/lib/liter_llm_rb.so
CHANGED
|
Binary file
|