1. Data Zones: The Context Layers
LoLLMs uses a layered context approach. When you call get_full_data_zone(), it assembles these layers in specific order:
- Memory: Long-term facts.
- User Data Zone: Global user preferences (e.g., "I prefer Python 3.10").
- Discussion Data Zone: Metadata for the specific task (e.g., "Currently working on Chapter 3").
- Personality Data Zone: Temporary data from tools (e.g., RAG search results).
- Active Artefacts: The content of versioned documents.
# Direct manipulation of session context
discussion.user_data_zone = "User Role: Senior Architect"
discussion.discussion_data_zone = "Project Goal: Build a FastAPI backend."
2. The Memory System
Memory can be manually set or automatically extracted using memorize().
- Manual: Best for explicit facts.
- Auto-Memorize: Asks the LLM to extract technical content and solutions from the history.
# Auto-extract facts from current conversation
memory_entry = discussion.memorize()
# Returns {"title": "...", "content": "..."} if successful
3. Versioned Artefact System
Artefacts are persistent documents that survive conversation turns. They support metadata and full version control.
A. Creation & Metadata
Always use XML tags. The system stores attributes like author, source, and description.
<artefact name="outline.md" type="document" author="ParisNeo" description="Book Structure">
# Book Outline
1. Introduction
2. The Awakening
3. The Conflict
</artefact>
B. Efficient Patching (Aider Format)
To save context, use Aider blocks. The backend finds the SEARCH text and replaces it with REPLACE.
<artefact name="outline.md">
<<<<<<< SEARCH
2. The Awakening
=======
2. The New Awakening (Expanded)
>>>>>>> REPLACE
</artefact>
C. Versioning & Reverting
Every update increments the version. You can see history counts in the context and revert via tags:
<!-- Revert 'outline.md' to version 1 -->
<revert_artefact name="outline.md" version="1" />
4. Agentic Chat & UI Notifications
When using discussion.chat(), the backend emits a MSG_TYPE_ARTEFACTS_STATE_CHANGED notification whenever an artefact is created, updated, or reverted.
from lollms_client import MSG_TYPE
def my_callback(text, msg_type, meta):
if msg_type == MSG_TYPE.MSG_TYPE_ARTEFACTS_STATE_CHANGED:
# meta["artefacts"] contains the updated list of dictionaries
print(f"Artefact updated: {text}")
discussion.chat(
user_message="Update the second chapter of the book.",
streaming_callback=my_callback
)
5. Practical Workflow: Writing a Book
- Initialization: Ask LLM to create an artefact with an empty structure.
- Iterative Filling: Ask LLM to fill specific segments using aider patches.
- Refinement: Use
<revert_artefact>if a change wasn't desired. - Context Management: Use
discussion.summarize_and_prune(max_tokens=4096)regularly to keep the history lean while the Artefact keeps the primary content stable.
Source: ParisNeo/lollms-vs-coder — distributed by TomeVault.