diff --git a/backend/danswer/configs/app_configs.py b/backend/danswer/configs/app_configs.py index fcba5decc06c..76f13deba781 100644 --- a/backend/danswer/configs/app_configs.py +++ b/backend/danswer/configs/app_configs.py @@ -246,6 +246,9 @@ JOB_TIMEOUT = 60 * 60 * 6 # 6 hours default LOG_ALL_MODEL_INTERACTIONS = ( os.environ.get("LOG_ALL_MODEL_INTERACTIONS", "").lower() == "true" ) +LOG_VESPA_TIMING_INFORMATION = ( + os.environ.get("LOG_VESPA_TIMING_INFORMATION", "").lower() == "true" +) # Anonymous usage telemetry DISABLE_TELEMETRY = os.environ.get("DISABLE_TELEMETRY", "").lower() == "true" # notset, debug, info, warning, error, or critical diff --git a/backend/danswer/document_index/vespa/index.py b/backend/danswer/document_index/vespa/index.py index 1f4c4f901db5..61818db3d587 100644 --- a/backend/danswer/document_index/vespa/index.py +++ b/backend/danswer/document_index/vespa/index.py @@ -20,6 +20,7 @@ from danswer.configs.app_configs import DOCUMENT_INDEX_NAME from danswer.configs.app_configs import EDIT_KEYWORD_QUERY from danswer.configs.app_configs import FAVOR_RECENT_DECAY_MULTIPLIER from danswer.configs.app_configs import HYBRID_ALPHA +from danswer.configs.app_configs import LOG_VESPA_TIMING_INFORMATION from danswer.configs.app_configs import NUM_RETURNED_HITS from danswer.configs.app_configs import VESPA_DEPLOYMENT_ZIP from danswer.configs.app_configs import VESPA_HOST @@ -436,10 +437,24 @@ def _vespa_hit_to_inference_chunk(hit: dict[str, Any]) -> InferenceChunk: def _query_vespa(query_params: Mapping[str, str | int | float]) -> list[InferenceChunk]: if "query" in query_params and not cast(str, query_params["query"]).strip(): raise ValueError("No/empty query received") - response = requests.get(SEARCH_ENDPOINT, params=query_params) + + response = requests.get( + SEARCH_ENDPOINT, + params=dict( + **query_params, + **{ + "presentation.timing": True, + } + if LOG_VESPA_TIMING_INFORMATION + else {}, + ), + ) response.raise_for_status() - hits = response.json()["root"].get("children", []) + response_json: dict[str, Any] = response.json() + if LOG_VESPA_TIMING_INFORMATION: + logger.info("Vespa timing info: %s", response_json.get("timing")) + hits = response_json["root"].get("children", []) for hit in hits: if hit["fields"].get(CONTENT) is None: