ruby_llm-template 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49596291defa8cac6cb6088736c1403b7e7612aa5948da276dba410ae114ed27
4
- data.tar.gz: '09b7dbfb13a4535aebd3c70df2353a9dc73597eacc160aea2643dc3272774e4b'
3
+ metadata.gz: 1c7cd2995edf14cfa1711e8e2a92a0d67a162d904865d559aaf3ec01d158e044
4
+ data.tar.gz: 3f1efee4b9cbe460ad9f029345b26d98acd0ff3f6e25b895b30c71dd9322d3a4
5
5
  SHA512:
6
- metadata.gz: ed0c3650f34970ac5ecd0ed30c48196cdcb0a81283828431ab17852cde489591e210c9cb52c68e42e89b12ce5565b6aca399a1838ac38cfe3516d1e5d0912fba
7
- data.tar.gz: 30520cba8a4e3aad1edbf971651310098f8f7c9c2f1367023337010537f6dd2a668aa94b6bfe5a53de2ba2af6e03d3e6d3628db5282d738422928e86d3c88574
6
+ metadata.gz: 01fe1048a262c4922ab3e9255d99be4a9f9d623dc9f97881f1f524c1a1f0914ae3b3dddd7751e4ebfc3aab79d661f73f17dfbaca3582df1512d9b145617e8245
7
+ data.tar.gz: 1d379ae8359f039c50a4953dbc0c29d0609ffa397e49701632fd1df05e42f484205637e7ef8a3398beda7f4a054864738c6a4a4c98601c65a379938541153903
data/README.md CHANGED
@@ -136,7 +136,7 @@ RubyLLM.chat
136
136
  ### Non-Rails Applications
137
137
 
138
138
  ```ruby
139
- RubyLlm::Template.configure do |config|
139
+ RubyLLM::Template.configure do |config|
140
140
  config.template_directory = "/path/to/your/prompts"
141
141
  end
142
142
  ```
@@ -146,7 +146,7 @@ end
146
146
  The gem automatically configures itself to use `Rails.root.join("app", "prompts")`, but you can override this in `config/initializers/ruby_llm_template.rb`:
147
147
 
148
148
  ```ruby
149
- RubyLlm::Template.configure do |config|
149
+ RubyLLM::Template.configure do |config|
150
150
  config.template_directory = Rails.root.join("app", "ai_prompts")
151
151
  end
152
152
  ```
