discourse-ai/lib/shared/prompting/prompt_builder.rb
Sam Saffron a8f54e2709
DEV: adding a concept of prompt builder
This is half baked and not working, but starts demonstrating the idea
2023-08-25 15:54:16 +10:00

39 lines
827 B
Ruby

# frozen_string_literal: true
module DiscourseAi
module Prompting
class PromptBuilder
def initialize(tokenizer:, max_tokens:)
@tokenizer = tokenizer
@max_tokens = max_tokens
@contents = []
end
def full?
end
def <<(content:, type:, user: nil)
validate_type(type)
@contents << { content: content, type: type, user: user }
end
def unshift(content:, type:, user: nil)
validate_type(type)
@contents.unshift(content: content, type: type, user: user)
end
def generate
raise NotImplemented
end
def validate_type(type)
if !%i[system assistant user].include?(type)
raise ArgumentError, "type must be one of :system, :assistant, :user"
end
end
end
end
end