From e5c16d69d89377dafc78b0bf11ceb9a710ce3ea8 Mon Sep 17 00:00:00 2001 From: Dmytro Lukash Date: Tue, 1 Apr 2025 11:55:39 +0300 Subject: [PATCH 1/5] Add Versioning --- lib/llm_eval_ruby/prompt_adapters/local.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/llm_eval_ruby/prompt_adapters/local.rb b/lib/llm_eval_ruby/prompt_adapters/local.rb index 731c89b..c00ea82 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 + # 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) # rubocop:disable Lint/UnusedMethodArgument - prompt_path = Rails.root.join(LlmEvalRuby.config.local_options[:prompts_path], name.to_s) + 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 From 4d2d02ddfb549ee6bfb2919c2dd7b0ac8fb7bf2c Mon Sep 17 00:00:00 2001 From: Dmytro Lukash Date: Tue, 1 Apr 2025 12:47:30 +0300 Subject: [PATCH 2/5] Update version of gem --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- lib/llm_eval_ruby/version.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5c3f6f..b77e775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,3 +23,7 @@ ## [0.2.6] - 2025-03-07 - Fixed span for local adapter. + +## [0.2.6] - 2025-03-07 + +- 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/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 From 67349a4ce9a0c47816844a6df4b868d1c97c211b Mon Sep 17 00:00:00 2001 From: Dmytro Lukash Date: Tue, 1 Apr 2025 12:49:05 +0300 Subject: [PATCH 3/5] Fix omit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b77e775..a8012a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,6 @@ - Fixed span for local adapter. -## [0.2.6] - 2025-03-07 +## [0.2.7] - 2025-04-01 - Added support for prompt versioning in the local adapter. From 825171862079d3ced72330a3031624cd924e621e Mon Sep 17 00:00:00 2001 From: Dmytro Lukash Date: Tue, 1 Apr 2025 13:02:35 +0300 Subject: [PATCH 4/5] Update gem spec version --- spec/llm_eval_ruby_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 378a8ecfa4c5dae1033c955ebde8e446bc3155bd Mon Sep 17 00:00:00 2001 From: Dmytro Lukash Date: Tue, 1 Apr 2025 13:05:01 +0300 Subject: [PATCH 5/5] Fix lints --- lib/llm_eval_ruby/prompt_adapters/local.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/llm_eval_ruby/prompt_adapters/local.rb b/lib/llm_eval_ruby/prompt_adapters/local.rb index c00ea82..32e5817 100644 --- a/lib/llm_eval_ruby/prompt_adapters/local.rb +++ b/lib/llm_eval_ruby/prompt_adapters/local.rb @@ -19,7 +19,7 @@ class << self # └── v3 # ├── system.txt # └── user.txt - def fetch_prompt(name:, version: nil) # rubocop:disable Lint/UnusedMethodArgument + 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|