Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
20 changes: 16 additions & 4 deletions lib/llm_eval_ruby/prompt_adapters/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/llm_eval_ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module LlmEvalRuby
VERSION = "0.2.6"
VERSION = "0.2.7"
end
2 changes: 1 addition & 1 deletion spec/llm_eval_ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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