Skip to content

armgit / storm

Public Imported from GitHub
0

An LLM-powered knowledge curation system that researches a topic and generates a full-length report with citations.

fixed bug

sureenheer376d2b2bbf07
diff --git a/knowledge_storm/storm_wiki/engine.py b/knowledge_storm/storm_wiki/engine.py
index e0c8dfc..77361ad 100644
--- a/knowledge_storm/storm_wiki/engine.py
+++ b/knowledge_storm/storm_wiki/engine.py
@@ -16,7 +16,7 @@ from .modules.retriever import StormRetriever
from .modules.storm_dataclass import StormInformationTable, StormArticle
from ..interface import Engine, LMConfigs
from ..lm import OpenAIModel
-from ..utils import FileIOHelper, makeStringRed
+from ..utils import FileIOHelper, makeStringRed, truncate_filename
class STORMWikiLMConfigs(LMConfigs):
@@ -283,7 +283,7 @@ class STORMWikiRunner(Engine):
"No action is specified. Please set at least one of --do-research, --do-generate-outline, --do-generate-article, --do-polish-article")
self.topic = topic
- self.article_dir_name = topic.replace(' ', '_').replace('/', '_')
+ self.article_dir_name = truncate_filename(topic.replace(' ', '_').replace('/', '_'))
self.article_output_dir = os.path.join(self.args.output_dir, self.article_dir_name)
os.makedirs(self.article_output_dir, exist_ok=True)
diff --git a/knowledge_storm/utils.py b/knowledge_storm/utils.py
index 09412c6..36f68fd 100644
--- a/knowledge_storm/utils.py
+++ b/knowledge_storm/utils.py
@@ -20,6 +20,20 @@ from trafilatura import extract
logging.getLogger("httpx").setLevel(logging.WARNING) # Disable INFO logging for httpx.
+def truncate_filename(filename, max_length=125):
+ """Truncate filename to max_length to ensure the filename won't exceed the file system limit.
+
+ Args:
+ filename: str
+ max_length: int, default to 125 (usual path length limit is 255 chars)
+ """
+
+ if len(filename) > max_length:
+ truncated_filename = filename[:max_length]
+ logging.warning(f"Filename is too long. Filename is truncated to {truncated_filename}.")
+ return truncated_filename
+
+ return filename
def load_api_key(toml_file_path):
try: