Skip to content

Commit

Permalink
Improve chat page performance (#3347)
Browse files Browse the repository at this point in the history
* Simplify /manage/indexing-status

* Rename endpoint
  • Loading branch information
Weves authored Dec 5, 2024
1 parent c89b98b commit 3266ef6
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 99 deletions.
21 changes: 1 addition & 20 deletions backend/danswer/server/documents/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,37 +1010,18 @@ def get_connector_by_id(


class BasicCCPairInfo(BaseModel):
docs_indexed: int
has_successful_run: bool
source: DocumentSource


@router.get("/indexing-status")
@router.get("/connector-status")
def get_basic_connector_indexing_status(
_: User = Depends(current_user),
db_session: Session = Depends(get_session),
) -> list[BasicCCPairInfo]:
cc_pairs = get_connector_credential_pairs(db_session)
cc_pair_identifiers = [
ConnectorCredentialPairIdentifier(
connector_id=cc_pair.connector_id, credential_id=cc_pair.credential_id
)
for cc_pair in cc_pairs
]
document_count_info = get_document_counts_for_cc_pairs(
db_session=db_session,
cc_pair_identifiers=cc_pair_identifiers,
)
cc_pair_to_document_cnt = {
(connector_id, credential_id): cnt
for connector_id, credential_id, cnt in document_count_info
}
return [
BasicCCPairInfo(
docs_indexed=cc_pair_to_document_cnt.get(
(cc_pair.connector_id, cc_pair.credential_id)
)
or 0,
has_successful_run=cc_pair.last_successful_index_time is not None,
source=cc_pair.connector.source,
)
Expand Down
71 changes: 0 additions & 71 deletions web/src/components/initialSetup/search/NoCompleteSourceModal.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion web/src/lib/assistants/fetchPersonaEditorInfoSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function fetchAssistantEditorInfoSS(
| [null, string]
> {
const tasks = [
fetchSS("/manage/indexing-status"),
fetchSS("/manage/connector-status"),
fetchSS("/manage/document-set"),
fetchSS("/llm/provider"),
// duplicate fetch, but shouldn't be too big of a deal
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/chat/fetchAssistantdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function fetchAssistantData(): Promise<AssistantData> {

// Parallel fetch of additional data
const [ccPairsResponse, llmProviders] = await Promise.all([
fetchSS("/manage/indexing-status").catch((error) => {
fetchSS("/manage/connector-status").catch((error) => {
console.error("Failed to fetch connectors:", error);
return null;
}),
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/chat/fetchChatData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function fetchChatData(searchParams: {
const tasks = [
getAuthTypeMetadataSS(),
getCurrentUserSS(),
fetchSS("/manage/indexing-status"),
fetchSS("/manage/connector-status"),
fetchSS("/manage/document-set"),
fetchSS("/chat/get-user-chat-sessions"),
fetchSS("/query/valid-tags"),
Expand Down
6 changes: 2 additions & 4 deletions web/src/lib/chat/fetchSomeChatData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function fetchSomeChatData(
const taskMap: Record<FetchOption, () => Promise<any>> = {
user: getCurrentUserSS,
chatSessions: () => fetchSS("/chat/get-user-chat-sessions"),
ccPairs: () => fetchSS("/manage/indexing-status"),
ccPairs: () => fetchSS("/manage/connector-status"),
documentSets: () => fetchSS("/manage/document-set"),
assistants: fetchAssistantsSS,
tags: () => fetchSS("/query/valid-tags"),
Expand Down Expand Up @@ -229,9 +229,7 @@ export async function fetchSomeChatData(
result.shouldDisplaySourcesIncompleteModal =
hasAnyConnectors &&
!result.shouldShowWelcomeModal &&
!result.ccPairs.some(
(ccPair) => ccPair.has_successful_run && ccPair.docs_indexed > 0
) &&
!result.ccPairs.some((ccPair) => ccPair.has_successful_run) &&
(!user || user.role === "admin");
}

Expand Down
1 change: 0 additions & 1 deletion web/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export interface ConnectorIndexingStatus<
}

export interface CCPairBasicInfo {
docs_indexed: number;
has_successful_run: boolean;
source: ValidSources;
}
Expand Down

0 comments on commit 3266ef6

Please sign in to comment.