Session
Object Hierarchy:
Description:
public class Session :
SessionBase
Session is a wrapper around Call.Chat that provides history persistence.
It uses SQ (SQLite) for database storage of metadata, and JSON files for complete session data including all messages. Properties are
wrappers Messages come from session.messages. Model and other properties are on Session (Chat is created per request by AgentHandler) with
a flag to include extra info during JSON encoding.
Example
// Create session from chat call
var call = new Call.Chat(client, "llama3.2");
var session = new History.Session(call, db);
// Save session to disk and database
yield session.save();
// Load session later
var loaded = History.Session.load(id, db, client, config);
Session requires a Call.Chat object in its constructor.
Content:
Properties:
Static methods:
Creation methods:
Methods:
- public override void activate ()
- public override void activate_agent (string agent_name) throws Error
Activates an agent for this session.
- public override void cancel_current_request ()
Cancels the current request if one is active.
- public override bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Node property_node)
Handle JSON property mapping and custom deserialization. No-op for
Session - sessions are never deserialized (only SessionJson is used).
- public override void handle_stream_chunk (string new_text, bool is_thinking, Chat response)
Called by AgentHandler when a streaming chunk is received. Handles
persistence and relays to Manager signals.
- public override async SessionBase? load () throws Error
Loads the session data if needed. No-op for Session (already loaded).
- protected override void on_message_created (Message m)
Handler for message_created signal from this session's client. Handles
message persistence when a message is created. FIXME = needs making logical after we remove get_chat FIXME = on message created should
not be getting a chat? - need to work out why that would happen
- public override async void read () throws Error
Read session from JSON file. No-op for Session - sessions are loaded
once via SessionPlaceholder.load() and never again.
- public override void saveToDB ()
Save session to SQLite database.
- public override async void save_async (bool update_timestamp = true)
Save session to both DB and file asynchronously. Updates metadata and
saves to both database and JSON file.
- public override async void send (Message message, Cancellable? cancellable = null) throws Error
Sends a Message object to this session.
- public override Node serialize_property (string property_name, Value value, ParamSpec pspec)
Handle JSON property mapping for serialization.
- public override string task_dir ()
- public override async void write () throws Error
Write session to JSON file. Uses this.fid and to_path() to determine
where to write. Serializes the session including messages with history info (timestamp, hidden).
Inherited Members:
All known members inherited from class OLLMchat.History.SessionBase
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref
All known members inherited from interface Json.Serializable
- default_deserialize_property
- default_serialize_property
- deserialize_property
- find_property
- get_property
- list_properties
- serialize_property
- set_property