riffer 0.56.0 → 0.57.1
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/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +26 -0
- data/README.md +1 -1
- data/docs/AGENTS.md +105 -50
- data/docs/AGENT_LIFECYCLE.md +1 -1
- data/docs/CONFIGURATION.md +7 -3
- data/docs/EVALS.md +2 -0
- data/docs/MCP.md +36 -0
- data/docs/MESSAGES.md +13 -0
- data/docs/OVERVIEW.md +7 -7
- data/docs/SERIALIZATION.md +12 -2
- data/docs/SKILLS.md +1 -1
- data/docs/STABILITY.md +1 -1
- data/docs/TOOLS.md +93 -37
- data/docs/TOOL_ADVANCED.md +7 -0
- data/docs/providers/AMAZON_BEDROCK.md +6 -2
- data/docs/providers/ANTHROPIC.md +35 -2
- data/docs/providers/AZURE_OPENAI.md +9 -3
- data/docs/providers/CUSTOM_PROVIDERS.md +19 -0
- data/docs/providers/GEMINI.md +8 -4
- data/docs/providers/GOOGLE_CLOUD.md +10 -5
- data/docs/providers/MOCK_PROVIDER.md +2 -0
- data/docs/providers/OPENAI.md +25 -3
- data/docs/providers/OPENROUTER.md +11 -3
- data/docs/providers/PROVIDERS.md +1 -1
- data/docs-site/index.html.erb +1 -1
- data/lib/riffer/agent/config.rb +21 -0
- data/lib/riffer/agent/context.rb +36 -18
- data/lib/riffer/agent/run.rb +54 -8
- data/lib/riffer/agent/serializer.rb +5 -0
- data/lib/riffer/agent/session.rb +1 -0
- data/lib/riffer/agent.rb +43 -0
- data/lib/riffer/config/mcp.rb +17 -0
- data/lib/riffer/config/pricing.rb +2 -2
- data/lib/riffer/config.rb +12 -1
- data/lib/riffer/evals/evaluator.rb +8 -1
- data/lib/riffer/evals/evaluator_runner.rb +1 -0
- data/lib/riffer/evals/judge.rb +2 -2
- data/lib/riffer/evals.rb +2 -0
- data/lib/riffer/mcp/search_tool.rb +1 -1
- data/lib/riffer/mcp.rb +7 -0
- data/lib/riffer/messages/tool.rb +6 -2
- data/lib/riffer/params/any_of.rb +5 -8
- data/lib/riffer/params/boolean.rb +1 -1
- data/lib/riffer/params/param.rb +96 -67
- data/lib/riffer/params.rb +50 -71
- data/lib/riffer/providers/anthropic_compatible/messages_api/stream.rb +3 -10
- data/lib/riffer/providers/anthropic_compatible/messages_api.rb +89 -13
- data/lib/riffer/providers/anthropic_vertex.rb +7 -0
- data/lib/riffer/providers/base.rb +43 -7
- data/lib/riffer/providers/deferred_tool_gateway/sink.rb +54 -0
- data/lib/riffer/providers/deferred_tool_gateway/tool.rb +17 -0
- data/lib/riffer/providers/deferred_tool_gateway.rb +150 -0
- data/lib/riffer/providers/gemini.rb +5 -5
- data/lib/riffer/providers/mock.rb +6 -0
- data/lib/riffer/providers/open_ai.rb +38 -10
- data/lib/riffer/skills/activate_tool.rb +1 -1
- data/lib/riffer/tool.rb +92 -2
- data/lib/riffer/tools/response.rb +11 -2
- data/lib/riffer/version.rb +1 -1
- data/sig/generated/riffer/agent/config.rbs +13 -1
- data/sig/generated/riffer/agent/context.rbs +16 -0
- data/sig/generated/riffer/agent/run.rbs +14 -2
- data/sig/generated/riffer/agent.rbs +13 -0
- data/sig/generated/riffer/config/mcp.rbs +7 -0
- data/sig/generated/riffer/config.rbs +5 -1
- data/sig/generated/riffer/evals/evaluator.rbs +4 -0
- data/sig/generated/riffer/evals.rbs +1 -0
- data/sig/generated/riffer/mcp.rbs +1 -0
- data/sig/generated/riffer/messages/tool.rbs +4 -2
- data/sig/generated/riffer/params/any_of.rbs +4 -4
- data/sig/generated/riffer/params/boolean.rbs +1 -1
- data/sig/generated/riffer/params/param.rbs +28 -14
- data/sig/generated/riffer/params.rbs +20 -20
- data/sig/generated/riffer/providers/anthropic_compatible/messages_api/stream.rbs +2 -5
- data/sig/generated/riffer/providers/anthropic_compatible/messages_api.rbs +34 -2
- data/sig/generated/riffer/providers/anthropic_vertex.rbs +5 -0
- data/sig/generated/riffer/providers/base.rbs +13 -0
- data/sig/generated/riffer/providers/deferred_tool_gateway/sink.rbs +23 -0
- data/sig/generated/riffer/providers/deferred_tool_gateway/tool.rbs +4 -0
- data/sig/generated/riffer/providers/deferred_tool_gateway.rbs +58 -0
- data/sig/generated/riffer/providers/mock.rbs +4 -0
- data/sig/generated/riffer/providers/open_ai.rbs +16 -4
- data/sig/generated/riffer/tool.rbs +48 -2
- data/sig/generated/riffer/tools/response.rbs +9 -2
- data/sig/manual/riffer/providers/deferred_tool_gateway.rbs +5 -0
- metadata +8 -3
- data/lib/riffer/tools/toolable.rb +0 -113
- data/sig/generated/riffer/tools/toolable.rbs +0 -66
|
@@ -34,7 +34,8 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI::Stream
|
|
|
34
34
|
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
35
35
|
def handle: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
36
36
|
|
|
37
|
-
# The caller reads finish reason and usage from here
|
|
37
|
+
# The caller reads the text, finish reason and usage from here, since one turn
|
|
38
|
+
# can take several streams.
|
|
38
39
|
# --
|
|
39
40
|
# : () -> Hash[Symbol, untyped]
|
|
40
41
|
def finish!: () -> Hash[Symbol, untyped]
|
|
@@ -61,10 +62,6 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI::Stream
|
|
|
61
62
|
# : (Hash[Symbol, untyped]) -> void
|
|
62
63
|
def apply_message_delta: (Hash[Symbol, untyped]) -> void
|
|
63
64
|
|
|
64
|
-
# --
|
|
65
|
-
# : (Riffer::Providers::_EventSink) -> void
|
|
66
|
-
def stop_message: (Riffer::Providers::_EventSink) -> void
|
|
67
|
-
|
|
68
65
|
# --
|
|
69
66
|
# : (Hash[Symbol, untyped]) -> void
|
|
70
67
|
def raise_stream_error: (Hash[Symbol, untyped]) -> void
|
|
@@ -5,6 +5,8 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI < Riffer::Providers::B
|
|
|
5
5
|
|
|
6
6
|
FINISH_REASONS: Hash[String, Symbol]
|
|
7
7
|
|
|
8
|
+
PAUSE_TURN_CONTINUATIONS: Integer
|
|
9
|
+
|
|
8
10
|
# Only parts carrying this tag are replayed, so reasoning captured by another
|
|
9
11
|
# adapter, whose signatures the Messages API may not accept, never reaches the
|
|
10
12
|
# request. Server tool parts and text parts that keep their block carry it too.
|
|
@@ -14,6 +16,10 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI < Riffer::Providers::B
|
|
|
14
16
|
# : (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
15
17
|
def self.skills_adapter: (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
16
18
|
|
|
19
|
+
# --
|
|
20
|
+
# : () -> bool
|
|
21
|
+
def self.supports_deferred_tools?: () -> bool
|
|
22
|
+
|
|
17
23
|
private
|
|
18
24
|
|
|
19
25
|
# --
|
|
@@ -33,10 +39,28 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI < Riffer::Providers::B
|
|
|
33
39
|
# : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
34
40
|
def execute_generate: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
35
41
|
|
|
42
|
+
# The done events cover the whole turn, so they wait until every paused
|
|
43
|
+
# response has been continued.
|
|
36
44
|
# --
|
|
37
45
|
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
38
46
|
def execute_stream: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> void
|
|
39
47
|
|
|
48
|
+
# --
|
|
49
|
+
# : (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> Hash[Symbol, untyped]
|
|
50
|
+
def stream_message: (Hash[Symbol, untyped], Riffer::Providers::_EventSink) -> Hash[Symbol, untyped]
|
|
51
|
+
|
|
52
|
+
# To resume a paused turn, resend the same request with the paused response's
|
|
53
|
+
# content array appended as an assistant message, copied as-is and with nothing after it.
|
|
54
|
+
# --
|
|
55
|
+
# : (Hash[Symbol, untyped]) { (Hash[Symbol, untyped]) -> Hash[Symbol, untyped] } -> Hash[Symbol, untyped]
|
|
56
|
+
def continue_paused_turn: (Hash[Symbol, untyped]) { (Hash[Symbol, untyped]) -> Hash[Symbol, untyped] } -> Hash[Symbol, untyped]
|
|
57
|
+
|
|
58
|
+
# Each request is billed for its own input and output, so the counts add up.
|
|
59
|
+
# A nil count in the later response would replace the running total, so it's dropped.
|
|
60
|
+
# --
|
|
61
|
+
# : (Hash[Symbol, untyped]?, Hash[Symbol, untyped]?) -> Hash[Symbol, untyped]?
|
|
62
|
+
def merge_usage: (Hash[Symbol, untyped]?, Hash[Symbol, untyped]?) -> Hash[Symbol, untyped]?
|
|
63
|
+
|
|
40
64
|
# Claude signs each thinking block over every block before it in the turn, so
|
|
41
65
|
# the blocks go back in the order they came.
|
|
42
66
|
# --
|
|
@@ -78,8 +102,16 @@ class Riffer::Providers::AnthropicCompatible::MessagesAPI < Riffer::Providers::B
|
|
|
78
102
|
def structured_output_config: (Riffer::Agent::StructuredOutput) -> Hash[Symbol, untyped]
|
|
79
103
|
|
|
80
104
|
# --
|
|
81
|
-
# : (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
82
|
-
def partition_messages: (Array[Riffer::Messages::Base]) -> Hash[Symbol, untyped]
|
|
105
|
+
# : (Array[Riffer::Messages::Base], Array[singleton(Riffer::Tool)]) -> Hash[Symbol, untyped]
|
|
106
|
+
def partition_messages: (Array[Riffer::Messages::Base], Array[singleton(Riffer::Tool)]) -> Hash[Symbol, untyped]
|
|
107
|
+
|
|
108
|
+
# A load goes as tool_reference blocks alone, since the API rejects them mixed
|
|
109
|
+
# with text. Only this request's deferred tools are referenced: the API rejects
|
|
110
|
+
# a reference to a tool missing from +tools+, and a restored history may name
|
|
111
|
+
# tools the agent no longer defers.
|
|
112
|
+
# --
|
|
113
|
+
# : (Riffer::Messages::Tool, Array[String]) -> (String | Array[Hash[Symbol, untyped]])
|
|
114
|
+
def tool_result_content: (Riffer::Messages::Tool, Array[String]) -> (String | Array[Hash[Symbol, untyped]])
|
|
83
115
|
|
|
84
116
|
# --
|
|
85
117
|
# : (Riffer::Messages::Assistant) -> Hash[Symbol, untyped]
|
|
@@ -14,6 +14,11 @@ class Riffer::Providers::AnthropicVertex < Riffer::Providers::AnthropicCompatibl
|
|
|
14
14
|
# : () -> String
|
|
15
15
|
def self.semconv_provider_name: () -> String
|
|
16
16
|
|
|
17
|
+
# Agent Platform rejects URL sources, so riffer downloads the file and sends it inline.
|
|
18
|
+
# --
|
|
19
|
+
# : (Riffer::Messages::User::FilePart) -> Symbol
|
|
20
|
+
def file_delivery: (Riffer::Messages::User::FilePart) -> Symbol
|
|
21
|
+
|
|
17
22
|
private
|
|
18
23
|
|
|
19
24
|
# --
|
|
@@ -15,6 +15,10 @@ class Riffer::Providers::Base
|
|
|
15
15
|
# : (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
16
16
|
def self.skills_adapter: (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
17
17
|
|
|
18
|
+
# --
|
|
19
|
+
# : () -> bool
|
|
20
|
+
def self.supports_deferred_tools?: () -> bool
|
|
21
|
+
|
|
18
22
|
# --
|
|
19
23
|
# : () -> String
|
|
20
24
|
def self.semconv_provider_name: () -> String
|
|
@@ -48,6 +52,15 @@ class Riffer::Providers::Base
|
|
|
48
52
|
# : () -> untyped
|
|
49
53
|
def build_client: () -> untyped
|
|
50
54
|
|
|
55
|
+
# The model calls a loaded deferred tool, and the gateway, by its wire name too.
|
|
56
|
+
# --
|
|
57
|
+
# : (Hash[Symbol, untyped]) -> Array[singleton(Riffer::Tool)]
|
|
58
|
+
def decodable_tools: (Hash[Symbol, untyped]) -> Array[singleton(Riffer::Tool)]
|
|
59
|
+
|
|
60
|
+
# --
|
|
61
|
+
# : (Hash[Symbol, untyped]) -> Array[singleton(Riffer::Tool)]
|
|
62
|
+
def gateway_deferred_tools: (Hash[Symbol, untyped]) -> Array[singleton(Riffer::Tool)]
|
|
63
|
+
|
|
51
64
|
# --
|
|
52
65
|
# : (String) -> String
|
|
53
66
|
def encode_tool_name: (String) -> String
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/deferred_tool_gateway/sink.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
class Riffer::Providers::DeferredToolGateway::Sink
|
|
4
|
+
@sink: Riffer::Providers::_EventSink
|
|
5
|
+
|
|
6
|
+
@deferred_tools: Array[singleton(Riffer::Tool)]
|
|
7
|
+
|
|
8
|
+
@gateway_item_ids: Array[String]
|
|
9
|
+
|
|
10
|
+
# --
|
|
11
|
+
# : (Riffer::Providers::_EventSink, deferred_tools: Array[singleton(Riffer::Tool)]) -> void
|
|
12
|
+
def initialize: (Riffer::Providers::_EventSink, deferred_tools: Array[singleton(Riffer::Tool)]) -> void
|
|
13
|
+
|
|
14
|
+
# --
|
|
15
|
+
# : (Riffer::StreamEvents::Base) -> self
|
|
16
|
+
def <<: (Riffer::StreamEvents::Base) -> self
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# --
|
|
21
|
+
# : (Riffer::StreamEvents::ToolCallDone) -> Riffer::StreamEvents::ToolCallDone
|
|
22
|
+
def unwrap: (Riffer::StreamEvents::ToolCallDone) -> Riffer::StreamEvents::ToolCallDone
|
|
23
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Generated from lib/riffer/providers/deferred_tool_gateway.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Riffer::Providers::DeferredToolGateway
|
|
4
|
+
# +deferred_tools+ are the ones the gateway carries for the request. With none there is no gateway, and every
|
|
5
|
+
# function here returns its input.
|
|
6
|
+
# --
|
|
7
|
+
# : (Array[Riffer::Messages::Base], Array[singleton(Riffer::Tool)]) -> Array[Riffer::Messages::Base]
|
|
8
|
+
def wrap_messages: (Array[Riffer::Messages::Base], Array[singleton(Riffer::Tool)]) -> Array[Riffer::Messages::Base]
|
|
9
|
+
|
|
10
|
+
# --
|
|
11
|
+
# : (Array[Riffer::Messages::Assistant::TextPart | Riffer::Messages::Assistant::ReasoningPart | Riffer::Messages::Assistant::ToolCall | Riffer::Messages::Assistant::ServerToolPart], Array[singleton(Riffer::Tool)]) -> Array[Riffer::Messages::Assistant::TextPart | Riffer::Messages::Assistant::ReasoningPart | Riffer::Messages::Assistant::ToolCall | Riffer::Messages::Assistant::ServerToolPart]
|
|
12
|
+
def unwrap_parts: (Array[Riffer::Messages::Assistant::TextPart | Riffer::Messages::Assistant::ReasoningPart | Riffer::Messages::Assistant::ToolCall | Riffer::Messages::Assistant::ServerToolPart], Array[singleton(Riffer::Tool)]) -> Array[Riffer::Messages::Assistant::TextPart | Riffer::Messages::Assistant::ReasoningPart | Riffer::Messages::Assistant::ToolCall | Riffer::Messages::Assistant::ServerToolPart]
|
|
13
|
+
|
|
14
|
+
# A gateway call without a string name and string arguments, or naming a tool that isn't deferred, stays a call to
|
|
15
|
+
# the gateway, which is never one of the agent's tools, so the model gets an +:unknown_tool+ error result. Only a
|
|
16
|
+
# deferred tool's call is wrapped again on the way out, so unwrapping any other name would replay its arguments
|
|
17
|
+
# to the provider as they came, unparseable JSON included.
|
|
18
|
+
# --
|
|
19
|
+
# : (Riffer::Messages::Assistant::ToolCall, Array[singleton(Riffer::Tool)]) -> Riffer::Messages::Assistant::ToolCall
|
|
20
|
+
def unwrap_tool_call: (Riffer::Messages::Assistant::ToolCall, Array[singleton(Riffer::Tool)]) -> Riffer::Messages::Assistant::ToolCall
|
|
21
|
+
|
|
22
|
+
# --
|
|
23
|
+
# : (Riffer::Providers::_EventSink, Array[singleton(Riffer::Tool)]) -> Riffer::Providers::_EventSink
|
|
24
|
+
def unwrapping_sink: (Riffer::Providers::_EventSink, Array[singleton(Riffer::Tool)]) -> Riffer::Providers::_EventSink
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# --
|
|
29
|
+
# : (String) -> [String, String]?
|
|
30
|
+
def parse_gateway_arguments: (String) -> [ String, String ]?
|
|
31
|
+
|
|
32
|
+
# --
|
|
33
|
+
# : (Riffer::Messages::Assistant, Array[String]) -> Riffer::Messages::Assistant
|
|
34
|
+
def wrap_assistant: (Riffer::Messages::Assistant, Array[String]) -> Riffer::Messages::Assistant
|
|
35
|
+
|
|
36
|
+
# --
|
|
37
|
+
# : (Riffer::Messages::Assistant::ToolCall, Array[String]) -> Riffer::Messages::Assistant::ToolCall
|
|
38
|
+
def wrap_tool_call: (Riffer::Messages::Assistant::ToolCall, Array[String]) -> Riffer::Messages::Assistant::ToolCall
|
|
39
|
+
|
|
40
|
+
# A result for a deferred tool is renamed along with its call, since Gemini sends the name with a function
|
|
41
|
+
# response and rejects one that names no declared function.
|
|
42
|
+
# --
|
|
43
|
+
# : (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Riffer::Messages::Tool
|
|
44
|
+
def wrap_tool_result: (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Riffer::Messages::Tool
|
|
45
|
+
|
|
46
|
+
# --
|
|
47
|
+
# : (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
|
|
48
|
+
def loaded_deferred_tools: (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
|
|
49
|
+
|
|
50
|
+
# Deterministic, so an earlier tool result reads the same on every request and the prompt cache holds.
|
|
51
|
+
# --
|
|
52
|
+
# : (Array[singleton(Riffer::Tool)]) -> String
|
|
53
|
+
def describe_loaded_tools: (Array[singleton(Riffer::Tool)]) -> String
|
|
54
|
+
|
|
55
|
+
# --
|
|
56
|
+
# : () -> String
|
|
57
|
+
def loaded_tools_header: () -> String
|
|
58
|
+
end
|
|
@@ -11,6 +11,10 @@ class Riffer::Providers::Mock < Riffer::Providers::Base
|
|
|
11
11
|
# : (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
12
12
|
def self.skills_adapter: (?String?) -> singleton(Riffer::Skills::Adapter)
|
|
13
13
|
|
|
14
|
+
# --
|
|
15
|
+
# : () -> bool
|
|
16
|
+
def self.supports_deferred_tools?: () -> bool
|
|
17
|
+
|
|
14
18
|
# --
|
|
15
19
|
# : () -> String
|
|
16
20
|
def self.semconv_provider_name: () -> String
|
|
@@ -10,6 +10,10 @@ class Riffer::Providers::OpenAI < Riffer::Providers::Base
|
|
|
10
10
|
# together with <tt>incomplete_details.reason</tt>.
|
|
11
11
|
FINISH_REASONS: Hash[String, Symbol | Hash[String, Symbol]]
|
|
12
12
|
|
|
13
|
+
# --
|
|
14
|
+
# : () -> bool
|
|
15
|
+
def self.supports_deferred_tools?: () -> bool
|
|
16
|
+
|
|
13
17
|
# --
|
|
14
18
|
# : () -> String
|
|
15
19
|
def self.semconv_provider_name: () -> String
|
|
@@ -135,12 +139,20 @@ class Riffer::Providers::OpenAI < Riffer::Providers::Base
|
|
|
135
139
|
def handle_output_item_done_reasoning: (untyped, yielder: Riffer::Providers::_EventSink) -> void
|
|
136
140
|
|
|
137
141
|
# --
|
|
138
|
-
# : (Array[Riffer::Messages::Base]) -> Array[Hash[Symbol, untyped]]
|
|
139
|
-
def convert_messages_to_openai_format: (Array[Riffer::Messages::Base]) -> Array[Hash[Symbol, untyped]]
|
|
142
|
+
# : (Array[Riffer::Messages::Base], deferred_tools: Array[singleton(Riffer::Tool)]) -> Array[Hash[Symbol, untyped]]
|
|
143
|
+
def convert_messages_to_openai_format: (Array[Riffer::Messages::Base], deferred_tools: Array[singleton(Riffer::Tool)]) -> Array[Hash[Symbol, untyped]]
|
|
144
|
+
|
|
145
|
+
# --
|
|
146
|
+
# : (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
|
|
147
|
+
def loaded_deferred_tools: (Riffer::Messages::Tool, Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
|
|
148
|
+
|
|
149
|
+
# --
|
|
150
|
+
# : (Array[singleton(Riffer::Tool)]) -> Hash[Symbol, untyped]
|
|
151
|
+
def convert_additional_tools_to_openai_format: (Array[singleton(Riffer::Tool)]) -> Hash[Symbol, untyped]
|
|
140
152
|
|
|
141
153
|
# --
|
|
142
|
-
# : (Riffer::Messages::Assistant) -> Array[Hash[Symbol, untyped]]
|
|
143
|
-
def convert_assistant_to_openai_format: (Riffer::Messages::Assistant) -> Array[Hash[Symbol, untyped]]
|
|
154
|
+
# : (Riffer::Messages::Assistant, deferred_tools: Array[singleton(Riffer::Tool)]) -> Array[Hash[Symbol, untyped]]
|
|
155
|
+
def convert_assistant_to_openai_format: (Riffer::Messages::Assistant, deferred_tools: Array[singleton(Riffer::Tool)]) -> Array[Hash[Symbol, untyped]]
|
|
144
156
|
|
|
145
157
|
# --
|
|
146
158
|
# : (Array[Riffer::Messages::Assistant::ReasoningPart]) -> Array[Hash[Symbol, untyped]]
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
# Generated from lib/riffer/tool.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
class Riffer::Tool
|
|
4
|
-
extend Riffer::Tools::Toolable
|
|
5
|
-
|
|
6
4
|
extend Riffer::Registrable
|
|
7
5
|
|
|
6
|
+
self.@description: String?
|
|
7
|
+
|
|
8
|
+
self.@identifier: String?
|
|
9
|
+
|
|
10
|
+
self.@timeout: (Integer | Float)?
|
|
11
|
+
|
|
12
|
+
self.@params_builder: Riffer::Params?
|
|
13
|
+
|
|
14
|
+
DEFAULT_TIMEOUT: Integer
|
|
15
|
+
|
|
16
|
+
# --
|
|
17
|
+
# : (?String?) -> String?
|
|
18
|
+
def self.description: (?String?) -> String?
|
|
19
|
+
|
|
20
|
+
# --
|
|
21
|
+
# : (?String?) -> String
|
|
22
|
+
def self.identifier: (?String?) -> String
|
|
23
|
+
|
|
24
|
+
# --
|
|
25
|
+
# : (?String?) -> String
|
|
26
|
+
def self.name: (?String?) -> String
|
|
27
|
+
|
|
28
|
+
# --
|
|
29
|
+
# : (?(Integer | Float)?) -> (Integer | Float)
|
|
30
|
+
def self.timeout: (?(Integer | Float)?) -> (Integer | Float)
|
|
31
|
+
|
|
32
|
+
# --
|
|
33
|
+
# : () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
34
|
+
def self.params: () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
35
|
+
|
|
36
|
+
# --
|
|
37
|
+
# : (?strict: bool) -> Hash[Symbol, untyped]
|
|
38
|
+
def self.parameters_schema: (?strict: bool) -> Hash[Symbol, untyped]
|
|
39
|
+
|
|
40
|
+
# --
|
|
41
|
+
# : (?strict: bool) -> Hash[Symbol, untyped]
|
|
42
|
+
def self.to_tool_schema: (?strict: bool) -> Hash[Symbol, untyped]
|
|
43
|
+
|
|
44
|
+
# --
|
|
45
|
+
# : () -> true
|
|
46
|
+
def self.validate_as_tool!: () -> true
|
|
47
|
+
|
|
48
|
+
private def self.empty_schema: () -> untyped
|
|
49
|
+
|
|
8
50
|
# --
|
|
9
51
|
# : (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
10
52
|
def call: (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
@@ -17,6 +59,10 @@ class Riffer::Tool
|
|
|
17
59
|
# : (untyped) -> Riffer::Tools::Response
|
|
18
60
|
def json: (untyped) -> Riffer::Tools::Response
|
|
19
61
|
|
|
62
|
+
# --
|
|
63
|
+
# : (Array[singleton(Riffer::Tool)]) -> Riffer::Tools::Response
|
|
64
|
+
def load_tools: (Array[singleton(Riffer::Tool)]) -> Riffer::Tools::Response
|
|
65
|
+
|
|
20
66
|
# --
|
|
21
67
|
# : (String, ?type: Symbol) -> Riffer::Tools::Response
|
|
22
68
|
def error: (String, ?type: Symbol) -> Riffer::Tools::Response
|
|
@@ -12,6 +12,8 @@ class Riffer::Tools::Response
|
|
|
12
12
|
|
|
13
13
|
attr_reader error_type: Symbol?
|
|
14
14
|
|
|
15
|
+
attr_reader loaded_tools: Array[singleton(Riffer::Tool)]
|
|
16
|
+
|
|
15
17
|
# Kept out of every serialized form so it never reaches an LLM or a message
|
|
16
18
|
# payload.
|
|
17
19
|
attr_reader exception: Exception?
|
|
@@ -28,6 +30,11 @@ class Riffer::Tools::Response
|
|
|
28
30
|
# : (untyped) -> Riffer::Tools::Response
|
|
29
31
|
def self.json: (untyped) -> Riffer::Tools::Response
|
|
30
32
|
|
|
33
|
+
# No text alongside: Anthropic rejects a tool result that mixes +tool_reference+ blocks with text.
|
|
34
|
+
# --
|
|
35
|
+
# : (Array[singleton(Riffer::Tool)]) -> Riffer::Tools::Response
|
|
36
|
+
def self.load_tools: (Array[singleton(Riffer::Tool)]) -> Riffer::Tools::Response
|
|
37
|
+
|
|
31
38
|
# --
|
|
32
39
|
# : (String, ?type: Symbol, ?exception: Exception?) -> Riffer::Tools::Response
|
|
33
40
|
def self.error: (String, ?type: Symbol, ?exception: Exception?) -> Riffer::Tools::Response
|
|
@@ -47,6 +54,6 @@ class Riffer::Tools::Response
|
|
|
47
54
|
private
|
|
48
55
|
|
|
49
56
|
# --
|
|
50
|
-
# : (content: String, success: bool, ?error_message: String?, ?error_type: Symbol?, ?exception: Exception?) -> void
|
|
51
|
-
def initialize: (content: String, success: bool, ?error_message: String?, ?error_type: Symbol?, ?exception: Exception?) -> void
|
|
57
|
+
# : (content: String, success: bool, ?error_message: String?, ?error_type: Symbol?, ?exception: Exception?, ?loaded_tools: Array[singleton(Riffer::Tool)]) -> void
|
|
58
|
+
def initialize: (content: String, success: bool, ?error_message: String?, ?error_type: Symbol?, ?exception: Exception?, ?loaded_tools: Array[singleton(Riffer::Tool)]) -> void
|
|
52
59
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: riffer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.57.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jake Bottrall
|
|
@@ -230,6 +230,9 @@ files:
|
|
|
230
230
|
- lib/riffer/providers/anthropic_vertex.rb
|
|
231
231
|
- lib/riffer/providers/azure_open_ai.rb
|
|
232
232
|
- lib/riffer/providers/base.rb
|
|
233
|
+
- lib/riffer/providers/deferred_tool_gateway.rb
|
|
234
|
+
- lib/riffer/providers/deferred_tool_gateway/sink.rb
|
|
235
|
+
- lib/riffer/providers/deferred_tool_gateway/tool.rb
|
|
233
236
|
- lib/riffer/providers/finish_reason.rb
|
|
234
237
|
- lib/riffer/providers/gemini.rb
|
|
235
238
|
- lib/riffer/providers/gemini/client.rb
|
|
@@ -282,7 +285,6 @@ files:
|
|
|
282
285
|
- lib/riffer/tools/runtime/fibers.rb
|
|
283
286
|
- lib/riffer/tools/runtime/inline.rb
|
|
284
287
|
- lib/riffer/tools/runtime/threaded.rb
|
|
285
|
-
- lib/riffer/tools/toolable.rb
|
|
286
288
|
- lib/riffer/tracing.rb
|
|
287
289
|
- lib/riffer/tracing/capture.rb
|
|
288
290
|
- lib/riffer/tracing/no_op.rb
|
|
@@ -399,6 +401,9 @@ files:
|
|
|
399
401
|
- sig/generated/riffer/providers/anthropic_vertex.rbs
|
|
400
402
|
- sig/generated/riffer/providers/azure_open_ai.rbs
|
|
401
403
|
- sig/generated/riffer/providers/base.rbs
|
|
404
|
+
- sig/generated/riffer/providers/deferred_tool_gateway.rbs
|
|
405
|
+
- sig/generated/riffer/providers/deferred_tool_gateway/sink.rbs
|
|
406
|
+
- sig/generated/riffer/providers/deferred_tool_gateway/tool.rbs
|
|
402
407
|
- sig/generated/riffer/providers/finish_reason.rbs
|
|
403
408
|
- sig/generated/riffer/providers/gemini.rbs
|
|
404
409
|
- sig/generated/riffer/providers/gemini/client.rbs
|
|
@@ -450,7 +455,6 @@ files:
|
|
|
450
455
|
- sig/generated/riffer/tools/runtime/fibers.rbs
|
|
451
456
|
- sig/generated/riffer/tools/runtime/inline.rbs
|
|
452
457
|
- sig/generated/riffer/tools/runtime/threaded.rbs
|
|
453
|
-
- sig/generated/riffer/tools/toolable.rbs
|
|
454
458
|
- sig/generated/riffer/tracing.rbs
|
|
455
459
|
- sig/generated/riffer/tracing/capture.rbs
|
|
456
460
|
- sig/generated/riffer/tracing/no_op.rbs
|
|
@@ -481,6 +485,7 @@ files:
|
|
|
481
485
|
- sig/manual/riffer/params/format.rbs
|
|
482
486
|
- sig/manual/riffer/providers.rbs
|
|
483
487
|
- sig/manual/riffer/providers/anthropic_compatible/messages_api.rbs
|
|
488
|
+
- sig/manual/riffer/providers/deferred_tool_gateway.rbs
|
|
484
489
|
- sig/manual/riffer/providers/gemini.rbs
|
|
485
490
|
- sig/manual/riffer/providers/google_cloud.rbs
|
|
486
491
|
- sig/manual/riffer/providers/repository.rbs
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# rbs_inline: enabled
|
|
3
|
-
|
|
4
|
-
# @rbs module-self Module
|
|
5
|
-
module Riffer::Tools::Toolable
|
|
6
|
-
# @rbs self.@extenders: Array[Module]?
|
|
7
|
-
# @rbs @description: String?
|
|
8
|
-
# @rbs @identifier: String?
|
|
9
|
-
# @rbs @timeout: (Integer | Float)?
|
|
10
|
-
# @rbs @params_builder: Riffer::Params?
|
|
11
|
-
# @rbs @kind: Symbol?
|
|
12
|
-
|
|
13
|
-
DEFAULT_TIMEOUT = 10 #: Integer
|
|
14
|
-
|
|
15
|
-
#--
|
|
16
|
-
#: (Module) -> void
|
|
17
|
-
def self.extended(base)
|
|
18
|
-
extenders = (@extenders ||= []) #: Array[Module]
|
|
19
|
-
extenders << base
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
#--
|
|
23
|
-
#: () -> Array[Module]
|
|
24
|
-
def self.all
|
|
25
|
-
@extenders || []
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
#--
|
|
29
|
-
#: (?String?) -> String?
|
|
30
|
-
def description(value = nil)
|
|
31
|
-
return @description if value.nil?
|
|
32
|
-
|
|
33
|
-
@description = value.to_s
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
#--
|
|
37
|
-
#: (?String?) -> String
|
|
38
|
-
def identifier(value = nil)
|
|
39
|
-
return @identifier || Riffer::Helpers::Identifier.for(self) if value.nil?
|
|
40
|
-
|
|
41
|
-
@identifier = value.to_s
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
#--
|
|
45
|
-
#: (?String?) -> String
|
|
46
|
-
def name(value = nil)
|
|
47
|
-
return identifier(value) if value
|
|
48
|
-
|
|
49
|
-
identifier
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
#--
|
|
53
|
-
#: (?(Integer | Float)?) -> (Integer | Float)
|
|
54
|
-
def timeout(value = nil)
|
|
55
|
-
return @timeout || DEFAULT_TIMEOUT if value.nil?
|
|
56
|
-
|
|
57
|
-
@timeout = value.to_f
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
#--
|
|
61
|
-
#: () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
62
|
-
def params(&block)
|
|
63
|
-
return @params_builder if block.nil?
|
|
64
|
-
|
|
65
|
-
builder = Riffer::Params.new
|
|
66
|
-
builder.instance_eval(&block)
|
|
67
|
-
@params_builder = builder
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
#--
|
|
71
|
-
#: (?strict: bool) -> Hash[Symbol, untyped]
|
|
72
|
-
def parameters_schema(strict: false)
|
|
73
|
-
@params_builder&.to_json_schema(strict: strict) || empty_schema
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
#--
|
|
77
|
-
#: (?Symbol?) -> Symbol
|
|
78
|
-
def kind(value = nil)
|
|
79
|
-
return @kind || :tool if value.nil?
|
|
80
|
-
|
|
81
|
-
@kind = value.to_sym
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
#--
|
|
85
|
-
#: (?strict: bool) -> Hash[Symbol, untyped]
|
|
86
|
-
def to_tool_schema(strict: false)
|
|
87
|
-
{
|
|
88
|
-
name: name,
|
|
89
|
-
description: description,
|
|
90
|
-
parameters_schema: parameters_schema(strict: strict),
|
|
91
|
-
}
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
#--
|
|
95
|
-
#: () -> true
|
|
96
|
-
def validate_as_tool!
|
|
97
|
-
if description.nil? || description.to_s.strip.empty?
|
|
98
|
-
raise Riffer::ArgumentError,
|
|
99
|
-
"#{self} must define a description"
|
|
100
|
-
end
|
|
101
|
-
raise Riffer::ArgumentError, "#{self} must have an identifier" if identifier.nil? || identifier.to_s.strip.empty?
|
|
102
|
-
|
|
103
|
-
true
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
def empty_schema # :nodoc:
|
|
109
|
-
properties = {} #: Hash[Symbol, untyped]
|
|
110
|
-
required = [] #: Array[untyped]
|
|
111
|
-
{ type: "object", properties: properties, required: required, additionalProperties: false }
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# Generated from lib/riffer/tools/toolable.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
# @rbs module-self Module
|
|
4
|
-
module Riffer::Tools::Toolable : Module
|
|
5
|
-
@kind: Symbol?
|
|
6
|
-
|
|
7
|
-
@params_builder: Riffer::Params?
|
|
8
|
-
|
|
9
|
-
@timeout: (Integer | Float)?
|
|
10
|
-
|
|
11
|
-
@identifier: String?
|
|
12
|
-
|
|
13
|
-
@description: String?
|
|
14
|
-
|
|
15
|
-
self.@extenders: Array[Module]?
|
|
16
|
-
|
|
17
|
-
DEFAULT_TIMEOUT: Integer
|
|
18
|
-
|
|
19
|
-
# --
|
|
20
|
-
# : (Module) -> void
|
|
21
|
-
def self.extended: (Module) -> void
|
|
22
|
-
|
|
23
|
-
# --
|
|
24
|
-
# : () -> Array[Module]
|
|
25
|
-
def self.all: () -> Array[Module]
|
|
26
|
-
|
|
27
|
-
# --
|
|
28
|
-
# : (?String?) -> String?
|
|
29
|
-
def description: (?String?) -> String?
|
|
30
|
-
|
|
31
|
-
# --
|
|
32
|
-
# : (?String?) -> String
|
|
33
|
-
def identifier: (?String?) -> String
|
|
34
|
-
|
|
35
|
-
# --
|
|
36
|
-
# : (?String?) -> String
|
|
37
|
-
def name: (?String?) -> String
|
|
38
|
-
|
|
39
|
-
# --
|
|
40
|
-
# : (?(Integer | Float)?) -> (Integer | Float)
|
|
41
|
-
def timeout: (?(Integer | Float)?) -> (Integer | Float)
|
|
42
|
-
|
|
43
|
-
# --
|
|
44
|
-
# : () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
45
|
-
def params: () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
46
|
-
|
|
47
|
-
# --
|
|
48
|
-
# : (?strict: bool) -> Hash[Symbol, untyped]
|
|
49
|
-
def parameters_schema: (?strict: bool) -> Hash[Symbol, untyped]
|
|
50
|
-
|
|
51
|
-
# --
|
|
52
|
-
# : (?Symbol?) -> Symbol
|
|
53
|
-
def kind: (?Symbol?) -> Symbol
|
|
54
|
-
|
|
55
|
-
# --
|
|
56
|
-
# : (?strict: bool) -> Hash[Symbol, untyped]
|
|
57
|
-
def to_tool_schema: (?strict: bool) -> Hash[Symbol, untyped]
|
|
58
|
-
|
|
59
|
-
# --
|
|
60
|
-
# : () -> true
|
|
61
|
-
def validate_as_tool!: () -> true
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
def empty_schema: () -> untyped
|
|
66
|
-
end
|