MCPcopy
hub / github.com/stanford-oval/storm / insert_information

Method insert_information

knowledge_storm/dataclass.py:680–713  ·  view source on GitHub ↗

Inserts information into the knowledge base at the specified path. Args: path (str): The placement path string, connected by " -> " linking the name of nodes. information (Information): The information to insert. missing_node_handling (str): How

(
        self,
        path: str,
        information: Information,
        missing_node_handling="abort",
        root: Optional[KnowledgeNode] = None,
    )

Source from the content-addressed store, hash-verified

678 return current_node
679
680 def insert_information(
681 self,
682 path: str,
683 information: Information,
684 missing_node_handling="abort",
685 root: Optional[KnowledgeNode] = None,
686 ):
687 """
688 Inserts information into the knowledge base at the specified path.
689
690 Args:
691 path (str): The placement path string, connected by " -> " linking the name of nodes.
692 information (Information): The information to insert.
693 missing_node_handling (str): How to handle missing nodes. Options are "abort", "create", and "raise error".
694 Return:
695 uuid of insertion information
696 """
697 with self._lock:
698 target_node: KnowledgeNode = self.find_node_by_path(
699 path=path, missing_node_handling=missing_node_handling, root=root
700 )
701 information_hash = hash(information)
702 if information.citation_uuid == -1:
703 info_citation_uuid = self.info_hash_to_uuid_dict.get(
704 information_hash, len(self.info_hash_to_uuid_dict) + 1
705 )
706 information.citation_uuid = info_citation_uuid
707 self.info_hash_to_uuid_dict[information_hash] = info_citation_uuid
708 self.info_uuid_to_info_dict[info_citation_uuid] = information
709 if target_node is not None:
710 self.info_uuid_to_info_dict[information.citation_uuid].meta[
711 "placement"
712 ] = " -> ".join(target_node.get_path_from_root())
713 target_node.insert_information(information.citation_uuid)
714
715 def trim_empty_leaf_nodes(self):
716 """

Callers 1

update_from_conv_turnMethod · 0.95

Calls 3

find_node_by_pathMethod · 0.95
get_path_from_rootMethod · 0.80
insert_informationMethod · 0.45

Tested by

no test coverage detected