Skip to content

Commit 91b682b

Browse files
committed
Add specs for openrouter provider
1 parent 7814f2d commit 91b682b

18 files changed

+2123
-2
lines changed

lib/ruby_llm/providers/openrouter/streaming.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def stream_url
1313

1414
def handle_stream(&block) # rubocop:disable Metrics/MethodLength
1515
to_json_stream do |data|
16+
next if data.nil?
17+
1618
block.call(
1719
Chunk.new(
1820
role: :assistant,

lib/ruby_llm/providers/openrouter/tools.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ def parse_tool_calls(tool_calls, parse_arguments: true) # rubocop:disable Metric
5454
id: tc['id'],
5555
name: tc.dig('function', 'name'),
5656
arguments: if parse_arguments
57-
JSON.parse(tc.dig('function',
58-
'arguments'))
57+
begin
58+
JSON.parse(tc.dig('function',
59+
'arguments'))
60+
rescue JSON::ParserError
61+
{}
62+
end
5963
else
6064
tc.dig('function', 'arguments')
6165
end

spec/fixtures/vcr_cassettes/chat_basic_chat_functionality_openrouter_anthropic_claude-3_5-haiku_can_handle_multi-turn_conversations.yml

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/vcr_cassettes/chat_basic_chat_functionality_openrouter_anthropic_claude-3_5-haiku_can_have_a_basic_conversation.yml

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/vcr_cassettes/chat_basic_chat_functionality_openrouter_anthropic_claude-3_5-haiku_replaces_previous_system_messages_when_replace_true.yml

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)