Class: Sublayer::Agents::GenerateMetaforGivenTextAgent

Inherits:
Object
  • Object
show all
Includes:
Capabilities::HumanAssistance, Capabilities::LLMAssistance
Defined in:
lib/sublayer/agents/generate_metafor_given_text_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:) ⇒ GenerateMetaforGivenTextAgent

Returns a new instance of GenerateMetaforGivenTextAgent.



15
16
17
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 15

def initialize(text:)
  @text = text
end

Instance Attribute Details

#metaphorsObject (readonly)

Returns the value of attribute metaphors.



9
10
11
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 9

def metaphors
  @metaphors
end

#resultsObject (readonly)

Returns the value of attribute results.



9
10
11
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 9

def results
  @results
end

#textObject (readonly)

Returns the value of attribute text.



9
10
11
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 9

def text
  @text
end

Instance Method Details

#executeObject



19
20
21
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 19

def execute
  @metaphors = llm_generate
end

#promptObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sublayer/agents/generate_metafor_given_text_agent.rb', line 23

def prompt
  <<-PROMPT
  You are an expert in language, literature, communications, and storytelling.

  You are tasked with identifying metaphors that can explain text in a more relateable and digestible way.

  Here is the text snippet:

  ###TEXT###
  #{text}
  ###END TEXT###

  After reviewing the text, please suggest a metaphor to explain the text.
  Consider the meanings, and use commonly understood subjects to draw metaphors from.
  Metaphors should be relevant and enrich the comprehension of the text.
  Take a deep breath and let your creativity flow.
  Keep your response succinct and enjoyable to read even for a teenager.
  PROMPT
end