INNER CODE UNIT · Python
chat_completions
kaito-project/kaito · presets/ragengine/main.py:387
async def chat_completions(request: dict):
start_time = time.perf_counter()
status = STATUS_FAILURE # Default status
try:
# Check if InferenceService is configured via environment variable
if not os.getenv("LLM_INFERENCE_URL"):
raise HTTPException(
status_code=503,
detail="InferenceService not configured. This RAGEngine instance only supports document retrieve via /retrieve API. To use chat completions, configure an InferenceService in the RAGEngine spec.",
)
guardrails = guardrails_reloader.get_current()
if request.get("tools") or request.get("functions"):
raise HTTPException(
status_code=400,
detail="tools and functions are not supported.",
)
if request.get("n", 1) > 1: