phronomy 0.4.0 → 0.5.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.
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators"
4
- require "rails/generators/active_record"
5
-
6
- module Phronomy
7
- module Generators
8
- # Rails generator that installs Phronomy into a Rails app.
9
- # Creates an initializer and database migrations:
10
- # - phronomy_messages (conversation history persistence)
11
- #
12
- # Usage:
13
- # rails generate phronomy:install
14
- class InstallGenerator < ::Rails::Generators::Base
15
- include ::Rails::Generators::Migration
16
-
17
- source_root File.expand_path("templates", __dir__)
18
-
19
- desc "Creates a Phronomy initializer and database migrations."
20
-
21
- def self.next_migration_number(dirname)
22
- ::ActiveRecord::Generators::Base.next_migration_number(dirname)
23
- end
24
-
25
- def copy_initializer
26
- template "initializer.rb.tt", "config/initializers/phronomy.rb"
27
- end
28
-
29
- def create_messages_migration
30
- migration_template(
31
- "create_phronomy_messages.rb.tt",
32
- "db/migrate/create_phronomy_messages.rb"
33
- )
34
- end
35
-
36
- def create_message_model
37
- template "message_model.rb.tt", "app/models/phronomy_message.rb"
38
- end
39
- end
40
- end
41
- end
@@ -1,15 +0,0 @@
1
- class CreatePhronomyMessages < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
- def change
3
- create_table :phronomy_messages do |t|
4
- t.string :thread_id, null: false
5
- t.string :role, null: false
6
- t.text :content
7
- t.text :tool_calls_json
8
- t.string :model_id
9
- t.timestamps
10
- end
11
-
12
- add_index :phronomy_messages, :thread_id
13
- add_index :phronomy_messages, [:thread_id, :created_at]
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Phronomy configuration initializer.
4
- # Customize LLM settings and agent defaults here.
5
- Phronomy.configure do |config|
6
- # Default LLM model used when no model is specified on an agent or chain.
7
- # config.default_model = "gpt-4o-mini"
8
-
9
- # Maximum graph recursion depth (node steps per invoke).
10
- # config.recursion_limit = 25
11
- end
12
-
13
- # RubyLLM provider credentials.
14
- # Prefer Rails credentials (config/credentials.yml.enc) over ENV vars.
15
- RubyLLM.configure do |c|
16
- c.openai_api_key = Rails.application.credentials.dig(:openai, :api_key) || ENV["OPENAI_API_KEY"]
17
- c.anthropic_api_key = Rails.application.credentials.dig(:anthropic, :api_key) || ENV["ANTHROPIC_API_KEY"]
18
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Generated by `rails generate phronomy:install`.
4
- # Stores conversation messages keyed by thread_id.
5
- class PhronomyMessage < ApplicationRecord
6
- include Phronomy::ActiveRecord::ActsAs
7
- acts_as_phronomy_message
8
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Phronomy
4
- # Railtie providing Rails integration for Phronomy.
5
- # Loaded only when Rails is present.
6
- class Railtie < ::Rails::Railtie
7
- # Registers generator paths (rails generate phronomy:install).
8
- generators do
9
- require "generators/phronomy/install/install_generator"
10
- end
11
-
12
- # Fills in defaults not already set by a phronomy.rb initializer.
13
- initializer "phronomy.configure_defaults" do
14
- # Passes LLM API keys from Rails credentials to RubyLLM (only when present).
15
- # Use ::Rails to avoid resolving to Phronomy::Rails by accident.
16
- if ::Rails.application.credentials.respond_to?(:openai_api_key) &&
17
- ::Rails.application.credentials.openai_api_key
18
- RubyLLM.configure do |c|
19
- c.openai_api_key = ::Rails.application.credentials.openai_api_key
20
- end
21
- end
22
-
23
- if ::Rails.application.credentials.respond_to?(:anthropic_api_key) &&
24
- ::Rails.application.credentials.anthropic_api_key
25
- RubyLLM.configure do |c|
26
- c.anthropic_api_key = ::Rails.application.credentials.anthropic_api_key
27
- end
28
- end
29
- end
30
-
31
- # Loads Phronomy::Rails::AgentJob when both ActionCable and ActiveJob are present.
32
- initializer "phronomy.agent_job" do
33
- end
34
-
35
- # Loads Phronomy ActiveRecord extensions when ActiveRecord is available.
36
- initializer "phronomy.active_record", after: "active_record.initialize_database" do
37
- end
38
- end
39
- end