Class: Qualspec::PromptVariant
- Inherits:
-
Object
- Object
- Qualspec::PromptVariant
- Defined in:
- lib/qualspec/prompt_variant.rb
Overview
PromptVariant holds the configuration for a single test permutation. This class is the target for FactoryBot factory definitions, allowing traits to compose multi-dimensional prompt variations.
Constant Summary collapse
- DEFAULT_TEMPERATURE =
Default values as constants
0.7- DEFAULT_STANCE =
:neutral- DEFAULT_DIALECT =
:formal- DEFAULT_VERBOSITY =
:normal- TEMPERATURE_RANGE =
(0.0..2.0)
Instance Attribute Summary collapse
-
#base_prompt ⇒ Object
Prompt composition.
-
#context_history ⇒ Object
Context/history for multi-turn scenarios.
-
#credential ⇒ Object
Core variant dimensions.
-
#dialect ⇒ Object
Core variant dimensions.
-
#evaluation ⇒ Object
Response storage (populated during test run).
-
#full_prompt ⇒ Object
Prompt composition.
-
#name ⇒ Object
Metadata for tracking.
-
#output_schema ⇒ Object
Output format requirements.
-
#response ⇒ Object
Response storage (populated during test run).
-
#schema_instruction ⇒ Object
Output format requirements.
-
#stance ⇒ Object
Core variant dimensions.
-
#system_prompt ⇒ Object
Prompt composition.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#traits_applied ⇒ Object
Metadata for tracking.
-
#verbosity ⇒ Object
Core variant dimensions.
Instance Method Summary collapse
-
#customized? ⇒ Boolean
Check if this variant has non-default settings.
-
#initialize ⇒ PromptVariant
constructor
A new instance of PromptVariant.
-
#to_h ⇒ Object
Convert to hash for results tracking.
-
#variant_key ⇒ Object
Generate a unique key for this variant configuration.
Constructor Details
#initialize ⇒ PromptVariant
Returns a new instance of PromptVariant.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/qualspec/prompt_variant.rb', line 44 def initialize @temperature = DEFAULT_TEMPERATURE @stance = DEFAULT_STANCE @dialect = DEFAULT_DIALECT @verbosity = DEFAULT_VERBOSITY @credential = nil @context_history = [] @output_schema = :free @traits_applied = [] end |
Instance Attribute Details
#base_prompt ⇒ Object
Prompt composition
30 31 32 |
# File 'lib/qualspec/prompt_variant.rb', line 30 def base_prompt @base_prompt end |
#context_history ⇒ Object
Context/history for multi-turn scenarios
33 34 35 |
# File 'lib/qualspec/prompt_variant.rb', line 33 def context_history @context_history end |
#credential ⇒ Object
Core variant dimensions
26 27 28 |
# File 'lib/qualspec/prompt_variant.rb', line 26 def credential @credential end |
#dialect ⇒ Object
Core variant dimensions
26 27 28 |
# File 'lib/qualspec/prompt_variant.rb', line 26 def dialect @dialect end |
#evaluation ⇒ Object
Response storage (populated during test run)
42 43 44 |
# File 'lib/qualspec/prompt_variant.rb', line 42 def evaluation @evaluation end |
#full_prompt ⇒ Object
Prompt composition
30 31 32 |
# File 'lib/qualspec/prompt_variant.rb', line 30 def full_prompt @full_prompt end |
#name ⇒ Object
Metadata for tracking
39 40 41 |
# File 'lib/qualspec/prompt_variant.rb', line 39 def name @name end |
#output_schema ⇒ Object
Output format requirements
36 37 38 |
# File 'lib/qualspec/prompt_variant.rb', line 36 def output_schema @output_schema end |
#response ⇒ Object
Response storage (populated during test run)
42 43 44 |
# File 'lib/qualspec/prompt_variant.rb', line 42 def response @response end |
#schema_instruction ⇒ Object
Output format requirements
36 37 38 |
# File 'lib/qualspec/prompt_variant.rb', line 36 def schema_instruction @schema_instruction end |
#stance ⇒ Object
Core variant dimensions
26 27 28 |
# File 'lib/qualspec/prompt_variant.rb', line 26 def stance @stance end |
#system_prompt ⇒ Object
Prompt composition
30 31 32 |
# File 'lib/qualspec/prompt_variant.rb', line 30 def system_prompt @system_prompt end |
#temperature ⇒ Object
Returns the value of attribute temperature.
27 28 29 |
# File 'lib/qualspec/prompt_variant.rb', line 27 def temperature @temperature end |
#traits_applied ⇒ Object
Metadata for tracking
39 40 41 |
# File 'lib/qualspec/prompt_variant.rb', line 39 def traits_applied @traits_applied end |
#verbosity ⇒ Object
Core variant dimensions
26 27 28 |
# File 'lib/qualspec/prompt_variant.rb', line 26 def verbosity @verbosity end |
Instance Method Details
#customized? ⇒ Boolean
Check if this variant has non-default settings
64 65 66 67 68 |
# File 'lib/qualspec/prompt_variant.rb', line 64 def customized? @credential.to_s.strip != '' || @stance != DEFAULT_STANCE || (!@temperature.nil? && @temperature != DEFAULT_TEMPERATURE) end |
#to_h ⇒ Object
Convert to hash for results tracking
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/qualspec/prompt_variant.rb', line 78 def to_h { name: @name, variant_key: variant_key, traits: @traits_applied, credential: @credential, stance: @stance, dialect: @dialect, temperature: @temperature, verbosity: @verbosity, full_prompt: @full_prompt, system_prompt: @system_prompt, output_schema: @output_schema }.compact end |
#variant_key ⇒ Object
Generate a unique key for this variant configuration
71 72 73 74 75 |
# File 'lib/qualspec/prompt_variant.rb', line 71 def variant_key return 'default' if @traits_applied.empty? && @name.nil? @name || @traits_applied.sort.join('_') end |