Class: Agentic::ExpectedAnswerFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/agentic/expected_answer_format.rb

Overview

Value object representing expected answer format

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format:, sections:, length:) ⇒ ExpectedAnswerFormat

Initializes a new expected answer format

Parameters:

  • format (String)

    The format of the expected answer

  • sections (Array<String>)

    The sections expected in the answer

  • length (String)

    The expected length of the answer



19
20
21
22
23
# File 'lib/agentic/expected_answer_format.rb', line 19

def initialize(format:, sections:, length:)
  @format = format
  @sections = sections
  @length = length
end

Instance Attribute Details

#formatString (readonly)

Returns The format of the expected answer.

Returns:

  • (String)

    The format of the expected answer



7
8
9
# File 'lib/agentic/expected_answer_format.rb', line 7

def format
  @format
end

#lengthString (readonly)

Returns The expected length of the answer.

Returns:

  • (String)

    The expected length of the answer



13
14
15
# File 'lib/agentic/expected_answer_format.rb', line 13

def length
  @length
end

#sectionsArray<String> (readonly)

Returns The sections expected in the answer.

Returns:

  • (Array<String>)

    The sections expected in the answer



10
11
12
# File 'lib/agentic/expected_answer_format.rb', line 10

def sections
  @sections
end

Class Method Details

.from_hash(hash) ⇒ ExpectedAnswerFormat

Creates an ExpectedAnswerFormat from a hash

Parameters:

  • hash (Hash)

    The hash representation

Returns:



38
39
40
41
42
43
44
# File 'lib/agentic/expected_answer_format.rb', line 38

def self.from_hash(hash)
  new(
    format: hash["format"],
    sections: hash["sections"],
    length: hash["length"]
  )
end

Instance Method Details

#to_hHash

Returns a serializable representation of the expected answer format

Returns:

  • (Hash)

    The expected answer format as a hash



27
28
29
30
31
32
33
# File 'lib/agentic/expected_answer_format.rb', line 27

def to_h
  {
    "format" => @format,
    "sections" => @sections,
    "length" => @length
  }
end