diff --git a/CHANGELOG.md b/CHANGELOG.md index f5c3f6f..a8012a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,3 +23,7 @@ ## [0.2.6] - 2025-03-07 - Fixed span for local adapter. + +## [0.2.7] - 2025-04-01 + +- Added support for prompt versioning in the local adapter. diff --git a/Gemfile.lock b/Gemfile.lock index b62d5d8..849e3da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - llm_eval_ruby (0.2.6) + llm_eval_ruby (0.2.7) httparty (~> 0.22.0) liquid (~> 5.5.0) diff --git a/lib/llm_eval_ruby/prompt_adapters/local.rb b/lib/llm_eval_ruby/prompt_adapters/local.rb index 731c89b..32e5817 100644 --- a/lib/llm_eval_ruby/prompt_adapters/local.rb +++ b/lib/llm_eval_ruby/prompt_adapters/local.rb @@ -7,14 +7,26 @@ module LlmEvalRuby module PromptAdapters class Local < Base class << self - def fetch_prompt(name:, version: nil) # rubocop:disable Lint/UnusedMethodArgument - prompt_path = Rails.root.join(LlmEvalRuby.config.local_options[:prompts_path], name.to_s) + # Versioning was introduced to allow flexibility in managing different iterations of prompts. + # This enables testing and gradual rollouts of updated prompt versions without affecting existing ones. + # + # lib/prompts/test + # ├── system.txt + # ├── user.txt + # └── v2 + # ├── system.txt + # └── user.txt + # └── v3 + # ├── system.txt + # └── user.txt + def fetch_prompt(name:, version: nil) + prompt_path = Rails.root.join(LlmEvalRuby.config.local_options[:prompts_path], name.to_s, version.to_s) - system_prompts = Dir.glob("#{prompt_path}/**/system.txt").map do |path| + system_prompts = Dir.glob("#{prompt_path}/system.txt").map do |path| { "role" => "system", "content" => File.read(path) } end - user_prompt = Dir.glob("#{prompt_path}/**/user*.txt").map do |path| + user_prompt = Dir.glob("#{prompt_path}/user*.txt").map do |path| { "role" => "user", "content" => File.read(path) } end diff --git a/lib/llm_eval_ruby/version.rb b/lib/llm_eval_ruby/version.rb index 869eb7c..150d32b 100644 --- a/lib/llm_eval_ruby/version.rb +++ b/lib/llm_eval_ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module LlmEvalRuby - VERSION = "0.2.6" + VERSION = "0.2.7" end diff --git a/spec/llm_eval_ruby_spec.rb b/spec/llm_eval_ruby_spec.rb index c086bab..093096f 100644 --- a/spec/llm_eval_ruby_spec.rb +++ b/spec/llm_eval_ruby_spec.rb @@ -2,6 +2,6 @@ RSpec.describe LlmEvalRuby do it "has a version number" do - expect(LlmEvalRuby::VERSION).to be("0.2.6") + expect(LlmEvalRuby::VERSION).to be("0.2.7") end end