riffer 0.54.0 → 0.55.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/rules/rbs-inline.md +6 -6
  3. data/.release-please-manifest.json +1 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +28 -0
  6. data/README.md +24 -0
  7. data/Steepfile +2 -2
  8. data/docs/AGENTS.md +37 -12
  9. data/docs/CATALOG.md +8 -8
  10. data/docs/CONFIGURATION.md +47 -16
  11. data/docs/MCP.md +3 -4
  12. data/docs/STREAM_EVENTS.md +1 -1
  13. data/docs/TOOLS.md +11 -11
  14. data/docs/TRACING.md +1 -1
  15. data/docs/providers/AMAZON_BEDROCK.md +2 -0
  16. data/docs/providers/ANTHROPIC.md +32 -36
  17. data/docs/providers/CUSTOM_PROVIDERS.md +35 -0
  18. data/docs/providers/GEMINI.md +76 -26
  19. data/docs/providers/GOOGLE_CLOUD.md +363 -0
  20. data/docs/providers/PROVIDERS.md +30 -18
  21. data/docs-site/manifest.yml +3 -0
  22. data/lib/riffer/agent/structured_output.rb +6 -1
  23. data/lib/riffer/config/anthropic.rb +9 -0
  24. data/lib/riffer/config/gemini.rb +9 -0
  25. data/lib/riffer/config/google_cloud.rb +38 -0
  26. data/lib/riffer/config.rb +3 -0
  27. data/lib/riffer/http/client.rb +141 -0
  28. data/lib/riffer/http.rb +5 -0
  29. data/lib/riffer/mcp/client.rb +0 -1
  30. data/lib/riffer/params/any_of.rb +37 -9
  31. data/lib/riffer/params/param.rb +35 -14
  32. data/lib/riffer/params.rb +34 -19
  33. data/lib/riffer/providers/amazon_bedrock.rb +38 -5
  34. data/lib/riffer/providers/anthropic/client.rb +49 -0
  35. data/lib/riffer/providers/anthropic.rb +19 -452
  36. data/lib/riffer/providers/anthropic_compatible/messages_api/stream.rb +195 -0
  37. data/lib/riffer/providers/anthropic_compatible/messages_api.rb +293 -0
  38. data/lib/riffer/providers/anthropic_compatible.rb +5 -0
  39. data/lib/riffer/providers/anthropic_vertex.rb +66 -0
  40. data/lib/riffer/providers/base.rb +4 -7
  41. data/lib/riffer/providers/gemini/client.rb +17 -85
  42. data/lib/riffer/providers/gemini.rb +213 -81
  43. data/lib/riffer/providers/google_cloud/client.rb +106 -0
  44. data/lib/riffer/providers/google_cloud.rb +99 -0
  45. data/lib/riffer/providers/repository.rb +2 -0
  46. data/lib/riffer/version.rb +1 -1
  47. data/lib/riffer/wire/sse.rb +51 -0
  48. data/lib/riffer/wire.rb +31 -0
  49. data/lib/riffer.rb +18 -0
  50. data/rbs_collection.lock.yaml +24 -4
  51. data/sig/_private/faraday.rbs +8 -0
  52. data/sig/_private/googleauth.rbs +7 -0
  53. data/sig/generated/riffer/config/anthropic.rbs +6 -0
  54. data/sig/generated/riffer/config/gemini.rbs +6 -0
  55. data/sig/generated/riffer/config/google_cloud.rbs +28 -0
  56. data/sig/generated/riffer/config.rbs +2 -0
  57. data/sig/generated/riffer/http/client.rbs +59 -0
  58. data/sig/generated/riffer/http.rbs +4 -0
  59. data/sig/generated/riffer/params/any_of.rbs +13 -5
  60. data/sig/generated/riffer/params/param.rbs +10 -5
  61. data/sig/generated/riffer/params.rbs +8 -4
  62. data/sig/generated/riffer/providers/amazon_bedrock.rbs +14 -2
  63. data/sig/generated/riffer/providers/anthropic/client.rbs +34 -0
  64. data/sig/generated/riffer/providers/anthropic.rbs +5 -124
  65. data/sig/generated/riffer/providers/anthropic_compatible/messages_api/stream.rbs +71 -0
  66. data/sig/generated/riffer/providers/anthropic_compatible/messages_api.rbs +99 -0
  67. data/sig/generated/riffer/providers/anthropic_compatible.rbs +4 -0
  68. data/sig/generated/riffer/providers/anthropic_vertex.rbs +45 -0
  69. data/sig/generated/riffer/providers/gemini/client.rbs +11 -34
  70. data/sig/generated/riffer/providers/gemini.rbs +66 -4
  71. data/sig/generated/riffer/providers/google_cloud/client.rbs +71 -0
  72. data/sig/generated/riffer/providers/google_cloud.rbs +64 -0
  73. data/sig/generated/riffer/wire/sse.rbs +23 -0
  74. data/sig/generated/riffer/wire.rbs +17 -0
  75. data/sig/generated/riffer.rbs +12 -0
  76. data/sig/manual/riffer/providers/anthropic_compatible/messages_api.rbs +8 -0
  77. data/sig/manual/riffer/providers/gemini.rbs +8 -0
  78. data/sig/manual/riffer/providers/google_cloud.rbs +8 -0
  79. data/sig/manual/riffer/wire.rbs +5 -0
  80. metadata +61 -5
  81. data/sig/_private/anthropic.rbs +0 -17
  82. data/sig/_private/riffer/providers/anthropic.rbs +0 -6
  83. data/sig/_private/riffer/providers/gemini.rbs +0 -7
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ # Gemini models on Gemini Enterprise Agent Platform (formerly Vertex AI). The
5
+ # request and response bodies match the Gemini Developer API's, so this only
6
+ # swaps the transport, the resource paths and the structured output field.
7
+ class Riffer::Providers::GoogleCloud < Riffer::Providers::Gemini
8
+ # Agent Platform model ids may carry an +@version+ suffix.
9
+ VALID_MODEL_PATTERN = /\A[a-zA-Z0-9._@-]+\z/ #: Regexp
10
+
11
+ REASONING_FORMAT = "google-cloud-generate-content-v1" #: String
12
+
13
+ # Agent Platform label keys and values: at most 63 characters of lowercase
14
+ # letters, digits, underscores and dashes; keys start with a letter.
15
+ LABEL_MAX_LENGTH = 63 #: Integer
16
+ LABEL_INVALID_CHARACTERS = /[^\p{Ll}\p{Lo}\p{N}_-]/ #: Regexp
17
+
18
+ #--
19
+ #: () -> String
20
+ def self.semconv_provider_name
21
+ "gcp.vertex_ai"
22
+ end
23
+
24
+ private
25
+
26
+ #--
27
+ #: () -> untyped
28
+ def global_client
29
+ Riffer.config.google_cloud.client
30
+ end
31
+
32
+ #--
33
+ #: () -> untyped
34
+ def build_client
35
+ Riffer::Providers::GoogleCloud::Client.from_config(Riffer.config.google_cloud)
36
+ end
37
+
38
+ # Tags go out as request labels, merged over any +labels+ model option.
39
+ #--
40
+ #: (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
41
+ def build_request_params(messages, model, options)
42
+ params = super(messages, model, options.except(:labels))
43
+ labels = (options[:labels] || {}).transform_keys(&:to_s).merge(tag_labels(options[:tags] || {}))
44
+ params[:labels] = labels unless labels.empty?
45
+ params
46
+ end
47
+
48
+ # Rewrites tags into valid labels (downcased, invalid characters replaced by
49
+ # an underscore, cut to 63 characters) and drops keys that don't start with
50
+ # a letter, so a tag like agent: "support/triage_agent" can't fail the call.
51
+ #--
52
+ #: (Hash[untyped, untyped]) -> Hash[String, String]
53
+ def tag_labels(tags)
54
+ labels = {} #: Hash[String, String]
55
+ tags.each do |key, value|
56
+ next if value.nil?
57
+
58
+ label_key = to_label(key)
59
+ labels[label_key] = to_label(value) if label_key.match?(/\A\p{L}/)
60
+ end
61
+ labels
62
+ end
63
+
64
+ #--
65
+ #: (untyped) -> String
66
+ def to_label(value)
67
+ value.to_s.downcase.gsub(LABEL_INVALID_CHARACTERS, "_")[0, LABEL_MAX_LENGTH].to_s
68
+ end
69
+
70
+ #--
71
+ #: () -> String
72
+ def reasoning_format
73
+ REASONING_FORMAT
74
+ end
75
+
76
+ # Agent Platform declares responseFormat as a repeated field.
77
+ #--
78
+ #: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
79
+ def structured_output_config(json_schema)
80
+ { responseFormat: [{ text: { mimeType: "APPLICATION_JSON", schema: json_schema } }] }
81
+ end
82
+
83
+ #--
84
+ #: (String, String) -> String
85
+ def api_path(model, method)
86
+ validate_model!(model)
87
+ "publishers/google/models/#{model}:#{method}"
88
+ end
89
+
90
+ #--
91
+ #: (String) -> void
92
+ def validate_model!(model)
93
+ return if model.match?(VALID_MODEL_PATTERN)
94
+
95
+ raise Riffer::ArgumentError,
96
+ "Invalid model name: #{model.inspect}. Model must contain only alphanumeric characters, " \
97
+ "hyphens, dots, underscores, and @."
98
+ end
99
+ end
@@ -10,8 +10,10 @@ module Riffer::Providers::Repository
10
10
  REPO = {
11
11
  amazon_bedrock: -> { Riffer::Providers::AmazonBedrock },
12
12
  anthropic: -> { Riffer::Providers::Anthropic },
13
+ anthropic_vertex: -> { Riffer::Providers::AnthropicVertex },
13
14
  azure_openai: -> { Riffer::Providers::AzureOpenAI },
14
15
  gemini: -> { Riffer::Providers::Gemini },
16
+ google_cloud: -> { Riffer::Providers::GoogleCloud },
15
17
  openai: -> { Riffer::Providers::OpenAI },
16
18
  openrouter: -> { Riffer::Providers::OpenRouter },
17
19
  mock: -> { Riffer::Providers::Mock },
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Riffer
5
- VERSION = "0.54.0" #: String
5
+ VERSION = "0.55.0" #: String
6
6
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ class Riffer::Wire::SSE
5
+ # @rbs @buffer: String
6
+ # @rbs @data: Array[String]
7
+ # @rbs @event: String?
8
+
9
+ #--
10
+ #: () -> void
11
+ def initialize
12
+ @buffer = +""
13
+ @data = []
14
+ @event = nil
15
+ end
16
+
17
+ #--
18
+ #: (String) { (String, String?) -> void } -> void
19
+ def feed(chunk, &)
20
+ @buffer << chunk
21
+
22
+ # Lines end in LF or CRLF. The SSE spec also allows a bare CR, which no
23
+ # supported provider sends.
24
+ while (line_end = @buffer.index("\n"))
25
+ line = @buffer.slice!(0, line_end + 1).to_s.chomp
26
+ process_line(line, &)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ #--
33
+ #: (String) { (String, String?) -> void } -> void
34
+ def process_line(line)
35
+ if line.empty?
36
+ yield(@data.join("\n"), @event) unless @data.empty?
37
+ @data = []
38
+ @event = nil
39
+ return
40
+ end
41
+ return if line.start_with?(":")
42
+
43
+ field, value = line.split(":", 2)
44
+ value = value.to_s.delete_prefix(" ")
45
+
46
+ case field
47
+ when "data" then @data << value
48
+ when "event" then @event = value
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ require "json"
5
+
6
+ module Riffer::Wire
7
+ extend self
8
+
9
+ TOOL_NAME_SEPARATOR = "__" #: String
10
+
11
+ #--
12
+ #: (String) -> String
13
+ def encode_tool_name(name)
14
+ name.gsub("/", TOOL_NAME_SEPARATOR)
15
+ end
16
+
17
+ #--
18
+ #: (String, tools: Array[singleton(Riffer::Tool)]) -> String
19
+ def decode_tool_name(wire_name, tools:)
20
+ tool = tools.find { |t| encode_tool_name(t.name) == wire_name }
21
+ tool ? tool.name : wire_name
22
+ end
23
+
24
+ #--
25
+ #: (String) -> Hash[String, untyped]
26
+ def parse_tool_arguments(arguments)
27
+ return {} if arguments.empty?
28
+
29
+ JSON.parse(arguments)
30
+ end
31
+ end
data/lib/riffer.rb CHANGED
@@ -8,6 +8,9 @@ loader.inflector.inflect(
8
8
  "open_ai" => "OpenAI",
9
9
  "azure_open_ai" => "AzureOpenAI",
10
10
  "open_router" => "OpenRouter",
11
+ "sse" => "SSE",
12
+ "http" => "HTTP",
13
+ "messages_api" => "MessagesAPI",
11
14
  )
12
15
  # Test-framework wiring a consumer requires by hand; neither file defines the
13
16
  # constant its path implies, and both reference framework constants riffer
@@ -29,6 +32,21 @@ module Riffer
29
32
 
30
33
  class ValidationError < Error; end
31
34
 
35
+ # A provider answered with a non-success status, or sent an in-stream error
36
+ # event (+status+ is nil then). +body+ is the raw response text.
37
+ class APIError < Error
38
+ attr_reader :status #: Integer? # @dynamic status
39
+ attr_reader :body #: String? # @dynamic body
40
+
41
+ #--
42
+ #: (?String?, ?status: Integer?, ?body: String?) -> void
43
+ def initialize(message = nil, status: nil, body: nil)
44
+ super(message)
45
+ @status = status
46
+ @body = body
47
+ end
48
+ end
49
+
32
50
  # Rescue it in the tool to clean up; otherwise it becomes a
33
51
  # +:timeout_error+ response.
34
52
  class TimeoutError < Error; end
@@ -9,10 +9,6 @@ gems:
9
9
  revision: 3913b7dffb65bdffdfe5cb9095108f932e85433b
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
- - name: anthropic
13
- version: 1.76.0
14
- source:
15
- type: rubygems
16
12
  - name: ast
17
13
  version: '2.4'
18
14
  source:
@@ -117,6 +113,14 @@ gems:
117
113
  version: '0'
118
114
  source:
119
115
  type: stdlib
116
+ - name: googleauth
117
+ version: '1.11'
118
+ source:
119
+ type: git
120
+ name: ruby/gem_rbs_collection
121
+ revision: 3913b7dffb65bdffdfe5cb9095108f932e85433b
122
+ remote: https://github.com/ruby/gem_rbs_collection.git
123
+ repo_dir: gems
120
124
  - name: hashdiff
121
125
  version: '1.1'
122
126
  source:
@@ -137,6 +141,14 @@ gems:
137
141
  version: '0'
138
142
  source:
139
143
  type: stdlib
144
+ - name: jwt
145
+ version: '2.5'
146
+ source:
147
+ type: git
148
+ name: ruby/gem_rbs_collection
149
+ revision: 3913b7dffb65bdffdfe5cb9095108f932e85433b
150
+ remote: https://github.com/ruby/gem_rbs_collection.git
151
+ repo_dir: gems
140
152
  - name: language_server-protocol
141
153
  version: 3.17.0.6
142
154
  source:
@@ -265,6 +277,14 @@ gems:
265
277
  version: '0'
266
278
  source:
267
279
  type: stdlib
280
+ - name: signet
281
+ version: '0.19'
282
+ source:
283
+ type: git
284
+ name: ruby/gem_rbs_collection
285
+ revision: 3913b7dffb65bdffdfe5cb9095108f932e85433b
286
+ remote: https://github.com/ruby/gem_rbs_collection.git
287
+ repo_dir: gems
268
288
  - name: singleton
269
289
  version: '0'
270
290
  source:
@@ -0,0 +1,8 @@
1
+ # The collection's faraday 2.7 stubs declare Request#options= but not the
2
+ # reader that streaming needs to set on_data. Loaded only for riffer's own
3
+ # Steep run (consumers skip sig/_private).
4
+ module Faraday
5
+ class Request
6
+ def options: () -> Faraday::RequestOptions
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # The `googleauth` stubs in gem_rbs_collection omit the ADC entry point.
2
+ # Loaded only for riffer's own Steep run.
3
+ module Google
4
+ module Auth
5
+ def self.get_application_default: (?untyped scope, ?Hash[untyped, untyped] options) -> untyped
6
+ end
7
+ end
@@ -3,6 +3,8 @@
3
3
  class Riffer::Config::Anthropic
4
4
  attr_reader api_key: String?
5
5
 
6
+ attr_reader base_url: String?
7
+
6
8
  attr_accessor client: untyped
7
9
 
8
10
  # --
@@ -12,4 +14,8 @@ class Riffer::Config::Anthropic
12
14
  # --
13
15
  # : (untyped) -> void
14
16
  def api_key=: (untyped) -> void
17
+
18
+ # --
19
+ # : (untyped) -> void
20
+ def base_url=: (untyped) -> void
15
21
  end
@@ -3,6 +3,8 @@
3
3
  class Riffer::Config::Gemini
4
4
  attr_reader api_key: String?
5
5
 
6
+ attr_reader base_url: String?
7
+
6
8
  attr_accessor client: untyped
7
9
 
8
10
  # --
@@ -12,4 +14,8 @@ class Riffer::Config::Gemini
12
14
  # --
13
15
  # : (untyped) -> void
14
16
  def api_key=: (untyped) -> void
17
+
18
+ # --
19
+ # : (untyped) -> void
20
+ def base_url=: (untyped) -> void
15
21
  end
@@ -0,0 +1,28 @@
1
+ # Generated from lib/riffer/config/google_cloud.rb with RBS::Inline
2
+
3
+ class Riffer::Config::GoogleCloud
4
+ attr_reader project_id: String?
5
+
6
+ # The default +"global"+ endpoint routes requests to any region, so it
7
+ # carries no data-residency guarantee.
8
+ attr_reader location: String
9
+
10
+ # A googleauth credentials object; +nil+ resolves Application Default
11
+ # Credentials.
12
+ attr_accessor credentials: untyped
13
+
14
+ attr_accessor client: untyped
15
+
16
+ # --
17
+ # : () -> void
18
+ def initialize: () -> void
19
+
20
+ # --
21
+ # : (untyped) -> void
22
+ def project_id=: (untyped) -> void
23
+
24
+ # +nil+ restores the +"global"+ default.
25
+ # --
26
+ # : (untyped) -> void
27
+ def location=: (untyped) -> void
28
+ end
@@ -13,6 +13,8 @@ class Riffer::Config
13
13
 
14
14
  attr_reader gemini: Riffer::Config::Gemini
15
15
 
16
+ attr_reader google_cloud: Riffer::Config::GoogleCloud
17
+
16
18
  attr_reader openai: Riffer::Config::OpenAI
17
19
 
18
20
  attr_reader openrouter: Riffer::Config::OpenRouter
@@ -0,0 +1,59 @@
1
+ # Generated from lib/riffer/http/client.rb with RBS::Inline
2
+
3
+ class Riffer::HTTP::Client
4
+ @connection: Faraday::Connection
5
+
6
+ @extra_headers: Hash[String, String]
7
+
8
+ DEFAULT_OPEN_TIMEOUT: Integer
9
+
10
+ DEFAULT_READ_TIMEOUT: Integer
11
+
12
+ # +headers+ are sent on every request and win over the subclass's auth and
13
+ # version headers, as do headers set on the +connection+.
14
+ # --
15
+ # : (?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
16
+ def initialize: (?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
17
+
18
+ # Raises Riffer::APIError on a non-success status.
19
+ # --
20
+ # : (String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
21
+ def post: (String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
22
+
23
+ # Raises Riffer::APIError on a non-success status; the error body is never yielded.
24
+ # --
25
+ # : (String, Hash[Symbol, untyped]) { (String) -> void } -> void
26
+ def post_stream: (String, Hash[Symbol, untyped]) { (String) -> void } -> void
27
+
28
+ private
29
+
30
+ # --
31
+ # : (String) -> String
32
+ def url_for: (String) -> String
33
+
34
+ # Called per request so short-lived credentials can refresh.
35
+ # --
36
+ # : () -> Hash[String, String]
37
+ def headers: () -> Hash[String, String]
38
+
39
+ # --
40
+ # : () -> String
41
+ def error_label: () -> String
42
+
43
+ # --
44
+ # : (Hash[Symbol, untyped], String) -> String
45
+ def error_message: (Hash[Symbol, untyped], String) -> String
46
+
47
+ # Headers go on the request, never on the connection, which may be shared
48
+ # across fibers and keeps whatever headers the caller configured on it.
49
+ # Faraday matches header names case-insensitively, so a caller's header
50
+ # replaces the subclass's whatever its casing. The content and encoding
51
+ # headers below are always riffer's: the body and the stream depend on them.
52
+ # --
53
+ # : (String, Hash[Symbol, untyped], ?on_data: Proc?) -> Faraday::Response
54
+ def request: (String, Hash[Symbol, untyped], ?on_data: Proc?) -> Faraday::Response
55
+
56
+ # --
57
+ # : (Integer, String) -> bot
58
+ def raise_api_error!: (Integer, String) -> bot
59
+ end
@@ -0,0 +1,4 @@
1
+ # Generated from lib/riffer/http.rb with RBS::Inline
2
+
3
+ module Riffer::HTTP
4
+ end
@@ -1,13 +1,21 @@
1
1
  # Generated from lib/riffer/params/any_of.rb with RBS::Inline
2
2
 
3
3
  class Riffer::Params::AnyOf
4
- attr_reader variants: Array[Riffer::Params]
4
+ @name: Symbol
5
+
6
+ attr_reader variants: Array[Riffer::Params | Riffer::Params::Param]
7
+
8
+ # --
9
+ # : (Symbol) -> void
10
+ def initialize: (Symbol) -> void
5
11
 
6
12
  # --
7
- # : () -> void
8
- def initialize: () -> void
13
+ # : (?Module?, ?description: String?, ?enum: Array[untyped]?, ?format: String?) ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> void
14
+ def variant: (?Module?, ?description: String?, ?enum: Array[untyped]?, ?format: String?) ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> void
15
+
16
+ private
9
17
 
10
18
  # --
11
- # : () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> void
12
- def variant: () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> void
19
+ # : (Module, String?, Array[untyped]?, String?) -> Riffer::Params::Param
20
+ def primitive: (Module, String?, Array[untyped]?, String?) -> Riffer::Params::Param
13
21
  end
@@ -27,15 +27,15 @@ class Riffer::Params::Param
27
27
 
28
28
  attr_reader nested_params: Riffer::Params?
29
29
 
30
- attr_reader variants: Array[Riffer::Params]?
30
+ attr_reader variants: Array[Riffer::Params | Riffer::Params::Param]?
31
31
 
32
32
  # --
33
33
  # : (Symbol, Hash[Symbol, untyped], required: bool) -> Riffer::Params::Param
34
34
  def self.from_json_schema: (Symbol, Hash[Symbol, untyped], required: bool) -> Riffer::Params::Param
35
35
 
36
36
  # --
37
- # : (Array[Hash[Symbol, untyped]]) -> Array[Riffer::Params]
38
- def self.resolve_variants: (Array[Hash[Symbol, untyped]]) -> Array[Riffer::Params]
37
+ # : (Symbol, Array[Hash[Symbol, untyped]]) -> Array[Riffer::Params | Riffer::Params::Param]
38
+ def self.resolve_variants: (Symbol, Array[Hash[Symbol, untyped]]) -> Array[Riffer::Params | Riffer::Params::Param]
39
39
 
40
40
  # --
41
41
  # : (Module, Hash[Symbol, untyped]) -> Riffer::Params?
@@ -50,8 +50,8 @@ class Riffer::Params::Param
50
50
  def self.json_type_to_ruby: (untyped) -> Module
51
51
 
52
52
  # --
53
- # : (name: Symbol, type: Module, required: bool, ?description: String?, ?enum: Array[untyped]?, ?format: String?, ?default: untyped, ?item_type: Module?, ?dimensions: Integer, ?nested_params: Riffer::Params?, ?variants: Array[Riffer::Params]?) -> void
54
- def initialize: (name: Symbol, type: Module, required: bool, ?description: String?, ?enum: Array[untyped]?, ?format: String?, ?default: untyped, ?item_type: Module?, ?dimensions: Integer, ?nested_params: Riffer::Params?, ?variants: Array[Riffer::Params]?) -> void
53
+ # : (name: Symbol, type: Module, required: bool, ?description: String?, ?enum: Array[untyped]?, ?format: String?, ?default: untyped, ?item_type: Module?, ?dimensions: Integer, ?nested_params: Riffer::Params?, ?variants: Array[Riffer::Params | Riffer::Params::Param]?) -> void
54
+ def initialize: (name: Symbol, type: Module, required: bool, ?description: String?, ?enum: Array[untyped]?, ?format: String?, ?default: untyped, ?item_type: Module?, ?dimensions: Integer, ?nested_params: Riffer::Params?, ?variants: Array[Riffer::Params | Riffer::Params::Param]?) -> void
55
55
 
56
56
  # --
57
57
  # : (untyped) -> bool
@@ -74,6 +74,11 @@ class Riffer::Params::Param
74
74
  # : (Riffer::Params::Param) -> void
75
75
  def initialize_copy: (Riffer::Params::Param) -> void
76
76
 
77
+ # The first matching variant wins, and a Float variant without an enum accepts any number.
78
+ # --
79
+ # : () -> void
80
+ def validate_variant_order!: () -> void
81
+
77
82
  # --
78
83
  # : () -> void
79
84
  def validate_format!: () -> void
@@ -50,8 +50,12 @@ class Riffer::Params
50
50
  def build_nested: (Module, Module?, Array[untyped]?) ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
51
51
 
52
52
  # --
53
- # : ((Module | Array[untyped])?, Array[untyped]?) ?{ (Riffer::Params::AnyOf) [self: Riffer::Params::AnyOf] -> void } -> Array[Riffer::Params]
54
- def build_variants: ((Module | Array[untyped])?, Array[untyped]?) ?{ (Riffer::Params::AnyOf) [self: Riffer::Params::AnyOf] -> void } -> Array[Riffer::Params]
53
+ # : (Symbol, (Module | Array[untyped])?, Array[untyped]?) ?{ (Riffer::Params::AnyOf) [self: Riffer::Params::AnyOf] -> void } -> Array[Riffer::Params | Riffer::Params::Param]
54
+ def build_variants: (Symbol, (Module | Array[untyped])?, Array[untyped]?) ?{ (Riffer::Params::AnyOf) [self: Riffer::Params::AnyOf] -> void } -> Array[Riffer::Params | Riffer::Params::Param]
55
+
56
+ # --
57
+ # : (Riffer::Params::Param, untyped) -> String?
58
+ def value_error: (Riffer::Params::Param, untyped) -> String?
55
59
 
56
60
  # --
57
61
  # : (Riffer::Params::Param, untyped, Array[String]) -> untyped
@@ -62,8 +66,8 @@ class Riffer::Params
62
66
  def validate_nested_hash: (Riffer::Params::Param, Hash[Symbol, untyped], Array[String]) -> Hash[Symbol, untyped]
63
67
 
64
68
  # --
65
- # : (Riffer::Params::Param, Hash[Symbol, untyped], Array[String]) -> Hash[Symbol, untyped]
66
- def validate_any_of: (Riffer::Params::Param, Hash[Symbol, untyped], Array[String]) -> Hash[Symbol, untyped]
69
+ # : (Riffer::Params::Param, untyped, Array[String]) -> untyped
70
+ def validate_any_of: (Riffer::Params::Param, untyped, Array[String]) -> untyped
67
71
 
68
72
  # Validation drops keys a Params doesn't declare, at any depth, so they are
69
73
  # the keys in the input that are missing from the output.
@@ -150,9 +150,21 @@ class Riffer::Providers::AmazonBedrock < Riffer::Providers::Base
150
150
  # : (Array[Hash[Symbol, untyped]], Riffer::Messages::Tool) -> void
151
151
  def append_tool_result: (Array[Hash[Symbol, untyped]], Riffer::Messages::Tool) -> void
152
152
 
153
+ # +document_names+ collects the names already used in the request, which
154
+ # Converse requires to be unique across every message.
153
155
  # --
154
- # : (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
155
- def convert_file_part_to_bedrock_format: (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
156
+ # : (Riffer::Messages::User::FilePart, Array[String]) -> Hash[Symbol, untyped]
157
+ def convert_file_part_to_bedrock_format: (Riffer::Messages::User::FilePart, Array[String]) -> Hash[Symbol, untyped]
158
+
159
+ DOCUMENT_NAME_LIMIT: Integer
160
+
161
+ # Converse allows only alphanumerics, single whitespace, hyphens, parentheses
162
+ # and square brackets in a document name, up to 200 characters, so
163
+ # +invoice.pdf+ is sent as +invoice+ and a repeated name gets a counter:
164
+ # +invoice (2)+.
165
+ # --
166
+ # : (String?, Array[String]) -> String
167
+ def document_name: (String?, Array[String]) -> String
156
168
 
157
169
  BEDROCK_FORMAT_MAP: Hash[String, String]
158
170
 
@@ -0,0 +1,34 @@
1
+ # Generated from lib/riffer/providers/anthropic/client.rb with RBS::Inline
2
+
3
+ class Riffer::Providers::Anthropic::Client < Riffer::HTTP::Client
4
+ @api_key: String
5
+
6
+ @base_url: String
7
+
8
+ DEFAULT_BASE_URL: String
9
+
10
+ # Override with an anthropic-version entry in +headers+.
11
+ DEFAULT_ANTHROPIC_VERSION: String
12
+
13
+ # --
14
+ # : (api_key: String, ?base_url: String, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
15
+ def initialize: (api_key: String, ?base_url: String, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
16
+
17
+ private
18
+
19
+ # --
20
+ # : (String) -> String
21
+ def url_for: (String) -> String
22
+
23
+ # --
24
+ # : () -> Hash[String, String]
25
+ def headers: () -> Hash[String, String]
26
+
27
+ # --
28
+ # : () -> String
29
+ def error_label: () -> String
30
+
31
+ # --
32
+ # : (Hash[Symbol, untyped], String) -> String
33
+ def error_message: (Hash[Symbol, untyped], String) -> String
34
+ end