Chat History
Basic Chat History and Message store
llama_cpp_agent.chat_history.basic_chat_history
Chat History and Message store
llama_cpp_agent.chat_history.chat_history_base
ChatMessageStore
Bases: ABC
An abstract base class for storing and managing chat messages.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
get_messages_count()
abstractmethod
add_message(message)
abstractmethod
Add a new message to the store.
:param message: The ChatMessage object to add.
edit_message(index, edited_message)
abstractmethod
Edit a message at a specific index in the store.
:param index: The index of the message to edit. :param edited_message: The edited ChatMessage object.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
add_user_message(message)
abstractmethod
Add a user message to the store.
:param message: The content of the user message.
add_assistant_message(message)
abstractmethod
Add an assistant message to the store.
:param message: The content of the assistant message.
add_system_message(message)
abstractmethod
Add a system message to the store.
:param message: The content of the system message.
remove_last_message()
abstractmethod
remove_last_k_messages(k)
abstractmethod
Remove the last k messages from the store.
:param k: The number of messages to remove.
get_message(index)
abstractmethod
Get a message at a specific index from the store.
:param index: The index of the message to retrieve. :return: The ChatMessage object at the specified index.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
get_last_message()
abstractmethod
Get the last message from the store.
:return: The last ChatMessage object in the store.
get_last_k_messages(k)
abstractmethod
Get the last k messages from the store.
:param k: The number of messages to retrieve. :return: A list of the last k ChatMessage objects.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
get_messages(k)
abstractmethod
Get the messages starting from index k.
:param k: The starting index. :return: A list of ChatMessage objects starting from index k.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
get_all_messages()
abstractmethod
Get all messages from the store.
:return: A list of all ChatMessage objects in the store.
save_to_json(file_path)
abstractmethod
Save the messages to a JSON file.
:param file_path: The path to the JSON file.
load_from_json(file_path)
abstractmethod
Load messages from a JSON file.
:param file_path: The path to the JSON file.
ChatHistory
Bases: ABC
An abstract base class for managing chat history.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
get_message_store()
abstractmethod
Get the message store associated with the chat history.
:return: The ChatMessageStore object.
get_chat_messages()
abstractmethod
Get the chat messages as a list of dictionaries.
:return: A list of dictionaries representing the chat messages.
add_message(message)
abstractmethod
Add a message to the chat history.
:param message: A dictionary representing the message to add.
get_messages_count()
abstractmethod
Get the total count of messages in the chat history.
:return: The count of messages.
edit_message(index, edited_message)
abstractmethod
Edit a message at a specific index in the chat history.
:param index: The index of the message to edit. :param edited_message: A dictionary representing the edited message.
Source code in llama_cpp_agent/chat_history/chat_history_base.py
get_message(index)
abstractmethod
Get a message at a specific index from the chat history.
:param index: The index of the message to retrieve. :return: A dictionary representing the message at the specified index.