@@ -249,7 +249,7 @@ The gem provides clear error messages for common issues:
249
249
  ```ruby
250
250
  begin
251
251
  RubyLLM.chat.with_template(:extract_metadata).complete
252
- rescue RubyLlm::Template::Error => e
252
+ rescue RubyLLM::Template::Error => e
253
253
  puts e.message
254
254
  # "Template 'extract_metadata' not found in /path/to/prompts"
255
255
  # "Schema file 'extract_metadata/schema.rb' found but RubyLLM::Schema gem is not installed"
@@ -7,7 +7,7 @@
7
7
  require_relative "../lib/ruby_llm/template"
8
8
 
9
9
  # Configure template directory
10
- RubyLlm::Template.configure do |config|
10
+ RubyLLM::Template.configure do |config|
11
11
  config.template_directory = File.join(__dir__, "prompts")
12
12
  end
13
13
 
@@ -91,7 +91,7 @@ puts "=" * 40
91
91
 
92
92
  # Mock chat object that demonstrates the extension
93
93
  class MockChat
94
- include RubyLlm::Template::ChatExtension
94
+ include RubyLLM::Template::ChatExtension
95
95
 
96
96
  def initialize
97
97
  @messages = []
@@ -135,7 +135,7 @@ begin
135
135
  document: "Q3 Financial Report: Revenue increased 15% to $2.3M. Key challenges include supply chain delays affecting Q4 projections.",
136
136
  additional_context: "Focus on financial metrics and future outlook",
137
137
  focus_areas: ["revenue", "challenges", "projections"]).complete
138
- rescue RubyLlm::Template::Error => e
138
+ rescue RubyLLM::Template::Error => e
139
139
  puts "❌ Error: #{e.message}"
140
140
  end
141
141
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "rails/generators"
4
4
 
5
- module RubyLlmTemplate
5
+ module RubyLLMTemplate
6
6
  module Generators
7
7
  class InstallGenerator < Rails::Generators::Base
8
8
  desc "Install RubyLLM Template system"
@@ -15,7 +15,7 @@ module RubyLlmTemplate
15
15
  create_file "config/initializers/ruby_llm_template.rb", <<~RUBY
16
16
  # frozen_string_literal: true
17
17
 
18
- RubyLlm::Template.configure do |config|
18
+ RubyLLM::Template.configure do |config|
19
19
  # Set the directory where your prompts are stored
20
20
  # Default: Rails.root.join("app", "prompts")
21
21
  # config.template_directory = Rails.root.join("app", "prompts")
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RubyLlm
3
+ module RubyLLM
4
4
  module Template
5
5
  module ChatExtension
6
6
  def with_template(template_name, context = {})
7
- loader = RubyLlm::Template::Loader.new(template_name)
7
+ loader = RubyLLM::Template::Loader.new(template_name)
8
8
 
9
9
  unless loader.template_exists?
10
- raise RubyLlm::Template::Error, "Template '#{template_name}' not found in #{RubyLlm::Template.configuration.template_directory}"
10
+ raise RubyLLM::Template::Error, "Template '#{template_name}' not found in #{RubyLLM::Template.configuration.template_directory}"
11
11
  end
12
12
 
13
13
  # Apply templates in a specific order to maintain conversation flow
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RubyLlm
3
+ module RubyLLM
4
4
  module Template
5
5
  class Configuration
6
6
  attr_writer :template_directory
@@ -9,14 +9,14 @@ rescue LoadError
9
9
  # RubyLLM::Schema not available, schema.rb files won't work
10
10
  end
11
11
 
12
- module RubyLlm
12
+ module RubyLLM
13
13
  module Template
14
14
  class Loader
15
15
  SUPPORTED_ROLES = %w[system user assistant schema].freeze
16
16
 
17
17
  def initialize(template_name, template_directory: nil)
18
18
  @template_name = template_name.to_s
19
- @template_directory = Pathname.new(template_directory || RubyLlm::Template.configuration.template_directory)
19
+ @template_directory = Pathname.new(template_directory || RubyLLM::Template.configuration.template_directory)
20
20
  @template_path = @template_directory.join(@template_name)
21
21
  end
22
22
 
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RubyLlm
3
+ module RubyLLM
4
4
  module Template
5
5
  class Railtie < Rails::Railtie
6
6
  initializer "ruby_llm_template.configure" do |app|
7
7
  # Set default template directory for Rails applications
8
- RubyLlm::Template.configure do |config|
8
+ RubyLLM::Template.configure do |config|
9
9
  config.template_directory ||= app.root.join("app", "prompts")
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RubyLlm
3
+ module RubyLLM
4
4
  module Template
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
@@ -13,7 +13,7 @@ rescue LoadError
13
13
  # Rails not available
14
14
  end
15
15
 
16
- module RubyLlm
16
+ module RubyLLM
17
17
  module Template
18
18
  class Error < StandardError; end
19
19
 
@@ -41,7 +41,7 @@ begin
41
41
 
42
42
  module RubyLLMChatTemplateExtension
43
43
  def self.extended(base)
44
- base.extend(RubyLlm::Template::ChatExtension)
44
+ base.extend(RubyLLM::Template::ChatExtension)
45
45
  end
46
46
  end
47
47
 
@@ -49,7 +49,7 @@ begin
49
49
  module RubyLLMTemplateHook
50
50
  def chat(*args, **kwargs)
51
51
  chat_instance = super
52
- chat_instance.extend(RubyLlm::Template::ChatExtension)
52
+ chat_instance.extend(RubyLLM::Template::ChatExtension)
53
53
  chat_instance
54
54
  end
55
55
  end
@@ -1,4 +1,4 @@
1
- module RubyLlm
1
+ module RubyLLM
2
2
  module Template
3
3
  VERSION: String
4
4
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_llm-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Friis