Class: Cline::SessionMessages

Inherits:
Schema
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/cline/session_messages.rb

Overview

Session messages

Instance Attribute Summary

Attributes inherited from Schema

#extra_attributes

Public API collapse

Internal collapse

Methods inherited from Schema

#==, as_hash, cast, cline_snake_attributes, #to_cline_json, #to_hash

Class Method Details

.of_hash(hash, *args, cline_models:, **kwargs) ⇒ Schema

Parse a Hash object and instantiate the proper instance from it.

Parameters:

  • hash (Hash)

    Data

  • args (Array)

    Remaining arguments to be transferred to Shale

  • cline_models (Models)

    The Cline models used to interpret the tasks' messages

  • kwargs (Hash)

    Remaining kwargs to be transferred to Shale

Returns:

  • (Schema)

    Corresponding instance



46
47
48
49
50
51
52
# File 'lib/cline/session_messages.rb', line 46

def self.of_hash(hash, *args, cline_models:, **kwargs)
  instance = super(hash, *args, **kwargs)
  # Shale doesn't pass extra kwargs to nested collection items,
  # so we set cline_models on each message after deserialization
  instance.messages&.each { |message| message.cline_models = cline_models }
  instance
end

Instance Method Details

#agentString

Returns Agent identifier (lead or agent).

Returns:

  • (String)

    Agent identifier (lead or agent)



19
# File 'lib/cline/session_messages.rb', line 19

attribute :agent, :string

#messagesArray<SessionMessage>

Returns Messages of this session.

Returns:



25
# File 'lib/cline/session_messages.rb', line 25

attribute :messages, Utils::Schema.collection(SessionMessage)

#session_idString

Returns Session ID.

Returns:

  • (String)

    Session ID



22
# File 'lib/cline/session_messages.rb', line 22

attribute :session_id, :string

#system_promptString

Returns System prompt used for this session.

Returns:

  • (String)

    System prompt used for this session



28
# File 'lib/cline/session_messages.rb', line 28

attribute :system_prompt, :string

#updated_atString

Returns Last update timestamp of this messages file.

Returns:

  • (String)

    Last update timestamp of this messages file



16
# File 'lib/cline/session_messages.rb', line 16

attribute :updated_at, :string

#versionInteger

Returns Schema version.

Returns:

  • (Integer)

    Schema version



13
# File 'lib/cline/session_messages.rb', line 13

attribute :version, :integer

#wrapped_messagesArray

Return the messages as an array, even if there are no message.

Returns:

  • (Array)

    The messages



57
58
59
# File 'lib/cline/session_messages.rb', line 57

def wrapped_messages
  messages || []
end