def answer_with_guardrails(query, search_results):
if not search_results or max_relevance_score(search_results) < 0.3:
return {
"answer": "I don't have information about that in our knowledge base.",
"confidence": "low",
"action": "Suggest alternative sources"
}
return generate_answer(query, search_results,
instruction="ONLY use the provided documents. "
"If the answer isn't in the documents, say so.")