Class: Datadog::AIGuard::Evaluation::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ai_guard/evaluation/message.rb

Overview

Message class for AI Guard

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role:, content: nil, tool_call: nil, tool_call_id: nil) ⇒ Message

Returns a new instance of Message.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/datadog/ai_guard/evaluation/message.rb', line 10

def initialize(role:, content: nil, tool_call: nil, tool_call_id: nil)
  raise ArgumentError, "Role must be set to a non-empty value" if role.to_s.empty?

  @role = role.to_sym
  @content = content
  @tool_call = tool_call
  @tool_call_id = tool_call_id

  if @tool_call && !@tool_call.is_a?(ToolCall)
    raise ArgumentError, "Expected an instance of #{ToolCall.name} for :tool_call argument"
  end
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/datadog/ai_guard/evaluation/message.rb', line 8

def content
  @content
end

#roleObject (readonly)

Returns the value of attribute role.



8
9
10
# File 'lib/datadog/ai_guard/evaluation/message.rb', line 8

def role
  @role
end

#tool_callObject (readonly)

Returns the value of attribute tool_call.



8
9
10
# File 'lib/datadog/ai_guard/evaluation/message.rb', line 8

def tool_call
  @tool_call
end

#tool_call_idObject (readonly)

Returns the value of attribute tool_call_id.



8
9
10
# File 'lib/datadog/ai_guard/evaluation/message.rb', line 8

def tool_call_id
  @tool_call_id
end