Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/storm_examples/run_storm_wiki_deepseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def sanitize_topic(topic):
topic = topic.replace(" ", "_")

# Remove any character that isn't alphanumeric, underscore, or hyphen
topic = re.sub(r"[^a-zA-Z0-9_-]", "", topic)
topic = re.sub(r'[^a-zA-Z0-9_\-\s]', '', topic)

# Ensure the topic isn't empty after sanitization
if not topic:
topic = "unnamed_topic"

return topic
return topic[:100] if topic else "unnamed_topic"


def main(args):
Expand Down Expand Up @@ -152,8 +152,8 @@ def main(args):
try:
runner.run(
topic=sanitized_topic,
do_research=args.do_research,
do_generate_outline=args.do_generate_outline,
do_research=args.do_research and bool(sanitized_topic.strip()),
do_generate_outline=args.do_generate_outline and bool(sanitized_topic.strip()),
do_generate_article=args.do_generate_article,
do_polish_article=args.do_polish_article,
remove_duplicate=args.remove_duplicate,
Expand Down
4 changes: 4 additions & 0 deletions knowledge_storm/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,10 @@ def forward(
if isinstance(query_or_queries, str)
else query_or_queries
)
valid_queries = [q for q in queries if q and len(q.strip()) >= 3]
if not valid_queries:
logging.warning(f"All queries are empty: {queries}")
return []
self.usage += len(queries)

collected_results = []
Expand Down
7 changes: 7 additions & 0 deletions knowledge_storm/storm_wiki/modules/knowledge_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ def forward(self, topic: str, question: str, ground_truth_url: str):
q.replace("-", "").strip().strip('"').strip('"').strip()
for q in queries.split("\n")
]
queries = [q for q in queries if q and len(q.strip()) > 3] # 长度>3字符
if not queries:
return dspy.Prediction(
queries=[],
searched_results=[],
answer="No valid queries generated for this question"
)
queries = queries[: self.max_search_queries]
# Search
searched_results: List[Information] = self.retriever.retrieve(
Expand Down