activeagent 1.9.2 → 1.9.4
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/CHANGELOG.md +252 -0
- data/README.md +3 -0
- data/lib/active_agent/base.rb +2 -2
- data/lib/active_agent/concerns/preview.rb +2 -2
- data/lib/active_agent/evals/design_tokens.rb +12 -1
- data/lib/active_agent/evals/publisher.rb +19 -12
- data/lib/active_agent/evals/report.rb +12 -62
- data/lib/active_agent/evals/report_html.rb +85 -10
- data/lib/active_agent/evals/report_markdown.rb +202 -0
- data/lib/active_agent/evals.rb +1 -0
- data/lib/active_agent/inline_preview_interceptor.rb +1 -0
- data/lib/active_agent/preview/templates/layouts/active_agent/preview.html.erb +17 -0
- data/lib/active_agent/preview/templates/rails/agents/index.html.erb +14 -0
- data/lib/active_agent/preview/templates/rails/agents/preview.html.erb +3 -0
- data/lib/active_agent/providers/_base_provider.rb +2 -0
- data/lib/active_agent/providers/anthropic_provider.rb +1 -0
- data/lib/active_agent/providers/common/responses/base.rb +15 -2
- data/lib/active_agent/providers/common/usage.rb +4 -2
- data/lib/active_agent/providers/open_ai/chat_provider.rb +39 -0
- data/lib/active_agent/providers/open_ai/responses_provider.rb +3 -0
- data/lib/active_agent/providers/opper/_types.rb +16 -0
- data/lib/active_agent/providers/opper/options.rb +38 -0
- data/lib/active_agent/providers/opper_provider.rb +72 -0
- data/lib/active_agent/railtie.rb +11 -5
- data/lib/active_agent/version.rb +1 -1
- data/lib/generators/test_unit/agent_generator.rb +1 -1
- data/lib/generators/test_unit/templates/functional_test.rb.tt +1 -1
- data/lib/generators/test_unit/templates/preview.rb.tt +3 -3
- data/lib/rails/agents_controller.rb +43 -0
- metadata +10 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_relative "_base_provider"
|
|
2
|
+
|
|
3
|
+
require_gem!(:openai, __FILE__)
|
|
4
|
+
|
|
5
|
+
require_relative "open_ai_provider"
|
|
6
|
+
require_relative "opper/_types"
|
|
7
|
+
|
|
8
|
+
module ActiveAgent
|
|
9
|
+
module Providers
|
|
10
|
+
# Provides access to Opper's OpenAI-compatible LLM gateway.
|
|
11
|
+
#
|
|
12
|
+
# Extends the OpenAI provider to work with Opper's OpenAI-compatible API,
|
|
13
|
+
# enabling access to models from many providers through a single
|
|
14
|
+
# interface. Model ids are bare pool names (e.g. +claude-sonnet-4-6+);
|
|
15
|
+
# a +provider/model+ id (e.g. +anthropic/claude-sonnet-4-6+) pins a route.
|
|
16
|
+
#
|
|
17
|
+
# Opper is a plain OpenAI-compatible gateway: requests, responses and
|
|
18
|
+
# transforms are identical to the OpenAI Chat API, so this provider reuses
|
|
19
|
+
# OpenAI::Chat::RequestType and OpenAI::Chat::Transforms directly. The only
|
|
20
|
+
# Opper-specific configuration is the base URL and API key, which live in
|
|
21
|
+
# Opper::Options.
|
|
22
|
+
#
|
|
23
|
+
# @example Configuration in active_agent.yml
|
|
24
|
+
# opper:
|
|
25
|
+
# service: "Opper"
|
|
26
|
+
# api_key: <%= ENV["OPPER_API_KEY"] %>
|
|
27
|
+
# model: "claude-sonnet-4-6"
|
|
28
|
+
#
|
|
29
|
+
# @see OpenAI::ChatProvider
|
|
30
|
+
# @see https://docs.opper.ai
|
|
31
|
+
class OpperProvider < OpenAI::ChatProvider
|
|
32
|
+
# @return [String]
|
|
33
|
+
def self.service_name
|
|
34
|
+
"Opper"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @return [Class]
|
|
38
|
+
def self.options_klass
|
|
39
|
+
Opper::Options
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @return [ActiveModel::Type::Value]
|
|
43
|
+
def self.prompt_request_type
|
|
44
|
+
OpenAI::Chat::RequestType.new
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @return [ActiveModel::Type::Value]
|
|
48
|
+
def self.embed_request_type
|
|
49
|
+
OpenAI::Embedding::RequestType.new
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
protected
|
|
53
|
+
|
|
54
|
+
# Executes an embedding request via Opper's OpenAI-compatible API.
|
|
55
|
+
#
|
|
56
|
+
# @param parameters [Hash]
|
|
57
|
+
# @return [Hash] symbolized API response
|
|
58
|
+
def api_embed_execute(parameters)
|
|
59
|
+
client.embeddings.create(**parameters).as_json.deep_symbolize_keys
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# @see BaseProvider#api_response_normalize
|
|
63
|
+
# @param api_response [OpenAI::Models::ChatCompletion]
|
|
64
|
+
# @return [Hash] normalized response hash
|
|
65
|
+
def api_response_normalize(api_response)
|
|
66
|
+
return api_response unless api_response
|
|
67
|
+
|
|
68
|
+
OpenAI::Chat::Transforms.gem_to_hash(api_response)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/active_agent/railtie.rb
CHANGED
|
@@ -6,6 +6,8 @@ require "active_agent"
|
|
|
6
6
|
require "active_agent/railtie/schema_generator_extension"
|
|
7
7
|
require "abstract_controller/railties/routes_helpers"
|
|
8
8
|
|
|
9
|
+
Rails.autoload :AgentsController, "rails/agents_controller"
|
|
10
|
+
|
|
9
11
|
module ActiveAgent
|
|
10
12
|
class Railtie < Rails::Railtie # :nodoc:
|
|
11
13
|
config.active_agent = ActiveSupport::OrderedOptions.new
|
|
@@ -101,8 +103,12 @@ module ActiveAgent
|
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
initializer "active_agent.set_autoload_paths", before: :set_autoload_paths do |app|
|
|
104
|
-
|
|
105
|
-
#
|
|
106
|
+
options = app.config.active_agent
|
|
107
|
+
options.preview_paths |= [ "#{app.root}/test/agents/previews", "#{app.root}/test/docs/previews" ]
|
|
108
|
+
# This runs before set_configs assigns show_previews its development default.
|
|
109
|
+
if options.show_previews.nil? ? Rails.env.development? : options.show_previews
|
|
110
|
+
app.config.autoload_paths.concat(options.preview_paths)
|
|
111
|
+
end
|
|
106
112
|
end
|
|
107
113
|
|
|
108
114
|
initializer "active_agent.compile_config_methods" do
|
|
@@ -132,9 +138,9 @@ module ActiveAgent
|
|
|
132
138
|
|
|
133
139
|
if options.show_previews
|
|
134
140
|
app.routes.prepend do
|
|
135
|
-
get "/rails/agents" => "rails/agents#index", :internal => true
|
|
136
|
-
get "/rails/agents/download/*path" => "rails/agents#download", :internal => true
|
|
137
|
-
get "/rails/agents/*path" => "rails/agents#preview", :internal => true
|
|
141
|
+
get "/rails/agents" => "rails/agents#index", :internal => true, :as => :rails_agent_previews
|
|
142
|
+
get "/rails/agents/download/*path" => "rails/agents#download", :internal => true, :as => :download_rails_agent_preview, :format => false
|
|
143
|
+
get "/rails/agents/*path" => "rails/agents#preview", :internal => true, :as => :rails_agent_preview, :format => false
|
|
138
144
|
end
|
|
139
145
|
end
|
|
140
146
|
end
|
data/lib/active_agent/version.rb
CHANGED
|
@@ -17,7 +17,7 @@ module TestUnit # :nodoc:
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def create_preview_files
|
|
20
|
-
template "preview.rb", File.join("test/
|
|
20
|
+
template "preview.rb", File.join("test/agents/previews", class_path, "#{file_name}_agent_preview.rb")
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
private
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<% module_namespacing do -%>
|
|
2
|
-
# Preview all agent views/prompts templates at http://localhost:3000/
|
|
2
|
+
# Preview all agent views/prompts templates at http://localhost:3000/rails/agents/<%= file_path %>_agent
|
|
3
3
|
class <%= class_name %>AgentPreview < ActiveAgent::Preview
|
|
4
4
|
<% actions.each_with_index do |action, index| -%>
|
|
5
5
|
<% if index != 0 -%>
|
|
6
6
|
|
|
7
7
|
<% end -%>
|
|
8
|
-
# Preview this
|
|
8
|
+
# Preview this prompt at http://localhost:3000/rails/agents/<%= file_path %>_agent/<%= action %>
|
|
9
9
|
def <%= action %>
|
|
10
|
-
<%= class_name %>Agent.<%= action %>
|
|
10
|
+
<%= class_name %>Agent.with(params).<%= action %>
|
|
11
11
|
end
|
|
12
12
|
<% end -%>
|
|
13
13
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/application_controller"
|
|
4
|
+
|
|
5
|
+
class Rails::AgentsController < Rails::ApplicationController # :nodoc:
|
|
6
|
+
prepend_view_path File.expand_path("../active_agent/preview/templates", __dir__)
|
|
7
|
+
layout "active_agent/preview"
|
|
8
|
+
before_action :require_local!
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
@previews = ActiveAgent::Preview.all
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def preview
|
|
15
|
+
if found = ActiveAgent::Preview.find(params[:path])
|
|
16
|
+
@previews = [ found ]
|
|
17
|
+
render :index
|
|
18
|
+
elsif load_preview
|
|
19
|
+
render :preview
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def download
|
|
24
|
+
return unless load_preview
|
|
25
|
+
|
|
26
|
+
send_data @content, type: "text/markdown", disposition: "attachment",
|
|
27
|
+
filename: "#{@preview.preview_name.tr('/', '-')}-#{@prompt}.md"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def load_preview
|
|
33
|
+
name, _, @prompt = params[:path].to_s.rpartition("/")
|
|
34
|
+
@preview = ActiveAgent::Preview.find(name)
|
|
35
|
+
unless @preview&.prompt_exists?(@prompt)
|
|
36
|
+
head :not_found
|
|
37
|
+
return false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@content = @preview.call(@prompt, request.query_parameters).prompt_preview
|
|
41
|
+
true
|
|
42
|
+
end
|
|
43
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeagent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Bowen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -467,6 +467,7 @@ files:
|
|
|
467
467
|
- lib/active_agent/evals/replay.rb
|
|
468
468
|
- lib/active_agent/evals/report.rb
|
|
469
469
|
- lib/active_agent/evals/report_html.rb
|
|
470
|
+
- lib/active_agent/evals/report_markdown.rb
|
|
470
471
|
- lib/active_agent/evals/result.rb
|
|
471
472
|
- lib/active_agent/evals/ruby_llm.rb
|
|
472
473
|
- lib/active_agent/evals/runner.rb
|
|
@@ -481,6 +482,9 @@ files:
|
|
|
481
482
|
- lib/active_agent/input_request.rb
|
|
482
483
|
- lib/active_agent/input_request/resume.rb
|
|
483
484
|
- lib/active_agent/model_capabilities.rb
|
|
485
|
+
- lib/active_agent/preview/templates/layouts/active_agent/preview.html.erb
|
|
486
|
+
- lib/active_agent/preview/templates/rails/agents/index.html.erb
|
|
487
|
+
- lib/active_agent/preview/templates/rails/agents/preview.html.erb
|
|
484
488
|
- lib/active_agent/providers/_base_provider.rb
|
|
485
489
|
- lib/active_agent/providers/anthropic/_types.rb
|
|
486
490
|
- lib/active_agent/providers/anthropic/options.rb
|
|
@@ -585,6 +589,9 @@ files:
|
|
|
585
589
|
- lib/active_agent/providers/open_router_provider.rb
|
|
586
590
|
- lib/active_agent/providers/openai_provider.rb
|
|
587
591
|
- lib/active_agent/providers/openrouter_provider.rb
|
|
592
|
+
- lib/active_agent/providers/opper/_types.rb
|
|
593
|
+
- lib/active_agent/providers/opper/options.rb
|
|
594
|
+
- lib/active_agent/providers/opper_provider.rb
|
|
588
595
|
- lib/active_agent/providers/requesty/_types.rb
|
|
589
596
|
- lib/active_agent/providers/requesty/options.rb
|
|
590
597
|
- lib/active_agent/providers/requesty_provider.rb
|
|
@@ -637,6 +644,7 @@ files:
|
|
|
637
644
|
- lib/generators/test_unit/install_generator.rb
|
|
638
645
|
- lib/generators/test_unit/templates/functional_test.rb.tt
|
|
639
646
|
- lib/generators/test_unit/templates/preview.rb.tt
|
|
647
|
+
- lib/rails/agents_controller.rb
|
|
640
648
|
- lib/tasks/activeagent_tasks.rake
|
|
641
649
|
homepage: https://activeagents.ai
|
|
642
650
|
licenses:
|