Skip to content

Commit

Permalink
fix(frontend): update knowledge graph url
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Nov 27, 2024
1 parent 463ada3 commit f887819
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getChatMessageSubgraph } from '@/api/chats';
import { useAuth } from '@/components/auth/AuthProvider';
import { type ChatMessageGroup, useChatMessageStreamState } from '@/components/chat/chat-hooks';
import { type ChatMessageGroup, useChatInfo, useChatMessageStreamState, useCurrentChatController } from '@/components/chat/chat-hooks';
import type { OngoingState } from '@/components/chat/chat-message-controller';
import { AppChatStreamState, type StackVMState } from '@/components/chat/chat-stream-state';
import { NetworkViewer } from '@/components/graph/components/NetworkViewer';
Expand All @@ -11,9 +11,11 @@ import { useEffect } from 'react';
import useSWR from 'swr';

export function KnowledgeGraphDebugInfo ({ group }: { group: ChatMessageGroup }) {
const { engine_options } = useChatInfo(useCurrentChatController()) ?? {};
const auth = useAuth();
const ongoing = useChatMessageStreamState(group.assistant);
const canEdit = !!auth.me?.is_superuser;
const kbId = engine_options?.knowledge_base?.linked_knowledge_base?.id;
const canEdit = !!auth.me?.is_superuser && kbId != null;

const shouldFetch = (!ongoing || ongoing.finished || couldFetchKnowledgeGraphDebugInfo(ongoing));
const { data: span, isLoading, mutate } = useSWR(
Expand Down Expand Up @@ -42,7 +44,7 @@ export function KnowledgeGraphDebugInfo ({ group }: { group: ChatMessageGroup })
network={network}
Details={() => canEdit
? (
<Link href={`/knowledge-graph?query=${encodeURIComponent(`message-subgraph:${group.user.id}`)}`} className="absolute top-2 right-2 text-xs underline">
<Link href={`/knowledge-bases/${kbId}/knowledge-graph-explorer?query=${encodeURIComponent(`message-subgraph:${group.user.id}`)}`} className="absolute top-2 right-2 text-xs underline">
<PencilIcon className="w-3 h-3 mr-1 inline-block" />
Edit graph
</Link>
Expand Down

0 comments on commit f887819

Please sign in to comment.