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, as_type: nil, **kwargs) ⇒ Event

Returns a new instance of Event.



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

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, as_type: 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
   =  || {}
  @level = level
  @status_message = status_message
  @parent_observation_id = parent_observation_id
  @version = version
  @as_type = validate_as_type(as_type)
  @kwargs = kwargs

  # Create the event
  create_event
end

Instance Attribute Details

#as_typeObject (readonly)

Returns the value of attribute as_type.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def as_type
  @as_type
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def client
  @client
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def id
  @id
end

#inputObject (readonly)

Returns the value of attribute input.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def input
  @input
end

#levelObject (readonly)

Returns the value of attribute level.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def level
  @level
end

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def 
  
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def output
  @output
end

#parent_observation_idObject (readonly)

Returns the value of attribute parent_observation_id.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def parent_observation_id
  @parent_observation_id
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def start_time
  @start_time
end

#status_messageObject (readonly)

Returns the value of attribute status_message.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def status_message
  @status_message
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def trace_id
  @trace_id
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/langfuse/event.rb', line 5

def version
  @version
end

Instance Method Details

#to_dictObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/langfuse/event.rb', line 30

def to_dict
  data = {
    id: @id,
    trace_id: @trace_id,
    name: @name,
    start_time: @start_time,
    input: @input,
    output: @output,
    metadata: ,
    level: @level,
    status_message: @status_message,
    parent_observation_id: @parent_observation_id,
    version: @version
  }
  data[:type] = @as_type if @as_type
  data.merge(@kwargs).compact
end