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.
- checksums.yaml +4 -4
- data/.claude/rules/rbs-inline.md +6 -6
- data/.release-please-manifest.json +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +28 -0
- data/README.md +24 -0
- data/Steepfile +2 -2
- data/docs/AGENTS.md +37 -12
- data/docs/CATALOG.md +8 -8
- data/docs/CONFIGURATION.md +47 -16
- data/docs/MCP.md +3 -4
- data/docs/STREAM_EVENTS.md +1 -1
- data/docs/TOOLS.md +11 -11
- data/docs/TRACING.md +1 -1
- data/docs/providers/AMAZON_BEDROCK.md +2 -0
- data/docs/providers/ANTHROPIC.md +32 -36
- data/docs/providers/CUSTOM_PROVIDERS.md +35 -0
- data/docs/providers/GEMINI.md +76 -26
- data/docs/providers/GOOGLE_CLOUD.md +363 -0
- data/docs/providers/PROVIDERS.md +30 -18
- data/docs-site/manifest.yml +3 -0
- data/lib/riffer/agent/structured_output.rb +6 -1
- data/lib/riffer/config/anthropic.rb +9 -0
- data/lib/riffer/config/gemini.rb +9 -0
- data/lib/riffer/config/google_cloud.rb +38 -0
- data/lib/riffer/config.rb +3 -0
- data/lib/riffer/http/client.rb +141 -0
- data/lib/riffer/http.rb +5 -0
- data/lib/riffer/mcp/client.rb +0 -1
- data/lib/riffer/params/any_of.rb +37 -9
- data/lib/riffer/params/param.rb +35 -14
- data/lib/riffer/params.rb +34 -19
- data/lib/riffer/providers/amazon_bedrock.rb +38 -5
- data/lib/riffer/providers/anthropic/client.rb +49 -0
- data/lib/riffer/providers/anthropic.rb +19 -452
- data/lib/riffer/providers/anthropic_compatible/messages_api/stream.rb +195 -0
- data/lib/riffer/providers/anthropic_compatible/messages_api.rb +293 -0
- data/lib/riffer/providers/anthropic_compatible.rb +5 -0
- data/lib/riffer/providers/anthropic_vertex.rb +66 -0
- data/lib/riffer/providers/base.rb +4 -7
- data/lib/riffer/providers/gemini/client.rb +17 -85
- data/lib/riffer/providers/gemini.rb +213 -81
- data/lib/riffer/providers/google_cloud/client.rb +106 -0
- data/lib/riffer/providers/google_cloud.rb +99 -0
- data/lib/riffer/providers/repository.rb +2 -0
- data/lib/riffer/version.rb +1 -1
- data/lib/riffer/wire/sse.rb +51 -0
- data/lib/riffer/wire.rb +31 -0
- data/lib/riffer.rb +18 -0
- data/rbs_collection.lock.yaml +24 -4
- data/sig/_private/faraday.rbs +8 -0
- data/sig/_private/googleauth.rbs +7 -0
- data/sig/generated/riffer/config/anthropic.rbs +6 -0
- data/sig/generated/riffer/config/gemini.rbs +6 -0
- data/sig/generated/riffer/config/google_cloud.rbs +28 -0
- data/sig/generated/riffer/config.rbs +2 -0
- data/sig/generated/riffer/http/client.rbs +59 -0
- data/sig/generated/riffer/http.rbs +4 -0
- data/sig/generated/riffer/params/any_of.rbs +13 -5
- data/sig/generated/riffer/params/param.rbs +10 -5
- data/sig/generated/riffer/params.rbs +8 -4
- data/sig/generated/riffer/providers/amazon_bedrock.rbs +14 -2
- data/sig/generated/riffer/providers/anthropic/client.rbs +34 -0
- data/sig/generated/riffer/providers/anthropic.rbs +5 -124
- data/sig/generated/riffer/providers/anthropic_compatible/messages_api/stream.rbs +71 -0
- data/sig/generated/riffer/providers/anthropic_compatible/messages_api.rbs +99 -0
- data/sig/generated/riffer/providers/anthropic_compatible.rbs +4 -0
- data/sig/generated/riffer/providers/anthropic_vertex.rbs +45 -0
- data/sig/generated/riffer/providers/gemini/client.rbs +11 -34
- data/sig/generated/riffer/providers/gemini.rbs +66 -4
- data/sig/generated/riffer/providers/google_cloud/client.rbs +71 -0
- data/sig/generated/riffer/providers/google_cloud.rbs +64 -0
- data/sig/generated/riffer/wire/sse.rbs +23 -0
- data/sig/generated/riffer/wire.rbs +17 -0
- data/sig/generated/riffer.rbs +12 -0
- data/sig/manual/riffer/providers/anthropic_compatible/messages_api.rbs +8 -0
- data/sig/manual/riffer/providers/gemini.rbs +8 -0
- data/sig/manual/riffer/providers/google_cloud.rbs +8 -0
- data/sig/manual/riffer/wire.rbs +5 -0
- metadata +61 -5
- data/sig/_private/anthropic.rbs +0 -17
- data/sig/_private/riffer/providers/anthropic.rbs +0 -6
- data/sig/_private/riffer/providers/gemini.rbs +0 -7
|
@@ -1,140 +1,21 @@
|
|
|
1
1
|
# Generated from lib/riffer/providers/anthropic.rb with RBS::Inline
|
|
2
2
|
|
|
3
|
-
class Riffer::Providers::Anthropic < Riffer::Providers::
|
|
4
|
-
WEB_SEARCH_TOOL_TYPE: String
|
|
5
|
-
|
|
6
|
-
FINISH_REASONS: Hash[String, Symbol]
|
|
7
|
-
|
|
8
|
-
# Only parts carrying this tag are replayed, so reasoning captured by another
|
|
9
|
-
# adapter, whose signatures the Messages API may not accept, never reaches the
|
|
10
|
-
# request.
|
|
11
|
-
REASONING_FORMAT: String
|
|
12
|
-
|
|
13
|
-
# --
|
|
14
|
-
# : (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
15
|
-
def self.skills_adapter: (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
16
|
-
|
|
3
|
+
class Riffer::Providers::Anthropic < Riffer::Providers::AnthropicCompatible::MessagesAPI
|
|
17
4
|
# --
|
|
18
5
|
# : () -> String
|
|
19
6
|
def self.semconv_provider_name: () -> String
|
|
20
7
|
|
|
21
|
-
# --
|
|
22
|
-
# : () -> void
|
|
23
|
-
def initialize: () -> void
|
|
24
|
-
|
|
25
8
|
private
|
|
26
9
|
|
|
27
10
|
# --
|
|
28
11
|
# : () -> untyped
|
|
29
|
-
def
|
|
12
|
+
def client: () -> untyped
|
|
30
13
|
|
|
31
14
|
# --
|
|
32
15
|
# : () -> untyped
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
# --
|
|
36
|
-
# : (Symbol) -> Hash[Symbol, untyped]
|
|
37
|
-
def default_reasoning_options: (Symbol) -> Hash[Symbol, untyped]
|
|
38
|
-
|
|
39
|
-
# --
|
|
40
|
-
# : (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
41
|
-
def build_request_params: (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
42
|
-
|
|
43
|
-
# --
|
|
44
|
-
# : (Hash[Symbol, untyped]) -> untyped
|
|
45
|
-
def execute_generate: (Hash[Symbol, untyped]) -> untyped
|
|
46
|
-
|
|
47
|
-
# --
|
|
48
|
-
# : (untyped) -> Riffer::Providers::TokenUsage?
|
|
49
|
-
def extract_token_usage: (untyped) -> Riffer::Providers::TokenUsage?
|
|
50
|
-
|
|
51
|
-
# --
|
|
52
|
-
# : (untyped) -> Riffer::Providers::FinishReason?
|
|
53
|
-
def extract_finish_reason: (untyped) -> Riffer::Providers::FinishReason?
|
|
54
|
-
|
|
55
|
-
# --
|
|
56
|
-
# : (untyped) -> Riffer::Providers::FinishReason?
|
|
57
|
-
def build_finish_reason: (untyped) -> Riffer::Providers::FinishReason?
|
|
58
|
-
|
|
59
|
-
# --
|
|
60
|
-
# : (untyped) -> Riffer::Providers::TokenUsage
|
|
61
|
-
def build_token_usage: (untyped) -> Riffer::Providers::TokenUsage
|
|
62
|
-
|
|
63
|
-
# --
|
|
64
|
-
# : (untyped) -> String
|
|
65
|
-
def extract_content: (untyped) -> String
|
|
66
|
-
|
|
67
|
-
# --
|
|
68
|
-
# : (untyped) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
69
|
-
def extract_tool_calls: (untyped) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
70
|
-
|
|
71
|
-
# --
|
|
72
|
-
# : (untyped) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
73
|
-
def extract_reasoning: (untyped) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
74
|
-
|
|
75
|
-
# --
|
|
76
|
-
# : (untyped) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
77
|
-
def build_reasoning_part: (untyped) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
78
|
-
|
|
79
|
-
# --
|
|
80
|
-
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
81
|
-
def execute_stream: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
82
|
-
|
|
83
|
-
# --
|
|
84
|
-
# : (untyped, state: Hash[Symbol, untyped]) -> void
|
|
85
|
-
def handle_raw_content_block_start: (untyped, state: Hash[Symbol, untyped]) -> void
|
|
86
|
-
|
|
87
|
-
# --
|
|
88
|
-
# : (untyped, state: Hash[Symbol, untyped]) -> void
|
|
89
|
-
def handle_raw_content_block_delta: (untyped, state: Hash[Symbol, untyped]) -> void
|
|
90
|
-
|
|
91
|
-
# --
|
|
92
|
-
# : (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
93
|
-
def handle_text_event: (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
94
|
-
|
|
95
|
-
# --
|
|
96
|
-
# : (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
97
|
-
def handle_input_json_event: (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
98
|
-
|
|
99
|
-
# --
|
|
100
|
-
# : (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
101
|
-
def handle_content_block_stop_tool_use: (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
102
|
-
|
|
103
|
-
# The SDK's accumulated block already carries the full thinking text and the
|
|
104
|
-
# signature from its trailing signature_delta.
|
|
105
|
-
# --
|
|
106
|
-
# : (untyped, yielder: Riffer::Providers::_EventSink) -> void
|
|
107
|
-
def handle_content_block_stop_reasoning: (untyped, yielder: Riffer::Providers::_EventSink) -> void
|
|
108
|
-
|
|
109
|
-
# --
|
|
110
|
-
# : (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
111
|
-
def handle_content_block_stop_server_tool_use: (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
112
|
-
|
|
113
|
-
# --
|
|
114
|
-
# : (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
115
|
-
def handle_content_block_stop_web_search_result: (untyped, state: Hash[Symbol, untyped], yielder: Riffer::Providers::_EventSink) -> void
|
|
116
|
-
|
|
117
|
-
# --
|
|
118
|
-
# : (untyped, state: Hash[Symbol, untyped], accumulated_message: untyped, yielder: Riffer::Providers::_EventSink) -> void
|
|
119
|
-
def handle_message_stop: (untyped, state: Hash[Symbol, untyped], accumulated_message: untyped, yielder: Riffer::Providers::_EventSink) -> void
|
|
120
|
-
|
|
121
|
-
# --
|
|
122
|
-
# : (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
123
|
-
def partition_messages: (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
124
|
-
|
|
125
|
-
# --
|
|
126
|
-
# : (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
127
|
-
def convert_assistant_to_anthropic_format: (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
128
|
-
|
|
129
|
-
# --
|
|
130
|
-
# : (Riffer::Messages::Assistant::ReasoningPart) -> Hash[Symbol, untyped]
|
|
131
|
-
def convert_reasoning_part_to_anthropic_format: (Riffer::Messages::Assistant::ReasoningPart) -> Hash[Symbol, untyped]
|
|
132
|
-
|
|
133
|
-
# --
|
|
134
|
-
# : (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
|
|
135
|
-
def convert_file_part_to_anthropic_format: (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
|
|
16
|
+
def global_client: () -> untyped
|
|
136
17
|
|
|
137
18
|
# --
|
|
138
|
-
# : (
|
|
139
|
-
def
|
|
19
|
+
# : () -> Riffer::Providers::Anthropic::Client
|
|
20
|
+
def build_client: () -> Riffer::Providers::Anthropic::Client
|
|
140
21
|
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/anthropic_compatible/messages_api/stream.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
class Riffer::Providers::AnthropicCompatible::MessagesAPI::Stream
|
|
4
|
+
@completed: bool
|
|
5
|
+
|
|
6
|
+
@web_search_query: String?
|
|
7
|
+
|
|
8
|
+
@partial_json: Hash[Integer, String]
|
|
9
|
+
|
|
10
|
+
@message: Hash[Symbol, untyped]
|
|
11
|
+
|
|
12
|
+
@tools: Array[singleton(Riffer::Tool)]
|
|
13
|
+
|
|
14
|
+
# --
|
|
15
|
+
# : (Hash[Symbol, untyped]) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
16
|
+
def self.reasoning_part: (Hash[Symbol, untyped]) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
17
|
+
|
|
18
|
+
# --
|
|
19
|
+
# : (tools: Array[singleton(Riffer::Tool)]) -> void
|
|
20
|
+
def initialize: (tools: Array[singleton(Riffer::Tool)]) -> void
|
|
21
|
+
|
|
22
|
+
# Raises Riffer::APIError on a stream +error+ event.
|
|
23
|
+
# --
|
|
24
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
25
|
+
def handle: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
26
|
+
|
|
27
|
+
# The caller reads finish reason and usage from here so it can price the usage.
|
|
28
|
+
# --
|
|
29
|
+
# : () -> Hash[Symbol, untyped]
|
|
30
|
+
def finish!: () -> Hash[Symbol, untyped]
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# --
|
|
35
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
36
|
+
def start_message: (Hash[Symbol, untyped]) -> void
|
|
37
|
+
|
|
38
|
+
# --
|
|
39
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
40
|
+
def start_block: (Hash[Symbol, untyped]) -> void
|
|
41
|
+
|
|
42
|
+
# --
|
|
43
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
44
|
+
def apply_delta: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
45
|
+
|
|
46
|
+
# --
|
|
47
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
48
|
+
def stop_block: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
49
|
+
|
|
50
|
+
# --
|
|
51
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
52
|
+
def apply_message_delta: (Hash[Symbol, untyped]) -> void
|
|
53
|
+
|
|
54
|
+
# --
|
|
55
|
+
# : (Riffer::Providers::_EventSink) -> void
|
|
56
|
+
def stop_message: (Riffer::Providers::_EventSink) -> void
|
|
57
|
+
|
|
58
|
+
# --
|
|
59
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
60
|
+
def raise_stream_error: (Hash[Symbol, untyped]) -> void
|
|
61
|
+
|
|
62
|
+
# A response cut off by max_tokens can end a block mid-input, leaving JSON
|
|
63
|
+
# that does not parse.
|
|
64
|
+
# --
|
|
65
|
+
# : (String) -> Hash[String, untyped]?
|
|
66
|
+
def parse_input: (String) -> Hash[String, untyped]?
|
|
67
|
+
|
|
68
|
+
# --
|
|
69
|
+
# : (Hash[Symbol, untyped]) -> Array[Hash[Symbol, String?]]
|
|
70
|
+
def web_search_sources: (Hash[Symbol, untyped]) -> Array[Hash[Symbol, String?]]
|
|
71
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/anthropic_compatible/messages_api.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
class Riffer::Providers::AnthropicCompatible::MessagesAPI < Riffer::Providers::Base
|
|
4
|
+
WEB_SEARCH_TOOL_TYPE: String
|
|
5
|
+
|
|
6
|
+
FINISH_REASONS: Hash[String, Symbol]
|
|
7
|
+
|
|
8
|
+
# Only parts carrying this tag are replayed, so reasoning captured by another
|
|
9
|
+
# adapter, whose signatures the Messages API may not accept, never reaches the
|
|
10
|
+
# request.
|
|
11
|
+
REASONING_FORMAT: String
|
|
12
|
+
|
|
13
|
+
# --
|
|
14
|
+
# : (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
15
|
+
def self.skills_adapter: (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
# --
|
|
20
|
+
# : (Symbol) -> Hash[Symbol, untyped]
|
|
21
|
+
def default_reasoning_options: (Symbol) -> Hash[Symbol, untyped]
|
|
22
|
+
|
|
23
|
+
# Relative to the client's base URL.
|
|
24
|
+
# --
|
|
25
|
+
# : (String?, stream: bool) -> String
|
|
26
|
+
def messages_path: (String?, stream: bool) -> String
|
|
27
|
+
|
|
28
|
+
# --
|
|
29
|
+
# : (Hash[Symbol, untyped], stream: bool) -> Hash[Symbol, untyped]
|
|
30
|
+
def request_body: (Hash[Symbol, untyped], stream: bool) -> Hash[Symbol, untyped]
|
|
31
|
+
|
|
32
|
+
# --
|
|
33
|
+
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
34
|
+
def execute_generate: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
35
|
+
|
|
36
|
+
# --
|
|
37
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
38
|
+
def execute_stream: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
39
|
+
|
|
40
|
+
# --
|
|
41
|
+
# : (Hash[Symbol, untyped]) -> String
|
|
42
|
+
def extract_content: (Hash[Symbol, untyped]) -> String
|
|
43
|
+
|
|
44
|
+
# --
|
|
45
|
+
# : (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
46
|
+
def extract_tool_calls: (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
47
|
+
|
|
48
|
+
# --
|
|
49
|
+
# : (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
50
|
+
def extract_reasoning: (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
51
|
+
|
|
52
|
+
# --
|
|
53
|
+
# : (Hash[Symbol, untyped]) -> Riffer::Providers::TokenUsage?
|
|
54
|
+
def extract_token_usage: (Hash[Symbol, untyped]) -> Riffer::Providers::TokenUsage?
|
|
55
|
+
|
|
56
|
+
# --
|
|
57
|
+
# : (Hash[Symbol, untyped]) -> Riffer::Providers::FinishReason?
|
|
58
|
+
def extract_finish_reason: (Hash[Symbol, untyped]) -> Riffer::Providers::FinishReason?
|
|
59
|
+
|
|
60
|
+
# --
|
|
61
|
+
# : (Hash[Symbol, untyped]) -> Array[Hash[Symbol, untyped]]
|
|
62
|
+
def content_blocks: (Hash[Symbol, untyped]) -> Array[Hash[Symbol, untyped]]
|
|
63
|
+
|
|
64
|
+
# --
|
|
65
|
+
# : (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
66
|
+
def build_request_params: (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
67
|
+
|
|
68
|
+
# --
|
|
69
|
+
# : (Hash[String, untyped]) -> Hash[Symbol, untyped]?
|
|
70
|
+
def request_metadata: (Hash[String, untyped]) -> Hash[Symbol, untyped]?
|
|
71
|
+
|
|
72
|
+
# --
|
|
73
|
+
# : (untyped) -> Hash[Symbol, untyped]
|
|
74
|
+
def web_search_tool: (untyped) -> Hash[Symbol, untyped]
|
|
75
|
+
|
|
76
|
+
# --
|
|
77
|
+
# : (Riffer::Agent::StructuredOutput) -> Hash[Symbol, untyped]
|
|
78
|
+
def structured_output_config: (Riffer::Agent::StructuredOutput) -> Hash[Symbol, untyped]
|
|
79
|
+
|
|
80
|
+
# --
|
|
81
|
+
# : (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
82
|
+
def partition_messages: (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
83
|
+
|
|
84
|
+
# --
|
|
85
|
+
# : (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
86
|
+
def convert_assistant: (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
87
|
+
|
|
88
|
+
# --
|
|
89
|
+
# : (Riffer::Messages::Assistant::ReasoningPart) -> Hash[Symbol, untyped]
|
|
90
|
+
def convert_reasoning_part: (Riffer::Messages::Assistant::ReasoningPart) -> Hash[Symbol, untyped]
|
|
91
|
+
|
|
92
|
+
# --
|
|
93
|
+
# : (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
|
|
94
|
+
def convert_file_part: (Riffer::Messages::User::FilePart) -> Hash[Symbol, untyped]
|
|
95
|
+
|
|
96
|
+
# --
|
|
97
|
+
# : (singleton(Riffer::Tool)) -> Hash[Symbol, untyped]
|
|
98
|
+
def convert_tool: (singleton(Riffer::Tool)) -> Hash[Symbol, untyped]
|
|
99
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/anthropic_vertex.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# Claude models on Gemini Enterprise Agent Platform (formerly Vertex AI), through
|
|
4
|
+
# its rawPredict endpoints. Shares config.google_cloud and GoogleCloud::Client
|
|
5
|
+
# with the google_cloud provider.
|
|
6
|
+
class Riffer::Providers::AnthropicVertex < Riffer::Providers::AnthropicCompatible::MessagesAPI
|
|
7
|
+
# Matches the Anthropic provider. Agent Platform also accepts "vertex-2023-10-16".
|
|
8
|
+
DEFAULT_ANTHROPIC_VERSION: String
|
|
9
|
+
|
|
10
|
+
# Agent Platform model ids may carry an +@version+ suffix.
|
|
11
|
+
VALID_MODEL_PATTERN: Regexp
|
|
12
|
+
|
|
13
|
+
# --
|
|
14
|
+
# : () -> String
|
|
15
|
+
def self.semconv_provider_name: () -> String
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
# --
|
|
20
|
+
# : () -> untyped
|
|
21
|
+
def global_client: () -> untyped
|
|
22
|
+
|
|
23
|
+
# --
|
|
24
|
+
# : () -> Riffer::Providers::GoogleCloud::Client
|
|
25
|
+
def build_client: () -> Riffer::Providers::GoogleCloud::Client
|
|
26
|
+
|
|
27
|
+
# Agent Platform takes the API version in the body, in place of the
|
|
28
|
+
# anthropic-version header. Override in a subclass to send another version.
|
|
29
|
+
# --
|
|
30
|
+
# : () -> String
|
|
31
|
+
def anthropic_version: () -> String
|
|
32
|
+
|
|
33
|
+
# The model goes in the URL rather than the body.
|
|
34
|
+
# --
|
|
35
|
+
# : (String?, stream: bool) -> String
|
|
36
|
+
def messages_path: (String?, stream: bool) -> String
|
|
37
|
+
|
|
38
|
+
# --
|
|
39
|
+
# : (Hash[Symbol, untyped], stream: bool) -> Hash[Symbol, untyped]
|
|
40
|
+
def request_body: (Hash[Symbol, untyped], stream: bool) -> Hash[Symbol, untyped]
|
|
41
|
+
|
|
42
|
+
# --
|
|
43
|
+
# : (String?) -> void
|
|
44
|
+
def validate_model!: (String?) -> void
|
|
45
|
+
end
|
|
@@ -1,52 +1,29 @@
|
|
|
1
1
|
# Generated from lib/riffer/providers/gemini/client.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
# <tt>Riffer.config.gemini.client</tt> accepts any object implementing +post+ and +post_stream+
|
|
4
|
-
#
|
|
5
|
-
class Riffer::Providers::Gemini::Client
|
|
6
|
-
@
|
|
7
|
-
|
|
8
|
-
@proxy_address: String?
|
|
9
|
-
|
|
10
|
-
@write_timeout: Integer?
|
|
11
|
-
|
|
12
|
-
@read_timeout: Integer
|
|
13
|
-
|
|
14
|
-
@open_timeout: Integer
|
|
4
|
+
# (see Riffer::HTTP::Client); this class is the default, not a required base.
|
|
5
|
+
class Riffer::Providers::Gemini::Client < Riffer::HTTP::Client
|
|
6
|
+
@api_key: String
|
|
15
7
|
|
|
16
8
|
@base_url: String
|
|
17
9
|
|
|
18
|
-
@api_key: String?
|
|
19
|
-
|
|
20
10
|
DEFAULT_BASE_URL: String
|
|
21
11
|
|
|
22
|
-
DEFAULT_OPEN_TIMEOUT: Integer
|
|
23
|
-
|
|
24
|
-
DEFAULT_READ_TIMEOUT: Integer
|
|
25
|
-
|
|
26
|
-
# : (?api_key: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer?, ?proxy_address: String?, ?proxy_port: Integer?) -> void
|
|
27
|
-
def initialize: (?api_key: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer?, ?proxy_address: String?, ?proxy_port: Integer?) -> void
|
|
28
|
-
|
|
29
|
-
# Raises Riffer::Error on a non-success status.
|
|
30
|
-
# --
|
|
31
|
-
# : (String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
32
|
-
def post: (String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
33
|
-
|
|
34
|
-
# Raises Riffer::Error on a non-success status.
|
|
35
12
|
# --
|
|
36
|
-
# : (String, Hash[
|
|
37
|
-
def
|
|
13
|
+
# : (api_key: String, ?base_url: String, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
|
|
14
|
+
def initialize: (api_key: String, ?base_url: String, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
|
|
38
15
|
|
|
39
16
|
private
|
|
40
17
|
|
|
41
18
|
# --
|
|
42
|
-
# : (
|
|
43
|
-
def
|
|
19
|
+
# : (String) -> String
|
|
20
|
+
def url_for: (String) -> String
|
|
44
21
|
|
|
45
22
|
# --
|
|
46
|
-
# :
|
|
47
|
-
def
|
|
23
|
+
# : () -> Hash[String, String]
|
|
24
|
+
def headers: () -> Hash[String, String]
|
|
48
25
|
|
|
49
26
|
# --
|
|
50
|
-
# : (
|
|
51
|
-
def
|
|
27
|
+
# : () -> String
|
|
28
|
+
def error_label: () -> String
|
|
52
29
|
end
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
class Riffer::Providers::Gemini < Riffer::Providers::Base
|
|
4
4
|
VALID_MODEL_PATTERN: Regexp
|
|
5
5
|
|
|
6
|
+
REASONING_FORMAT: String
|
|
7
|
+
|
|
8
|
+
GEMINI_CALL_ID_PATTERN: Regexp
|
|
9
|
+
|
|
10
|
+
WEB_SEARCH_TOOL_TYPE: String
|
|
11
|
+
|
|
12
|
+
# Gemini's documented stand-in for a function call it didn't sign, such as
|
|
13
|
+
# one another provider made. Without a signature it rejects the call.
|
|
14
|
+
PLACEHOLDER_SIGNATURE: String
|
|
15
|
+
|
|
6
16
|
FINISH_REASONS: Hash[String, Symbol]
|
|
7
17
|
|
|
8
18
|
# --
|
|
@@ -31,6 +41,16 @@ class Riffer::Providers::Gemini < Riffer::Providers::Base
|
|
|
31
41
|
# : (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
32
42
|
def build_request_params: (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
33
43
|
|
|
44
|
+
# --
|
|
45
|
+
# : (true | Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
46
|
+
def web_search_tool: (true | Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
47
|
+
|
|
48
|
+
# gemini-2.x models on the Developer API silently ignore responseFormat and
|
|
49
|
+
# return prose; structured output needs gemini-3 or later.
|
|
50
|
+
# --
|
|
51
|
+
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
52
|
+
def structured_output_config: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
53
|
+
|
|
34
54
|
# --
|
|
35
55
|
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
36
56
|
def execute_generate: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
@@ -43,6 +63,37 @@ class Riffer::Providers::Gemini < Riffer::Providers::Base
|
|
|
43
63
|
# : (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
44
64
|
def extract_tool_calls: (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ToolCall]
|
|
45
65
|
|
|
66
|
+
# --
|
|
67
|
+
# : (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
68
|
+
def extract_reasoning: (Hash[Symbol, untyped]) -> Array[Riffer::Messages::Assistant::ReasoningPart]
|
|
69
|
+
|
|
70
|
+
# Gemini 3 needs each thoughtSignature back on the part it came on, and
|
|
71
|
+
# rejects a function call in the current turn that lost it. The reasoning
|
|
72
|
+
# part's id names the tool call it belongs to; nil means the text.
|
|
73
|
+
# --
|
|
74
|
+
# : (Hash[Symbol, untyped]) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
75
|
+
def build_signature_part: (Hash[Symbol, untyped]) -> Riffer::Messages::Assistant::ReasoningPart?
|
|
76
|
+
|
|
77
|
+
# Distinct from GoogleCloud's: the Developer API and Agent Platform each
|
|
78
|
+
# reject the other's signatures.
|
|
79
|
+
# --
|
|
80
|
+
# : () -> String
|
|
81
|
+
def reasoning_format: () -> String
|
|
82
|
+
|
|
83
|
+
# Gemini's own call ids are too short to stay unique across a session, so
|
|
84
|
+
# riffer makes its own and appends Gemini's, which gemini_call_id reads back
|
|
85
|
+
# on replay. A signed call's id comes from its signature, so
|
|
86
|
+
# extract_tool_calls and extract_reasoning agree on it.
|
|
87
|
+
# --
|
|
88
|
+
# : (Hash[Symbol, untyped]) -> String
|
|
89
|
+
def tool_call_id: (Hash[Symbol, untyped]) -> String
|
|
90
|
+
|
|
91
|
+
# Gemini matches each functionResponse to its functionCall by this id, which
|
|
92
|
+
# parallel calls to the same function need.
|
|
93
|
+
# --
|
|
94
|
+
# : (String) -> String?
|
|
95
|
+
def gemini_call_id: (String) -> String?
|
|
96
|
+
|
|
46
97
|
# --
|
|
47
98
|
# : (Hash[Symbol, untyped]) -> Riffer::Providers::TokenUsage?
|
|
48
99
|
def extract_token_usage: (Hash[Symbol, untyped]) -> Riffer::Providers::TokenUsage?
|
|
@@ -63,10 +114,25 @@ class Riffer::Providers::Gemini < Riffer::Providers::Base
|
|
|
63
114
|
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
64
115
|
def execute_stream: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
65
116
|
|
|
117
|
+
# --
|
|
118
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
119
|
+
def yield_web_search_queries: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
120
|
+
|
|
121
|
+
# Gemini reports every query and source of the turn together, without saying
|
|
122
|
+
# which query found which source, so they become one WebSearchDone.
|
|
123
|
+
# --
|
|
124
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
125
|
+
def yield_web_search_done: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
126
|
+
|
|
66
127
|
# --
|
|
67
128
|
# : (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
68
129
|
def partition_messages: (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
69
130
|
|
|
131
|
+
# Gemini needs every result for one call turn in a single content, one part each.
|
|
132
|
+
# --
|
|
133
|
+
# : (Array[Hash[Symbol, untyped]], Riffer::Messages::Tool) -> void
|
|
134
|
+
def append_tool_result: (Array[Hash[Symbol, untyped]], Riffer::Messages::Tool) -> void
|
|
135
|
+
|
|
70
136
|
# --
|
|
71
137
|
# : (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
72
138
|
def convert_assistant_to_gemini_format: (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
@@ -90,8 +156,4 @@ class Riffer::Providers::Gemini < Riffer::Providers::Base
|
|
|
90
156
|
# --
|
|
91
157
|
# : (String) -> void
|
|
92
158
|
def validate_model!: (String) -> void
|
|
93
|
-
|
|
94
|
-
# --
|
|
95
|
-
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
96
|
-
def strip_additional_properties: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
97
159
|
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/google_cloud/client.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# <tt>Riffer.config.google_cloud.client</tt> accepts any object implementing +post+ and +post_stream+
|
|
4
|
+
# (see Riffer::HTTP::Client); this class is the default, not a required base. Paths are relative to
|
|
5
|
+
# the client's <tt>v1/projects/{project_id}/locations/{location}</tt> resource.
|
|
6
|
+
class Riffer::Providers::GoogleCloud::Client < Riffer::HTTP::Client
|
|
7
|
+
self.@application_default_credentials: untyped
|
|
8
|
+
|
|
9
|
+
@base_url: String
|
|
10
|
+
|
|
11
|
+
@credentials: untyped
|
|
12
|
+
|
|
13
|
+
@location: String
|
|
14
|
+
|
|
15
|
+
@project_id: String
|
|
16
|
+
|
|
17
|
+
SCOPE: String
|
|
18
|
+
|
|
19
|
+
# Both are interpolated into the endpoint's host or path.
|
|
20
|
+
VALID_PROJECT_ID_PATTERN: Regexp
|
|
21
|
+
|
|
22
|
+
VALID_LOCATION_PATTERN: Regexp
|
|
23
|
+
|
|
24
|
+
# googleauth's metadata-server lookups (GCE, Cloud Run, GKE) go through a
|
|
25
|
+
# process-wide google-cloud-env cache that detects reentrancy by Thread, so
|
|
26
|
+
# two fibers inside it at once raise ThreadError. Every googleauth call that
|
|
27
|
+
# can reach it holds this lock; Ruby's Mutex is fiber-aware, so waiters yield
|
|
28
|
+
# to the scheduler instead of blocking the thread.
|
|
29
|
+
AUTH_LOCK: Thread::Mutex
|
|
30
|
+
|
|
31
|
+
# Memoized process-wide so every client shares one token cache.
|
|
32
|
+
# --
|
|
33
|
+
# : () -> untyped
|
|
34
|
+
def self.application_default_credentials: () -> untyped
|
|
35
|
+
|
|
36
|
+
# --
|
|
37
|
+
# : (location: String) -> String
|
|
38
|
+
def self.base_url_for: (location: String) -> String
|
|
39
|
+
|
|
40
|
+
# --
|
|
41
|
+
# : (Riffer::Config::GoogleCloud) -> Riffer::Providers::GoogleCloud::Client
|
|
42
|
+
def self.from_config: (Riffer::Config::GoogleCloud) -> Riffer::Providers::GoogleCloud::Client
|
|
43
|
+
|
|
44
|
+
# +credentials+ is a googleauth credentials object (anything responding to
|
|
45
|
+
# +updater_proc+); +nil+ resolves Application Default Credentials.
|
|
46
|
+
# --
|
|
47
|
+
# : (project_id: String, location: String, ?credentials: untyped, ?base_url: String?, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
|
|
48
|
+
def initialize: (project_id: String, location: String, ?credentials: untyped, ?base_url: String?, ?headers: Hash[String, String], ?connection: Faraday::Connection?) -> void
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# --
|
|
53
|
+
# : (String, Regexp, String) -> void
|
|
54
|
+
def validate!: (String, Regexp, String) -> void
|
|
55
|
+
|
|
56
|
+
# --
|
|
57
|
+
# : (String) -> String
|
|
58
|
+
def url_for: (String) -> String
|
|
59
|
+
|
|
60
|
+
# googleauth refreshes only a missing or near-expiry token, so fibers queued
|
|
61
|
+
# behind a refresh reuse its result. +updater_proc+ rather than +apply!+,
|
|
62
|
+
# whose return value is the header String for some credential types and the
|
|
63
|
+
# headers Hash for others (self-signed JWTs).
|
|
64
|
+
# --
|
|
65
|
+
# : () -> Hash[String, String]
|
|
66
|
+
def headers: () -> Hash[String, String]
|
|
67
|
+
|
|
68
|
+
# --
|
|
69
|
+
# : () -> String
|
|
70
|
+
def error_label: () -> String
|
|
71
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/google_cloud.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# Gemini models on Gemini Enterprise Agent Platform (formerly Vertex AI). The
|
|
4
|
+
# request and response bodies match the Gemini Developer API's, so this only
|
|
5
|
+
# swaps the transport, the resource paths and the structured output field.
|
|
6
|
+
class Riffer::Providers::GoogleCloud < Riffer::Providers::Gemini
|
|
7
|
+
# Agent Platform model ids may carry an +@version+ suffix.
|
|
8
|
+
VALID_MODEL_PATTERN: Regexp
|
|
9
|
+
|
|
10
|
+
REASONING_FORMAT: String
|
|
11
|
+
|
|
12
|
+
# Agent Platform label keys and values: at most 63 characters of lowercase
|
|
13
|
+
# letters, digits, underscores and dashes; keys start with a letter.
|
|
14
|
+
LABEL_MAX_LENGTH: Integer
|
|
15
|
+
|
|
16
|
+
LABEL_INVALID_CHARACTERS: Regexp
|
|
17
|
+
|
|
18
|
+
# --
|
|
19
|
+
# : () -> String
|
|
20
|
+
def self.semconv_provider_name: () -> String
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
# --
|
|
25
|
+
# : () -> untyped
|
|
26
|
+
def global_client: () -> untyped
|
|
27
|
+
|
|
28
|
+
# --
|
|
29
|
+
# : () -> untyped
|
|
30
|
+
def build_client: () -> untyped
|
|
31
|
+
|
|
32
|
+
# Tags go out as request labels, merged over any +labels+ model option.
|
|
33
|
+
# --
|
|
34
|
+
# : (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
35
|
+
def build_request_params: (Array[Riffer::Messages::Base], String?, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
36
|
+
|
|
37
|
+
# Rewrites tags into valid labels (downcased, invalid characters replaced by
|
|
38
|
+
# an underscore, cut to 63 characters) and drops keys that don't start with
|
|
39
|
+
# a letter, so a tag like agent: "support/triage_agent" can't fail the call.
|
|
40
|
+
# --
|
|
41
|
+
# : (Hash[untyped, untyped]) -> Hash[String, String]
|
|
42
|
+
def tag_labels: (Hash[untyped, untyped]) -> Hash[String, String]
|
|
43
|
+
|
|
44
|
+
# --
|
|
45
|
+
# : (untyped) -> String
|
|
46
|
+
def to_label: (untyped) -> String
|
|
47
|
+
|
|
48
|
+
# --
|
|
49
|
+
# : () -> String
|
|
50
|
+
def reasoning_format: () -> String
|
|
51
|
+
|
|
52
|
+
# Agent Platform declares responseFormat as a repeated field.
|
|
53
|
+
# --
|
|
54
|
+
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
55
|
+
def structured_output_config: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
56
|
+
|
|
57
|
+
# --
|
|
58
|
+
# : (String, String) -> String
|
|
59
|
+
def api_path: (String, String) -> String
|
|
60
|
+
|
|
61
|
+
# --
|
|
62
|
+
# : (String) -> void
|
|
63
|
+
def validate_model!: (String) -> void
|
|
64
|
+
end
|