gpt-storyteller/src/builders/string.cr
2023-04-11 10:42:17 +02:00

42 lines
812 B
Crystal

require "colorize"
require "./generic"
class StringBuilder < PromptGenericBuilder
getter use_color : Bool
def initialize(@use_color)
Colorize.enabled = @use_color
end
def build(prompt : Prompt)
str = ""
prompt.prelude_zone.each do |content|
str += content
end
prompt.system_zone.each do |content|
str += "@@system".colorize(:yellow).to_s
str += content
end
prompt.past_zone.each do |content|
str += "@@before".colorize(:yellow).to_s
str += content
end
prompt.present_zone.each do |content|
str += "@@current".colorize(:yellow).to_s
str += content.colorize(:light_cyan).to_s
end
prompt.future_zone.each do |content|
str += "@@after".colorize(:yellow).to_s
str += content
end
str
end
end