insert

The insert function from the AsyncHistory class is used for multi-layered addition of blocks to the history. It allows adding multiple messages in a single call.

Properties:

  • data — a list containing the message blocks to be added.

Example usage:

from litegpt.lib import AsyncHistory
import asyncio

async def main():
    # Creating a history object and adding multiple blocks
    history = History()
    await history.insert([
        ("system", "system options here!"),
        ("assistant", "assistant first message!"),
        ("user", "user message here!"),
        ("assistant", "assistant second message!")
    ])
    print(history)
    
asyncio.run(main())

Thus, the insert function allows for easy and quick addition of multiple messages to the history, preserving the sequence and structure of the data.

Last updated