memoryscope.core.worker.backend.update_insight_worker

class memoryscope.core.worker.backend.update_insight_worker.UpdateInsightWorker(embedding_model: str = '', generation_model: str = '', rank_model: str = '', **kwargs)[source]

Bases: MemoryBaseWorker

This class is responsible for updating insight value in a memory system. It filters insight nodes based on their association with observed nodes, utilizes a ranking model to prioritize them, generates refreshed insights via an LLM, and manages node statuses and content updates, incorporating features for concurrent execution and logging.

FILE_PATH: str = '/home/runner/work/MemoryScope/MemoryScope/memoryscope/core/worker/backend/update_insight_worker.py'
filter_obs_nodes(insight_node: ~memoryscope.scheme.memory_node.MemoryNode, obs_nodes: ~typing.List[~memoryscope.scheme.memory_node.MemoryNode]) -> (<class 'memoryscope.scheme.memory_node.MemoryNode'>, typing.List[memoryscope.scheme.memory_node.MemoryNode], <class 'float'>)[source]

Filters observed nodes based on their relevance to a given insight node using a ranking model.

Parameters:
  • insight_node (MemoryNode) – The insight node used as the basis for filtering.

  • obs_nodes (List[MemoryNode]) – A list of observed nodes to be filtered.

Returns:

A tuple containing:
  • The original insight node.

  • A list of filtered observed nodes that are relevant to the insight node.

  • The maximum relevance score among the filtered nodes.

Return type:

tuple

update_insight_node(insight_node: MemoryNode, insight_value: str)[source]

Updates the MemoryNode with the new insight value.

Parameters:
  • insight_node (MemoryNode) – The MemoryNode whose insight value needs to be updated.

  • insight_value (str) – The new insight value.

Returns:

The updated MemoryNode with potentially revised insight value.

Return type:

MemoryNode

update_insight(insight_node: MemoryNode, filtered_nodes: List[MemoryNode]) MemoryNode[source]

Updates the insight value of a given MemoryNode based on the context from a list of filtered MemoryNodes.

Parameters:
  • insight_node (MemoryNode) – The MemoryNode whose insight value needs to be updated.

  • filtered_nodes (List[MemoryNode]) – A list of MemoryNodes used as context for updating the insight.

Returns:

The updated MemoryNode with potentially revised insight value.

Return type:

MemoryNode

name: str
workflow_context: Dict[str, Any]
memoryscope_context: MemoryscopeContext
raise_exception: bool
is_multi_thread: bool
thread_pool: ThreadPoolExecutor
enable_parallel: bool
kwargs: dict
continue_run: bool
async_task_list: list
thread_task_list: list
logger: Logger