async def chat_with_preprocessing(query: str, user_id: str) -> ChatResponse:
# Clean the query
clean_query = query.strip()
# Add user context
enriched = f"[User tier: premium] {clean_query}"
# Pass pre-processed standalone question to skip LLM reformulation
raw = await lc.engine.chat(
query=clean_query,
user_id=user_id,
standalone_question=enriched,
)
return ChatResponse(
text=raw["response"],
user_id=raw["user_id"],
platform="web",
status=raw["status"],
response_time=raw["response_time"],
timestamp=raw["timestamp"],
error=raw.get("error"),
)