An LLM-powered knowledge curation system that researches a topic and generates a full-length report with citations.
Python agentic-ragdeep-researchemnlp2024knowledge-curationlarge-language-modelsnaaclnlpreport-generationretrieval-augmented-generation
remove frontend code
Yucheng-Jiangcba21849153a
diff --git a/knowledge_storm/__init__.py b/knowledge_storm/__init__.pyindex 5a9a53f..d28f041 100644--- a/knowledge_storm/__init__.py+++ b/knowledge_storm/__init__.py@@ -1,10 +1,8 @@from .storm_wiki import *from .collaborative_storm import *-from .api import *from .encoder import *from .interface import *from .lm import *from .rm import *-from .server import *from .utils import *from .dataclass import *diff --git a/knowledge_storm/collaborative_storm/__init__.py b/knowledge_storm/collaborative_storm/__init__.pyindex 62e6bfb..b85715b 100644--- a/knowledge_storm/collaborative_storm/__init__.py+++ b/knowledge_storm/collaborative_storm/__init__.py@@ -1,4 +1,2 @@from .modules import *from .engine import *-from .demo_runner import *-from .baseline import *diff --git a/knowledge_storm/collaborative_storm/engine.py b/knowledge_storm/collaborative_storm/engine.pyindex e8c6092..8e50d21 100644--- a/knowledge_storm/collaborative_storm/engine.py+++ b/knowledge_storm/collaborative_storm/engine.py@@ -609,14 +609,6 @@ class CoStormRunner:def dump_logging_and_reset(self):return self.logging_wrapper.dump_logging_and_reset()- def get_next_turn_experts_for_frontend_render(self):- turn_policy = self.discourse_manager.get_next_turn_policy(- conversation_history=self.conversation_history,- simulate_user=False,- dry_run=True,- )- return turn_policy.agent.role_name-def step(self,user_utterance: str = "",diff --git a/knowledge_storm/collaborative_storm/modules/collaborative_storm_utils.py b/knowledge_storm/collaborative_storm/modules/collaborative_storm_utils.pyindex 661c49f..d337de6 100644--- a/knowledge_storm/collaborative_storm/modules/collaborative_storm_utils.py+++ b/knowledge_storm/collaborative_storm/modules/collaborative_storm_utils.py@@ -240,125 +240,6 @@ def load_api_key(toml_file_path):os.environ[key] = str(value)-def construct_frontend_display_data(- knowledge_base,- conv_turn,- is_warm_start: bool = False,- next_turn_role: Optional[str] = None,-):- def to_dict(node):- if node is None:- return None- data = {- "node_name": node.name,- "node_uuid": " -> ".join(node.get_path_from_root()),- "content": list(node.content),- "child_node": [],- }- for child in node.children:- child_data = to_dict(child)- if child_data is not None:- data["child_node"].append(child_data)- return data-- def split_paragraph(paragraph):- # Regular expression to match sentences with citations- sentence_pattern = re.compile(r"([^.?!]*[.?!])(\s*\[\d+\])*")- citation_pattern = re.compile(r"\[(\d+)\]")-- # Check if there are any sentence separators in the paragraph- if not re.search(r"[.?!]", paragraph):- # If no separators, consider the whole paragraph as a single sentence- citations = list(map(int, citation_pattern.findall(paragraph)))- sentence = citation_pattern.sub("", paragraph).strip()- return [(sentence, citations)]-- sentences = []-- for match in sentence_pattern.finditer(paragraph):- sentence_with_citations = match.group(0).strip()- sentence = match.group(1).strip()- citations = list(- map(int, citation_pattern.findall(sentence_with_citations))- )-- # Remove citations from the sentence- sentence = citation_pattern.sub("", sentence).strip()-- sentences.append((sentence, citations))-- return sentences-- # get mind map- mind_map = to_dict(knowledge_base.root)- # get last turn utterance- role = conv_turn.role- utterance = str(conv_turn.utterance)- sentences_w_citations = split_paragraph(utterance)-- # get cited info- cited_info = {}- for citation_idx, info in knowledge_base.info_uuid_to_info_dict.items():- cited_info[citation_idx] = {- "description": info.description,- "snippets": info.snippets,- "url": info.url,- "title": info.title,- "placement": info.meta.get("placement", ""),- }- evaluation_questions = None- if conv_turn.role != "Guest":- evaluation_questions = [- {- "question": "Does this new utterance help steer the discourse towards a new and interesting direction?",- "type": "multiple_choice",- "choices": ["Yes", "No"],- "id": 1,- },- {- "question": "Has the mind map reasonably managing the discourse so far?",- "type": "multiple_choice",- "choices": ["Yes", "No"],- "id": 2,- },- {- "question": "(Optional) Any comments?",- "type": "freeform",- "choices": [],- "id": 3,- },- ]- to_return = {- "mind_map": mind_map,- "conversation_turn": {- "role": role,- "content": sentences_w_citations,- "is_warm_start": is_warm_start,- },- "cited_info": cited_info,- "eval": evaluation_questions,- "next_turn_role": next_turn_role,- }- return to_return---def construct_article_frontend_display_data(knowledge_base, article: str):- cited_info = {- key: value.to_dict()- for key, value in knowledge_base.info_uuid_to_info_dict.items()- }- data = {"article": article, "cited_info": cited_info}- return data---def construct_round_table_conversation_databackup(round_table_conversation):- round_tabld_dump = round_table_conversation.to_dict()- log_dump = round_table_conversation.logging_wrapper.dump_logging_and_reset(- reset_logging=False- )- return {"round_tabld_dump": round_tabld_dump, "log_dump": log_dump}--def _get_answer_question_module_instance(lm_config: LMConfigs,runner_argument: "RunnerArgument",