From 383fe4d7075ffe43ae3b7b5c7834f9db1461fd31 Mon Sep 17 00:00:00 2001 From: Yuhong Sun Date: Sun, 29 Oct 2023 22:39:35 -0700 Subject: [PATCH] done --- backend/danswer/connectors/gong/connector.py | 27 +++++++++++++++----- web/src/app/admin/connectors/gong/page.tsx | 5 ++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/backend/danswer/connectors/gong/connector.py b/backend/danswer/connectors/gong/connector.py index 7f5f7f91ba9..5060d9422bf 100644 --- a/backend/danswer/connectors/gong/connector.py +++ b/backend/danswer/connectors/gong/connector.py @@ -54,7 +54,15 @@ def _get_workspace_id_map(self) -> dict[str, str]: response.raise_for_status() workspaces_details = response.json().get("workspaces") - return {workspace["name"]: workspace["id"] for workspace in workspaces_details} + name_id_map = { + workspace["name"]: workspace["id"] for workspace in workspaces_details + } + id_id_map = { + workspace["id"]: workspace["id"] for workspace in workspaces_details + } + # In very rare case, if a workspace is given a name which is the id of another workspace, + # Then the user input is treated as the name + return {**id_id_map, **name_id_map} def _get_transcript_batches( self, start_datetime: str | None = None, end_datetime: str | None = None @@ -178,8 +186,14 @@ def _fetch_calls( continue call_details = call_details_map[call_id] - call_metadata = call_details["metaData"] + + call_time_str = call_metadata["started"] + call_title = call_metadata["title"] + logger.info( + f"Indexing Gong call from {call_time_str.split('T', 1)[0]}: {call_title}" + ) + call_parties = call_details["parties"] id_to_name_map = self._parse_parties(call_parties) @@ -188,7 +202,6 @@ def _fetch_calls( speaker_to_name: dict[str, str] = {} transcript_text = "" - call_title = call_metadata["title"] if call_title: transcript_text += f"Call Title: {call_title}\n\n" @@ -226,10 +239,10 @@ def _fetch_calls( source=DocumentSource.GONG, # Should not ever be Untitled as a call cannot be made without a Title semantic_identifier=call_title or "Untitled", - doc_updated_at=datetime.fromisoformat( - call_metadata["started"] - ).astimezone(timezone.utc), - metadata={"Start Time": call_metadata["started"]}, + doc_updated_at=datetime.fromisoformat(call_time_str).astimezone( + timezone.utc + ), + metadata={}, ) ) yield doc_batch diff --git a/web/src/app/admin/connectors/gong/page.tsx b/web/src/app/admin/connectors/gong/page.tsx index 8250a54a582..cb5f0547cd9 100644 --- a/web/src/app/admin/connectors/gong/page.tsx +++ b/web/src/app/admin/connectors/gong/page.tsx @@ -215,8 +215,9 @@ const Main = () => { name: "workspaces", label: "Workspaces:", subtext: - "Specify 0 or more workspaces to index. Be sure to use the EXACT workspace name from Gong. " + - "If no workspaces are specified, transcripts from all workspaces will be indexed.", + "Specify 0 or more workspaces to index. Provide the workspace ID or the EXACT workspace " + + "name from Gong. If no workspaces are specified, transcripts from all workspaces will " + + "be indexed.", })} validationSchema={Yup.object().shape({ workspaces: Yup.array().of(