get_conversation_history {PacketLLM} | R Documentation |
Gets the chat history for the conversation with the given ID
Description
Retrieves the list of messages associated with a specific conversation ID.
Usage
get_conversation_history(id)
Arguments
id |
Character string. The ID of the conversation. |
Value
List or NULL
. A list containing the message history (each element is a
list with role
and content
) for the conversation specified by id
.
Returns NULL
if the conversation does not exist. Returns an empty list
(list()
) if the conversation exists but has no history yet.
Examples
# Setup
reset_history_manager()
conv_gethist_id <- create_new_conversation(activate = TRUE)
# Get history for new conversation
print("Initial history by ID:")
print(get_conversation_history(conv_gethist_id)) # list()
# Add messages using the exported function
add_message_to_active_history("user", "Hi there")
add_message_to_active_history("assistant", "Hello")
# Get history again
print("History after messages:")
print(get_conversation_history(conv_gethist_id))
# Get history for non-existent ID
print("History for non-existent:")
print(get_conversation_history("bad_id")) # NULL
# Clean up
reset_history_manager()
[Package PacketLLM version 0.1.0 Index]