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
7 changes: 3 additions & 4 deletions m_flow/api/v1/prompts/routers/get_prompts_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,22 @@ def _categorize_prompt(filename: str) -> str:
# Answering: question answering and context generation
# Note: summarize_search_results is for Q&A response, not general summarization
if (
name.startswith("answer")
or name.startswith("direct_answer")
name.startswith(("answer", "direct_answer"))
or "retrieval_context" in name
or name == "search_result_deduplicator.txt"
):
return "answering"

# Episodic: Episode/Facet extraction and routing
if name.startswith("episodic") or name.startswith("episode"):
if name.startswith(("episodic", "episode")):
return "episodic"

# Entity: entity extraction and description
if "entity" in name or name == "optimize_merged_description.txt":
return "entity"

# Graph: knowledge graph generation
if name.startswith("generate_graph") or name.startswith("knowledge_graph_extractor"):
if name.startswith(("generate_graph", "knowledge_graph_extractor")):
return "graph"

# Summarization: content summarization (general purpose)
Expand Down
2 changes: 1 addition & 1 deletion m_flow/knowledge/summarization/summarize_by_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _extract_episode_name(raw_text: str) -> str:
"""Extract 'Episode Name: ...' from LLM output."""
import re

match = re.search(r"^Episode Name:\s*(.+?)(?:\n|$)", raw_text, re.I | re.M)
match = re.search(r"^Episode Name:\s*(.+?)(?:\n|$)", raw_text, re.IGNORECASE | re.MULTILINE)
return match.group(1).strip() if match else ""


Expand Down
4 changes: 2 additions & 2 deletions m_flow/knowledge/summarization/text_summary_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def parse(
def _extract_topic(cls, text: str) -> Optional[str]:
"""Extract overall topic from text."""
# Try "Topic: ..." format
topic_match = re.search(r"^(?:Topic|Overall Topic|Summary):\s*(.+?)(?:\n|$)", text, re.I)
topic_match = re.search(r"^(?:Topic|Overall Topic|Summary):\s*(.+?)(?:\n|$)", text, re.IGNORECASE)
if topic_match:
return topic_match.group(1).strip()

Expand All @@ -106,7 +106,7 @@ def _extract_topic(cls, text: str) -> Optional[str]:
if (
10 < len(first_line) < 100
and not first_line.startswith(("【", "-", "*", "#"))
and not re.match(r"^Episode Name:", first_line, re.I)
and not re.match(r"^Episode Name:", first_line, re.IGNORECASE)
):
return first_line

Expand Down
2 changes: 1 addition & 1 deletion m_flow/memory/episodic/routing/document_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def route_documents_to_episodes(
doc = getattr(first_chunk, "is_part_of", None)

# Sentence-level mode: doc_id is actually event_id (precomputed once)
is_single_event = doc_id.startswith("evt_") or doc_id.startswith("atomic_")
is_single_event = doc_id.startswith(("evt_", "atomic_"))

# Get doc_title (use extracted helper function to reduce nesting)
doc_title = ""
Expand Down
2 changes: 1 addition & 1 deletion m_flow/memory/procedural/procedural_points_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def extract_anchor_tokens(text: str, min_len: int = 2, max_count: int = 50) -> L
seen: Set[str] = set()

# Numbers with units
for m in re.finditer(r"\d+\.?\d*\s*(?:TB|GB|MB|KB|%|次|个|分钟|秒|小时|天|ms|s|min)", text, re.I):
for m in re.finditer(r"\d+\.?\d*\s*(?:TB|GB|MB|KB|%|次|个|分钟|秒|小时|天|ms|s|min)", text, re.IGNORECASE):
t = m.group(0).strip()
k = t.lower()
if k not in seen and len(t) >= min_len:
Expand Down
10 changes: 3 additions & 7 deletions m_flow/retrieval/episodic/bundle_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ async def episodic_bundle_search(
results_by_collection = {c: len(r) for c, r in node_distances.items()}
total_hits = sum(results_by_collection.values())
all_ids = {
str(getattr(r, "id"))
for results in node_distances.values()
if results
for r in results
if getattr(r, "id", None)
str(r.id) for results in node_distances.values() if results for r in results if getattr(r, "id", None)
}
rlog.log_vector_search(
collections=cfg.collections,
Expand Down Expand Up @@ -425,7 +421,7 @@ async def _two_phase_projection(
"""Two-phase graph projection."""
# Collect relevant IDs
all_hit_ids = {
str(getattr(r, "id"))
str(r.id)
for collection_name, results in node_distances.items()
if collection_name != "RelationType_relationship_name" and results
for r in results
Expand Down Expand Up @@ -485,7 +481,7 @@ async def _two_phase_projection_with_stats(

# Collect relevant IDs
all_hit_ids = {
str(getattr(r, "id"))
str(r.id)
for collection_name, results in node_distances.items()
if collection_name != "RelationType_relationship_name" and results
for r in results
Expand Down
2 changes: 1 addition & 1 deletion m_flow/retrieval/utils/fine_grained_triplet_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async def search_in_collection(collection_name: str):
if wide_search_limit is not None:
relevant_ids_to_filter = list(
{
str(getattr(scored_node, "id"))
str(scored_node.id)
for collection_name, score_collection in node_distances.items()
if collection_name != "RelationType_relationship_name"
and isinstance(score_collection, (list, tuple))
Expand Down
2 changes: 1 addition & 1 deletion m_flow/retrieval/utils/procedural_bundle_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ async def search_col(col: str):

# Collect hit IDs
all_hit_ids = {
str(getattr(r, "id"))
str(r.id)
for col, scored in node_distances.items()
if col != "RelationType_relationship_name"
for r in (scored or [])
Expand Down
2 changes: 1 addition & 1 deletion m_flow/shared/files/utils/get_data_file_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _normalise_file_uri(raw: str) -> str:
normalised = os.path.normpath(without_scheme)
# On Windows the URI ``file:///C:/dir`` normalises to ``/C:\\dir``
if os.name == "nt":
if (normalised.startswith("/") or normalised.startswith("\\")) and len(normalised) > 2 and normalised[2] == ":":
if (normalised.startswith(("/", "\\"))) and len(normalised) > 2 and normalised[2] == ":":
normalised = normalised[1:]
return normalised

Expand Down
Loading