Skip to content

Commit c6a47d1

Browse files
committed
[WIP] Refactor Providers
1 parent c5cd401 commit c6a47d1

File tree

2 files changed

+3
-37
lines changed

2 files changed

+3
-37
lines changed

lib/active_agent/generation_provider/open_ai_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def format_image_content(message)
8686

8787
# Override from ParameterBuilder to add web_search_options for Chat API
8888
def build_provider_parameters
89-
params = {}
89+
params = super
9090

9191
# Check if we're using a model that supports web_search_options in Chat API
9292
if chat_api_web_search_model? && @prompt.options[:web_search]

lib/active_agent/generation_provider/open_router_provider.rb

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ def generate(prompt)
2929

3030
def namespace = OpenRouter
3131

32+
# OpenAI + OpenRouter
3233
def build_provider_parameters
33-
# Start with base OpenAI parameters
34-
params = super
35-
36-
# Add OpenRouter-specific parameters
37-
add_openrouter_params(params)
34+
super.merge(options.chat_parameters)
3835
end
3936

4037
def format_content_item(item)
@@ -82,37 +79,6 @@ def build_provider_preferences
8279
end
8380
end
8481

85-
def add_openrouter_params(params)
86-
# Add OpenRouter-specific routing parameters
87-
if @fallback_models.present?
88-
params[:models] = @fallback_models
89-
params[:route] = @route
90-
end
91-
92-
# Add transforms
93-
params[:transforms] = @transforms if @transforms.present?
94-
95-
# Add provider configuration (always include if we have data_collection or other settings)
96-
# Check both configured and runtime data_collection/require_parameters values
97-
runtime_data_collection = prompt&.options&.key?(:data_collection)
98-
runtime_require_parameters = prompt&.options&.key?(:require_parameters)
99-
runtime_provider_options = prompt&.options&.keys&.any? { |k| [ :only, :ignore, :quantizations, :sort, :max_price ].include?(k) }
100-
101-
if options.provider.present? || @data_collection != "allow" || @require_parameters != false ||
102-
@only_providers.present? || @ignore_providers.present? || @quantizations.present? ||
103-
@sort_preference.present? || @max_price.present? ||
104-
runtime_data_collection || runtime_require_parameters || runtime_provider_options
105-
params[:provider] = build_provider_preferences
106-
end
107-
108-
# Add plugins (e.g., for PDF processing)
109-
if prompt.options[:plugins].present?
110-
params[:plugins] = prompt.options[:plugins]
111-
end
112-
113-
params
114-
end
115-
11682
def execute_with_fallback(parameters)
11783
parameters[:stream] = provider_stream if prompt.options[:stream] || config["stream"]
11884

0 commit comments

Comments
 (0)