liter_llm 1.6.4-x86_64-linux → 1.7.1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f64a7d556ea441560cb7c11e6c07a5215e9c92e99f05eee02b420a37708f4f4
4
- data.tar.gz: 92588b69aa8c122e09ab8f019ca855856ff52ea26646853a44b5d5e2804b3ab2
3
+ metadata.gz: 0f71313b1bd53ae7bb282e25265f8e3dbcdad617c2802e917489b290b94b55bb
4
+ data.tar.gz: 5666fa2823976a798088bfd0a715b78672ebd96fbceae5aed06729609d3970ee
5
5
  SHA512:
6
- metadata.gz: 2192226a898aa995815ec44ba461c85a911da2f782c83649682ea2262b91348cef659e4aa537d7b47954401cc1e2607b37b473f077b4b92631527bcc489191fe
7
- data.tar.gz: 80478f44ce80349ddc4e9c2704f97829e3b9a483e1467fcca2c3f45abbd7aa27068dfbbf22303400f20b75709155ae68b8faaee56c266ce261dc654239d1a939
6
+ metadata.gz: da9f6025473b768d5a8460bc0815057f77891a4f9f13093ee7dcbda845e1a066c925aa74234c7911e15fe010bc89b60344f6cf2b6d8b7a41d02764371479c786
7
+ data.tar.gz: 8119e62a3827e2a684d71f12e00c6c12f0cea7cfa203d8946a4db33a7e765ad604dffbc856d06d755072f5ecbee7e8ac6487537d93339380fc252ab1e03bfd34
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:52effca2513e1c5f8a9a5b90a372d645388de4b92e4f822acc38d97502c322b6
2
+ # alef:hash:fec9b44a56d9714b7b12931bb48e1e8f6d57ef2d0ccaad1f9ac6046ce01a89af
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # frozen_string_literal: true
@@ -314,7 +314,142 @@ module LiterLlm
314
314
  end
315
315
 
316
316
  module LiterLlm
