saveFactsFromHistory

suspend fun saveFactsFromHistory(concept: Concept, subject: MemorySubject, scope: MemoryScope, retrievalModel: LLModel? = null)(source)

Extracts and saves facts from the LLM chat history based on the provided concept.

This method:

  1. Asks the LLM to extract facts about the specified concept from the conversation history

  2. Formats the response as a Fact object (SingleFact or MultipleFacts)

  3. Saves the fact to memory with the specified subject and scope

Example usage:

// Extract and save project dependencies from the conversation
memory.saveFactsFromHistory(
concept = Concept("project-dependencies", "Project build dependencies", FactType.MULTIPLE),
subject = MemorySubjects.Project,
scope = MemoryScope.Product("my-ide")
)

Parameters

concept

The concept to extract facts about

subject

The subject categorization for the facts (e.g., User, Project)

scope

The visibility scope for the facts (e.g., Agent, Feature, Product)

retrievalModel

LLM that will be used for fact retrieval from the history (by default, the same model as the current one will be used)