Skip to content

Commit a2581ff

Browse files
committed
fix issue with streaming chat with empty kb
1 parent 067a408 commit a2581ff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llm-service/app/services/chat/streaming_chat.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
StreamingAgentChatResponse,
4747
)
4848

49+
from app.ai.vector_stores.vector_store_factory import VectorStoreFactory
4950
from app.rag_types import RagPredictConfiguration
5051
from app.services import llm_completion, models
5152
from app.services.chat.chat import finalize_response
@@ -87,8 +88,13 @@ def stream_chat(
8788
)
8889

8990
response_id = str(uuid.uuid4())
90-
91-
if not query_configuration.use_tool_calling and len(session.data_source_ids) == 0:
91+
total_data_sources_size: int = sum(
92+
map(
93+
lambda ds_id: VectorStoreFactory.for_chunks(ds_id).size() or 0,
94+
session.data_source_ids,
95+
)
96+
)
97+
if not query_configuration.use_tool_calling and (len(session.data_source_ids) == 0 or total_data_sources_size == 0):
9298
# put a poison pill in the queue to stop the crew events stream
9399
crew_events_queue.put(CrewEvent(type=poison_pill, name="no-op"))
94100
return _stream_direct_llm_chat(session, response_id, query, user_name, crew_events_queue)

0 commit comments

Comments
 (0)