get_active_chat_history {PacketLLM} | R Documentation |
Gets the chat history for the active conversation
Description
Retrieves the list of messages associated with the currently active conversation.
Usage
get_active_chat_history()
Value
List. A list containing the message history (each element is a list
with role
and content
) for the currently active conversation.
Returns an empty list (list()
) if no conversation is active or if
the active conversation has no history yet.
Examples
# Setup
reset_history_manager()
conv_hist_id <- create_new_conversation(activate = TRUE)
# Get history when empty
print("Initial history:")
print(get_active_chat_history()) # list()
# Add messages
add_message_to_active_history("user", "Question 1")
add_message_to_active_history("assistant", "Answer 1")
# Get history after adding messages
print("History after messages:")
print(get_active_chat_history())
# Deactivate and check (should be empty list)
set_active_conversation(NULL)
print("History when none active:")
print(get_active_chat_history()) # list()
# Clean up
reset_history_manager()
[Package PacketLLM version 0.1.0 Index]