workspace working
This commit is contained in:
@@ -4008,6 +4008,7 @@ async def _build_llm_context(
|
||||
if not entities_context and not relations_context:
|
||||
if return_raw_data:
|
||||
# Return empty raw data structure when no entities/relations
|
||||
logger.debug(f"[_build_query_context] Early return (mode != mix) with empty raw data")
|
||||
empty_raw_data = _convert_to_user_format(
|
||||
[],
|
||||
[],
|
||||
@@ -4122,12 +4123,34 @@ async def _build_query_context(
|
||||
chunks_vdb,
|
||||
)
|
||||
|
||||
logger.debug(f"[_build_query_context] Early return check: entities={len(search_result['final_entities'])}, relations={len(search_result['final_relations'])}, chunk_tracking={search_result.get('chunk_tracking')}, mode={query_param.mode}, return_raw_data={return_raw_data}")
|
||||
if not search_result["final_entities"] and not search_result["final_relations"]:
|
||||
if query_param.mode != "mix":
|
||||
return None
|
||||
if return_raw_data:
|
||||
# Return empty raw data structure when no entities/relations
|
||||
empty_raw_data = _convert_to_user_format(
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
query_param.mode,
|
||||
)
|
||||
return None, empty_raw_data
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
if not search_result["chunk_tracking"]:
|
||||
return None
|
||||
if return_raw_data:
|
||||
# Return empty raw data structure when no entities/relations/chunks
|
||||
logger.debug(f"[_build_query_context] Early return (mode=mix, no chunk_tracking) with empty raw data")
|
||||
empty_raw_data = _convert_to_user_format(
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
query_param.mode,
|
||||
)
|
||||
return None, empty_raw_data
|
||||
else:
|
||||
return None
|
||||
|
||||
# Stage 2: Apply token truncation for LLM efficiency
|
||||
truncation_result = await _apply_token_truncation(
|
||||
@@ -4155,7 +4178,17 @@ async def _build_query_context(
|
||||
and not truncation_result["entities_context"]
|
||||
and not truncation_result["relations_context"]
|
||||
):
|
||||
return None
|
||||
if return_raw_data:
|
||||
# Return empty raw data structure when no entities/relations/chunks
|
||||
empty_raw_data = _convert_to_user_format(
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
query_param.mode,
|
||||
)
|
||||
return None, empty_raw_data
|
||||
else:
|
||||
return None
|
||||
|
||||
# Stage 4: Build final LLM context with dynamic token processing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user