From 218d62cc225a14a23a85c7faa431df8c995ee0e8 Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Wed, 21 May 2025 13:17:34 -0500 Subject: [PATCH] Allow initializer to set Raix client --- lib/roast/workflow/configuration_parser.rb | 3 +++ test/roast/workflow/configuration_parser_test.rb | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/roast/workflow/configuration_parser.rb b/lib/roast/workflow/configuration_parser.rb index 48ed96c3..a5465ab6 100644 --- a/lib/roast/workflow/configuration_parser.rb +++ b/lib/roast/workflow/configuration_parser.rb @@ -105,6 +105,9 @@ def load_roast_initializers def configure_api_client return unless configuration.api_token + existing_client = !!(Raix.configuration.openrouter_client || Raix.configuration.openai_client) + return if existing_client + begin case configuration.api_provider when :openrouter diff --git a/test/roast/workflow/configuration_parser_test.rb b/test/roast/workflow/configuration_parser_test.rb index 72ae7e9f..3924714c 100644 --- a/test/roast/workflow/configuration_parser_test.rb +++ b/test/roast/workflow/configuration_parser_test.rb @@ -25,6 +25,13 @@ def test_initialize_with_example_workflow assert_equal("run_coverage", @parser.configuration.steps.first) end + def test_with_existing_api_client_does_not_configure_new_api_client + openai_client = OpenAI::Client.new(access_token: "test") + Raix.configuration.openai_client = openai_client + Roast::Workflow::ConfigurationParser.new(@workflow_path) + assert_equal(openai_client, Raix.configuration.openai_client) + end + def test_begin_without_files_or_target_runs_targetless_workflow executor = mock("WorkflowExecutor") executor.stubs(:execute_steps)