Class: RbsGoose::Templates::Base
- Inherits:
-
Object
- Object
- RbsGoose::Templates::Base
show all
- Defined in:
- lib/rbs_goose/templates/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(instruction:, example_groups:) ⇒ Base
Returns a new instance of Base.
8
9
10
11
|
# File 'lib/rbs_goose/templates/base.rb', line 8
def initialize(instruction:, example_groups:)
@instruction = instruction
@example_groups = example_groups
end
|
Instance Method Details
13
14
15
16
17
18
19
20
21
|
# File 'lib/rbs_goose/templates/base.rb', line 13
def format(**args)
Langchain::Prompt::FewShotPromptTemplate.new(
prefix:,
suffix:,
example_prompt:,
examples: example_groups.map { transform_example_group(_1) },
input_variables:
).format(**format_args(args)).strip
end
|
23
24
25
|
# File 'lib/rbs_goose/templates/base.rb', line 23
def format_system_prompt
prefix.strip
end
|
27
28
29
30
31
32
33
34
35
|
# File 'lib/rbs_goose/templates/base.rb', line 27
def format_user_prompt(**args)
Langchain::Prompt::FewShotPromptTemplate.new(
prefix: '',
suffix:,
example_prompt:,
examples: example_groups.map { transform_example_group(_1) },
input_variables:
).format(**format_args(args)).strip
end
|
#parse_result(result) ⇒ Object
37
38
39
|
# File 'lib/rbs_goose/templates/base.rb', line 37
def parse_result(result)
result.scan(/```.+?```/m).map { IO::File.from_markdown(_1) }
end
|