Skip to content

Commit

Permalink
Adds AssistantMessage class.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljuti committed Feb 18, 2024
1 parent ae9b867 commit b18452f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/roseflow/chat/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "dry-struct"
require "roseflow/types"
require "roseflow/prompt"

module Roseflow
module Chat
Expand Down Expand Up @@ -51,5 +52,17 @@ def self.from(input)
)
end
end

class AssistantMessage < Message
attribute :role, Types::String.constrained(included_in: %w(assistant))

def self.from(input)
input = input.is_a?(Roseflow::Prompt) ? input.call : input
new(
role: "assistant",
content: input
)
end
end
end
end

0 comments on commit b18452f

Please sign in to comment.