Class: Langfuse::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/langfuse/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, trace_id:, name:, id: nil, start_time: nil, input: nil, output: nil, metadata: nil, level: nil, status_message: nil, parent_observation_id: nil, version: nil, **kwargs) ⇒ Event

Returns a new instance of Event.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/langfuse/event.rb', line 6

def initialize(client:, trace_id:, name:, id: nil, start_time: nil, input: nil,
               output: nil, metadata: nil, level: nil, status_message: nil,
               parent_observation_id: nil, version: nil, **kwargs)
  @client = client
  @id = id || Utils.generate_id
  @trace_id = trace_id
  @name = name
  @start_time = start_time || Utils.current_timestamp
  @input = input
  @output = output
  @metadata =  || {}
  @level = level
  @status_message = status_message
  @parent_observation_id = parent_observation_id
  @version = version
  @kwargs = kwargs

  # Create the event
  create_event
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def client
  @client
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def id
  @id
end

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def input
  @input
end

#levelObject (readonly)

Returns the value of attribute level.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def level
  @level
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def output
  @output
end

#parent_observation_idObject (readonly)

Returns the value of attribute parent_observation_id.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def parent_observation_id
  @parent_observation_id
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def start_time
  @start_time
end

#status_messageObject (readonly)

Returns the value of attribute status_message.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def status_message
  @status_message
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def trace_id
  @trace_id
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/langfuse/event.rb', line 3

def version
  @version
end

Instance Method Details

#to_dictObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/langfuse/event.rb', line 27

def to_dict
  {
    id: @id,
    trace_id: @trace_id,
    name: @name,
    start_time: @start_time,
    input: @input,
    output: @output,
    metadata: @metadata,
    level: @level,
    status_message: @status_message,
    parent_observation_id: @parent_observation_id,
    version: @version
  }.merge(@kwargs).compact
end