acpcchatbotadmin's picture
Upload 40 files
481dfe6 verified
Raw History Blame Contribute Delete
1.53 kB
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")