Skip to content
Open
Changes from 1 commit
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
18 changes: 15 additions & 3 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
# 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

Expand Down
Loading