File size: 1,530 Bytes
481dfe6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | from langchain_core.tools import tool
from app.retrieval.retriever import retrieve_and_rerank
@tool
def qdrant_retrieval_tool(query: str) -> list[dict]:
"""Search the ACPC Gujarat knowledge base for information about admissions,
eligibility criteria, important dates, required documents, counseling process,
seat allotment, fees, merit lists, and related topics.
Args:
query: A search query about ACPC Gujarat admissions.
Returns:
List of relevant document chunks with metadata (text, file_name, url, score).
"""
documents = retrieve_and_rerank(query)
results = []
for i, doc in enumerate(documents):
meta = doc.metadata or {}
results.append(
{
"rank": i + 1,
"text": doc.page_content,
"file_name": meta.get("file_name", ""),
"url": meta.get("url", meta.get("page_id", "")),
"score": float(meta.get("relevance_score", 0.0)),
}
)
return results
@tool
def get_current_date_tool() -> str:
"""Get the current date and time in IST (Indian Standard Time).
Useful for comparing against ACPC admission deadlines and important dates.
Returns:
Current date/time as a string (e.g. '03 April 2026, 14:30 IST').
"""
from datetime import datetime
import pytz
ist = pytz.timezone("Asia/Kolkata")
now = datetime.now(ist)
return now.strftime("%d %B %Y, %H:%M IST")
|