Class: Botrytis::SemanticMatchGenerator

Inherits:
Sublayer::Generators::Base
  • Object
show all
Defined in:
lib/botrytis/semantic_match_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_text:, available_patterns:) ⇒ SemanticMatchGenerator

Returns a new instance of SemanticMatchGenerator.



16
17
18
19
# File 'lib/botrytis/semantic_match_generator.rb', line 16

def initialize(step_text:, available_patterns:)
  @step_text = step_text
  @available_patterns = available_patterns
end

Instance Method Details

#generateObject



21
22
23
# File 'lib/botrytis/semantic_match_generator.rb', line 21

def generate
  super
end

#promptObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/botrytis/semantic_match_generator.rb', line 25

def prompt
  "  You are a semantic matcher for Cucumber step definitions. Your task is to determine if a step text semantically matches one of the available regex patterns, even if it doesn't match exactly.\n\n  Step Text: \"\#{@step_text}\"\n\n  Available Step Definition Patterns:\n  \#{@available_patterns.join(\"\\n\")}\n\n  For each pattern, consider:\n  1. The semantic meaning/intent of the step\n  2. The structure of the pattern\n  3. Any parameters that would need to be extracted\n\n  Choose the pattern that best matches the step text semantically.\n  If no pattern is a good semantic match, indicate that no match was found.\n\n  If you find a match, extract any parameters that would be captured by the pattern. And return them as a comma separated list.\n  For example, if the pattern is \"I have (\\\\d+) cucumbers\" and the step is \"I have 5 cucumbers\",\n  the parameter value would be \"5\".\n\n  Provide your confidence in the match as a value between 0.0 (no confidence) and 1.0 (absolute certainty).\n  PROMPT\nend\n"