317
- # Response format constraint.
317
+ # One part of a structured assistant response.
318
+ #
319
+ # `#[serde(tag = "type", rename_all = "snake_case")]` matches OpenAI's
320
+ # parts-spec discriminator (`"type": "text"`, `"type": "output_image"`, …).
321
+ module AssistantPart
322
+ extend T::Helpers
323
+ extend T::Sig
324
+
325
+ interface!
326
+
327
+ # Dispatch from a Hash to the appropriate variant constructor.
328
+ # @param hash [Hash] with discriminator field and variant-specific fields
329
+ # @return [variant_class] an instance of the appropriate variant
330
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
331
+ def self.from_hash(hash)
332
+ discriminator = hash[:type] || hash["type"]
333
+ case discriminator
334
+ when "text" then AssistantPartText.from_hash(hash)
335
+ when "refusal" then AssistantPartRefusal.from_hash(hash)
336
+ when "output_image" then AssistantPartOutputImage.from_hash(hash)
337
+ when "output_audio" then AssistantPartOutputAudio.from_hash(hash)
338
+ else raise "Unknown discriminator: #{discriminator}"
339
+ end
340
+ end
341
+ end
342
+ ## A text segment of the response.
343
+ AssistantPartText = Data.define(:text) do
344
+ include AssistantPart
345
+ extend T::Sig
346
+
347
+ # The text content of this part.
348
+ sig { returns(String) }
349
+ def text = super # rubocop:disable Lint/UselessMethodDefinition
350
+ sig { returns(T::Boolean) }
351
+ def text? = true
352
+ sig { returns(T::Boolean) }
353
+ def refusal? = false
354
+ sig { returns(T::Boolean) }
355
+ def output_image? = false
356
+ sig { returns(T::Boolean) }
357
+ def output_audio? = false
358
+ # @param hash [Hash] deserialized from the native extension
359
+ # @return [self]
360
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
361
+ def self.from_hash(hash)
362
+ new(text: hash[:text] || hash["text"])
363
+ end
364
+ end
365
+ ## A refusal — the model declined to respond.
366
+ AssistantPartRefusal = Data.define(:refusal) do
367
+ include AssistantPart
368
+ extend T::Sig
369
+
370
+ # The refusal reason.
371
+ sig { returns(String) }
372
+ def refusal = super # rubocop:disable Lint/UselessMethodDefinition
373
+ sig { returns(T::Boolean) }
374
+ def text? = false
375
+ sig { returns(T::Boolean) }
376
+ def refusal? = true
377
+ sig { returns(T::Boolean) }
378
+ def output_image? = false
379
+ sig { returns(T::Boolean) }
380
+ def output_audio? = false
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(refusal: hash[:refusal] || hash["refusal"])
386
+ end
387
+ end
388
+ ## An image produced by the model (e.g. `gpt-image-1`, Gemini Imagen).
389
+ AssistantPartOutputImage = Data.define(:image_url) do
390
+ include AssistantPart
391
+ extend T::Sig
392
+
393
+ # Image URL or data URI referencing the generated image.
394
+ sig { returns(ImageUrl) }
395
+ def image_url = super # rubocop:disable Lint/UselessMethodDefinition
396
+ sig { returns(T::Boolean) }
397
+ def text? = false
398
+ sig { returns(T::Boolean) }
399
+ def refusal? = false
400
+ sig { returns(T::Boolean) }
401
+ def output_image? = true
402
+ sig { returns(T::Boolean) }
403
+ def output_audio? = false
404
+ # @param hash [Hash] deserialized from the native extension
405
+ # @return [self]
406
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
407
+ def self.from_hash(hash)
408
+ new(image_url: hash[:image_url] || hash["image_url"])
409
+ end
410
+ end
411
+ ## Audio produced by the model (e.g. `gpt-4o-audio-preview`).
412
+ AssistantPartOutputAudio = Data.define(:audio) do
413
+ include AssistantPart
414
+ extend T::Sig
415
+
416
+ # Base64-encoded audio data and its format.
417
+ sig { returns(AudioContent) }
418
+ def audio = super # rubocop:disable Lint/UselessMethodDefinition
419
+ sig { returns(T::Boolean) }
420
+ def text? = false
421
+ sig { returns(T::Boolean) }
422
+ def refusal? = false
423
+ sig { returns(T::Boolean) }
424
+ def output_image? = false
425
+ sig { returns(T::Boolean) }
426
+ def output_audio? = true
427
+ # @param hash [Hash] deserialized from the native extension
428
+ # @return [self]
429
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
430
+ def self.from_hash(hash)
431
+ new(audio: hash[:audio] || hash["audio"])
432
+ end
433
+ end
434
+ end
435
+
436
+ module LiterLlm
437
+ # Wire format for the chat completions `response_format` field.
438
+ #
439
+ # # Provider mapping
440
+ #
441
+ # - **OpenAI** (and OpenAI-compatible providers): emitted verbatim as
442
+ # `{"type": "json_schema", "json_schema": {...}}` per the
443
+ # chat-completions spec.
444
+ # - **Gemini / Vertex AI**: translated to
445
+ # `generationConfig.responseMimeType = "application/json"` and
446
+ # `generationConfig.responseSchema = <schema>`. The `name`,
447
+ # `description`, and `strict` fields are dropped — Gemini's
448
+ # structured-output API does not consume them.
449
+ # - **Anthropic**: no native JSON mode. A system instruction is
450
+ # prepended asking the model to respond with valid JSON.
451
+ # `strict` is advisory only; callers should still validate the
452
+ # returned JSON if the schema is load-bearing.
318
453
  module ResponseFormat
319
454
  extend T::Helpers
320
455
  extend T::Sig
@@ -1,10 +1,10 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:52effca2513e1c5f8a9a5b90a372d645388de4b92e4f822acc38d97502c322b6
2
+ # alef:hash:fec9b44a56d9714b7b12931bb48e1e8f6d57ef2d0ccaad1f9ac6046ce01a89af
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module LiterLlm
8
8
  ## The version string for this package.
9
- VERSION = "1.6.4"
9
+ VERSION = "1.7.1"
10
10
  end
data/lib/liter_llm.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:52effca2513e1c5f8a9a5b90a372d645388de4b92e4f822acc38d97502c322b6
2
+ # alef:hash:fec9b44a56d9714b7b12931bb48e1e8f6d57ef2d0ccaad1f9ac6046ce01a89af
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # frozen_string_literal: true
data/lib/liter_llm_rb.so CHANGED
Binary file
data/sig/types.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:52effca2513e1c5f8a9a5b90a372d645388de4b92e4f822acc38d97502c322b6
2
+ # alef:hash:fec9b44a56d9714b7b12931bb48e1e8f6d57ef2d0ccaad1f9ac6046ce01a89af
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
 
@@ -10,10 +10,10 @@ module LiterLlm
10
10
  type json_value = Hash[String, untyped] | Array[untyped] | String | Integer | Float | bool | nil
11
11
 
12
12
  class SystemMessage
13
- attr_accessor content: String?
13
+ attr_accessor content: UserContent?
14
14
  attr_accessor name: String?
15
15
 
16
- def initialize: (?content: String, ?name: String) -> void
16
+ def initialize: (?content: UserContent, ?name: String) -> void
17
17
  end
