mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Log usage of /search, /chat, /update API endpoints to telemetry server
This commit is contained in:
parent
f2e89f6f46
commit
3ede919c66
1 changed files with 7 additions and 1 deletions
|
@ -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.utils import message_to_log, message_to_prompt
|
||||
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.state import SearchType
|
||||
from khoj.utils import state, constants
|
||||
|
@ -168,6 +168,8 @@ def search(
|
|||
# Cache results
|
||||
state.query_cache[query_cache_key] = results
|
||||
|
||||
log_telemetry(telemetry_type="api", api="search", app_config=state.config.app)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
@ -191,6 +193,8 @@ def update(t: Optional[SearchType] = None, force: Optional[bool] = False):
|
|||
else:
|
||||
logger.info("📬 Processor reconfigured via API")
|
||||
|
||||
log_telemetry(telemetry_type="api", api="update", app_config=state.config.app)
|
||||
|
||||
return {"status": "ok", "message": "khoj reloaded"}
|
||||
|
||||
|
||||
|
@ -251,4 +255,6 @@ def chat(q: Optional[str] = None):
|
|||
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}
|
||||
|
|
Loading…
Reference in a new issue