Agent Tools¶
This page documents the agent tools available to the conversational agents, including the default toolset used when none is specified.
Default Toolset¶
The following tools are enabled by default (from DEFAULT_TOOL_NAMES
):
search_nihai
— Docs: NihAI Searchask_nihai
— Docs: NihAI Ask
Available Tools¶
ask_nihai¶
async def _tool_wrap_nihai_ask(messages: list[dict[str, str]] | None = None, profile: str | None = None, max_results: int = 8, query: str | None = None) -> list[dict]
Parameters:
- messages: Conversation history as a list of objects like {"role": "user"|"assistant", "content": "..."}.
The final user message should contain the question to answer.
- profile: Optional patient profile string (location, age, pregnancy status, etc.).
- max_results: Maximum number of NihAI entries to return after enrichment.
- query: Backward‑compatibility single‑string query. If provided and
messages
is empty, a single user message is synthesized.
Behavior: - If NihAI lacks an answer, the system enriches the knowledge base using Perplexity sources, writes a normalized Q&A entry, then re-queries NihAI.
Guidance:
- This tool can be slower and more resource intensive than search_nihai
and may write to the NihAI knowledge base. Use search_nihai
FIRST, and
only call this if retrieval is insufficient.
Related Search Docs: NihAI Ask
depricate_nihai_faq¶
Mark a NihAI FAQ entry inactive (soft deprecation).search_googlesheet_faqs¶
async def _tool_wrap_googlesheet(query: str, max_results: int = 3, relevance_threshold: float = 0.3) -> list[dict]
search_nihai¶
Direct RAG search against NihAI via HTTP endpoint.Guidance:
- Prefer this tool FIRST when both NihAI tools are available. It is faster
and less resource intensive than ask_nihai
because it performs a
non‑writing retrieval over the existing knowledge base.
- If results are insufficient, then fall back to ask_nihai
.
Off by default. Enable explicitly by including 'search_nihai' in tools list. Related Search Docs: NihAI Search
search_noora_faq¶
Direct RAG search against the Noora FAQ collection.Not enabled by default; callers must include 'search_noora_faq' in tools list. Requires NOORA_FAQ_COLLECTION_NAME env var.
search_perplexity¶
async def _tool_wrap_perplexity(query: str, source_type: str | None = None, medical_category: str | None = None, max_results: int = 5) -> dict
Note: We no longer normalize or restrict source_type
. Any provided value
is passed through to the underlying implementation.
Related Search Docs: Perplexity Med
search_pubmed¶
async def _tool_wrap_pubmed(query: str, max_results: int = 3, email: str | None = None) -> list[dict]
search_september¶
async def _tool_wrap_september(query: str, max_results: int = 3, section_filter: str | None = None) -> list[dict]
write_nihai¶
async def _tool_wrap_nihai_write(question: str, answer: str, references: list[dict] | None = None, condition_area: str | None = None, topic: str | None = None, is_verified: bool = False, approvers: str = '', source: str = 'perplexity', accuracy_confidence: float | None = 0.6) -> dict
Use this only after verifying that no suitable existing entry covers the need.
write_nihai_from_perplexity¶
async def _tool_wrap_nihai_write_from_perplexity(question: str, condition_area: str | None = None, topic: str | None = None, max_tokens: int = 220) -> dict
Requirements: - question: Must be written in English. If the user's input is not English, the agent MUST rewrite the question to English before calling this tool. - The answer will also be stored in English.
Source: agents/tools.py