Skip to content

Commit 099095e

Browse files
authored
fix: fix the knowledge graph explorer link (#658)
1 parent 06ce1b1 commit 099095e

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

backend/app/rag/chat/chat_flow.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def _builtin_chat(
227227
db_user_message=db_user_message,
228228
response_text=need_clarify_response,
229229
knowledge_graph=knowledge_graph,
230+
source_documents=[],
230231
)
231232
return None, []
232233

@@ -247,7 +248,6 @@ def _builtin_chat(
247248
db_user_message=db_user_message,
248249
response_text=response_text,
249250
knowledge_graph=knowledge_graph,
250-
source_documents=source_documents,
251251
)
252252

253253
return response_text, source_documents
@@ -329,7 +329,7 @@ def _search_knowledge_graph(
329329
def _refine_user_question(
330330
self,
331331
user_question: str,
332-
chat_history: Optional[List[ChatMessage]] = list,
332+
chat_history: Optional[List[ChatMessage]] = [],
333333
refined_question_prompt: Optional[str] = None,
334334
knowledge_graph_context: str = "",
335335
annotation_silent: bool = False,
@@ -377,7 +377,7 @@ def _refine_user_question(
377377
def _clarify_question(
378378
self,
379379
user_question: str,
380-
chat_history: Optional[List[ChatMessage]] = list,
380+
chat_history: Optional[List[ChatMessage]] = [],
381381
knowledge_graph_context: str = "",
382382
) -> Generator[ChatEvent, None, Tuple[bool, str]]:
383383
"""
@@ -577,7 +577,7 @@ def _chat_finish(
577577
db_user_message: ChatMessage,
578578
response_text: str,
579579
knowledge_graph: KnowledgeGraphRetrievalResult = KnowledgeGraphRetrievalResult(),
580-
source_documents: Optional[List[SourceDocument]] = list,
580+
source_documents: Optional[List[SourceDocument]] = [],
581581
annotation_silent: bool = False,
582582
):
583583
if not annotation_silent:
@@ -627,14 +627,20 @@ def _external_chat(self) -> Generator[ChatEvent | str, None, None]:
627627
goal, response_format = self.user_question, {}
628628
if settings.ENABLE_QUESTION_CACHE and len(self.chat_history) == 0:
629629
try:
630-
logger.info(f"start to find_best_answer_for_question with question: {self.user_question}")
630+
logger.info(
631+
f"start to find_best_answer_for_question with question: {self.user_question}"
632+
)
631633
cache_messages = chat_repo.find_best_answer_for_question(
632634
self.db_session, self.user_question
633635
)
634636
if cache_messages and len(cache_messages) > 0:
635-
logger.info(f"find_best_answer_for_question result {len(cache_messages)} for question {self.user_question}")
637+
logger.info(
638+
f"find_best_answer_for_question result {len(cache_messages)} for question {self.user_question}"
639+
)
636640
except Exception as e:
637-
logger.error(f"Failed to find best answer for question {self.user_question}: {e}")
641+
logger.error(
642+
f"Failed to find best answer for question {self.user_question}: {e}"
643+
)
638644

639645
if not cache_messages or len(cache_messages) == 0:
640646
try:
@@ -643,10 +649,11 @@ def _external_chat(self) -> Generator[ChatEvent | str, None, None]:
643649

644650
# 2. Check if the goal provided enough context information or need to clarify.
645651
if self.engine_config.clarify_question:
646-
need_clarify, need_clarify_response = (
647-
yield from self._clarify_question(
648-
user_question=goal, chat_history=self.chat_history
649-
)
652+
(
653+
need_clarify,
654+
need_clarify_response,
655+
) = yield from self._clarify_question(
656+
user_question=goal, chat_history=self.chat_history
650657
)
651658
if need_clarify:
652659
yield from self._chat_finish(

backend/app/rag/knowledge_base/selector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def __init__(
2929
self,
3030
llm: LLM,
3131
select_mode: KBSelectMode = KBSelectMode.ALL,
32-
retrievers: List[BaseRetriever] = list,
33-
retriever_choices: List[ToolMetadata] = list,
32+
retrievers: List[BaseRetriever] = [],
33+
retriever_choices: List[ToolMetadata] = [],
3434
callback_manager: CallbackManager = CallbackManager([]),
3535
):
3636
if select_mode == KBSelectMode.ALL:

frontend/app/src/components/chat/knowledge-graph-debug-info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function KnowledgeGraphDebugInfo ({ group }: { group: ChatMessageGroup })
5050

5151
if (kbLinked.length === 1) {
5252
return (
53-
<Link href={`/knowledge-bases/${kbLinked}/knowledge-graph-explorer?query=${encodeURIComponent(`message-subgraph:${group.user.id}`)}`} className="absolute top-2 right-2 text-xs underline">
53+
<Link href={`/knowledge-bases/${kbLinked[0].id}/knowledge-graph-explorer?query=${encodeURIComponent(`message-subgraph:${group.user.id}`)}`} className="absolute top-2 right-2 text-xs underline">
5454
<PencilIcon className="w-3 h-3 mr-1 inline-block" />
5555
Edit graph
5656
</Link>

0 commit comments

Comments
 (0)