18
18
 
19
19
  class UserMessage
@@ -45,13 +45,17 @@ module LiterLlm
45
45
  end
46
46
 
47
47
  class AssistantMessage
48
- attr_accessor content: String?
48
+ attr_accessor content: AssistantContent?
49
49
  attr_accessor name: String?
50
50
  attr_accessor tool_calls: Array[ToolCall]?
51
51
  attr_accessor refusal: String?
52
52
  attr_accessor function_call: FunctionCall?
53
53
 
54
- def initialize: (?content: String, ?name: String, ?tool_calls: Array[ToolCall], ?refusal: String, ?function_call: FunctionCall) -> void
54
+ def initialize: (?content: AssistantContent, ?name: String, ?tool_calls: Array[ToolCall], ?refusal: String, ?function_call: FunctionCall) -> void
55
+ def text: () -> String?
56
+ def refusal_text: () -> String?
57
+ def output_images: () -> Array[ImageUrl]
58
+ def output_audio: () -> Array[AudioContent]
55
59
  end
56
60
 
57
61
  class ToolMessage
@@ -165,9 +169,10 @@ module LiterLlm
165
169
  attr_accessor stream_options: StreamOptions?
166
170
  attr_accessor seed: Integer?
167
171
  attr_accessor reasoning_effort: ReasoningEffort?
172
+ attr_accessor modalities: Array[Modality]?
168
173
  attr_accessor extra_body: json_value?
169
174
 
170
- def initialize: (?model: String, ?messages: Array[Message], ?temperature: Float, ?top_p: Float, ?n: Integer, ?stream: bool, ?stop: StopSequence, ?max_tokens: Integer, ?presence_penalty: Float, ?frequency_penalty: Float, ?logit_bias: Hash[String, Float], ?user: String, ?tools: Array[ChatCompletionTool], ?tool_choice: ToolChoice, ?parallel_tool_calls: bool, ?response_format: ResponseFormat, ?stream_options: StreamOptions, ?seed: Integer, ?reasoning_effort: ReasoningEffort, ?extra_body: json_value) -> void
175
+ def initialize: (?model: String, ?messages: Array[Message], ?temperature: Float, ?top_p: Float, ?n: Integer, ?stream: bool, ?stop: StopSequence, ?max_tokens: Integer, ?presence_penalty: Float, ?frequency_penalty: Float, ?logit_bias: Hash[String, Float], ?user: String, ?tools: Array[ChatCompletionTool], ?tool_choice: ToolChoice, ?parallel_tool_calls: bool, ?response_format: ResponseFormat, ?stream_options: StreamOptions, ?seed: Integer, ?reasoning_effort: ReasoningEffort, ?modalities: Array[Modality], ?extra_body: json_value) -> void
171
176
  end
172
177
 
173
178
  class StreamOptions
@@ -299,6 +304,13 @@ module LiterLlm
299
304
  def initialize: (?url: String, ?b64_json: String, ?revised_prompt: String) -> void
300
305
  end
301
306
 
307
+ class DecodedDataUrl
308
+ attr_accessor mime: String?
309
+ attr_accessor data: String?
310
+
311
+ def initialize: (?mime: String, ?data: String) -> void
312
+ end
313
+
302
314
  class CreateSpeechRequest
303
315
  attr_accessor model: String?
304
316
  attr_accessor input: String?
@@ -780,6 +792,12 @@ module LiterLlm
780
792
  type value = :low | :high | :auto
781
793
  end
782
794
 
795
+ class AssistantContent
796
+ end
797
+
798
+ class AssistantPart
799
+ end
800
+
783
801
  class ToolType
784
802
  type value = :function
785
803
  end
@@ -797,6 +815,10 @@ module LiterLlm
797
815
  class StopSequence
798
816
  end
799
817
 
818
+ class Modality
819
+ type value = :text | :audio | :image
820
+ end
821
+
800
822
  class FinishReason
801
823
  type value = :stop | :length | :tool_calls | :content_filter | :function_call | :other
802
824
  end
@@ -859,6 +881,10 @@ module LiterLlm
859
881
 
860
882
  def self.create_client_from_json: (String json) -> DefaultClient
861
883
 
884
+ def self.encode_data_url: (String bytes, ?String mime) -> String
885
+
886
+ def self.decode_data_url: (String url) -> DecodedDataUrl?
887
+
862
888
  def self.register_custom_provider: (CustomProviderConfig config) -> void
863
889
 
864
890
  def self.unregister_custom_provider: (String name) -> bool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liter_llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.7.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Na'aman Hirschfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-17 00:00:00.000000000 Z
11
+ date: 2026-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime