mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Log usage of /search, /chat, /update API endpoints to telemetry server
This commit is contained in:
@@ -14,7 +14,7 @@ from khoj.configure import configure_processor, configure_search
|
|||||||
from khoj.processor.conversation.gpt import converse, extract_questions
|
from khoj.processor.conversation.gpt import converse, extract_questions
|
||||||
from khoj.processor.conversation.utils import message_to_log, message_to_prompt
|
from khoj.processor.conversation.utils import message_to_log, message_to_prompt
|
||||||
from khoj.search_type import image_search, text_search
|
from khoj.search_type import image_search, text_search
|
||||||
from khoj.utils.helpers import timer
|
from khoj.utils.helpers import log_telemetry, timer
|
||||||
from khoj.utils.rawconfig import FullConfig, SearchResponse
|
from khoj.utils.rawconfig import FullConfig, SearchResponse
|
||||||
from khoj.utils.state import SearchType
|
from khoj.utils.state import SearchType
|
||||||
from khoj.utils import state, constants
|
from khoj.utils import state, constants
|
||||||
@@ -168,6 +168,8 @@ def search(
|
|||||||
# Cache results
|
# Cache results
|
||||||
state.query_cache[query_cache_key] = results
|
state.query_cache[query_cache_key] = results
|
||||||
|
|
||||||
|
log_telemetry(telemetry_type="api", api="search", app_config=state.config.app)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@@ -191,6 +193,8 @@ def update(t: Optional[SearchType] = None, force: Optional[bool] = False):
|
|||||||
else:
|
else:
|
||||||
logger.info("📬 Processor reconfigured via API")
|
logger.info("📬 Processor reconfigured via API")
|
||||||
|
|
||||||
|
log_telemetry(telemetry_type="api", api="update", app_config=state.config.app)
|
||||||
|
|
||||||
return {"status": "ok", "message": "khoj reloaded"}
|
return {"status": "ok", "message": "khoj reloaded"}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,4 +255,6 @@ def chat(q: Optional[str] = None):
|
|||||||
conversation_log=meta_log.get("chat", []),
|
conversation_log=meta_log.get("chat", []),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log_telemetry(telemetry_type="api", api="chat", app_config=state.config.app)
|
||||||
|
|
||||||
return {"status": status, "response": gpt_response, "context": compiled_references}
|
return {"status": status, "response": gpt_response, "context": compiled_references}
|
||||||
|
|||||||
Reference in New Issue
Block a user