flowmarg / agent /rag_chat.py
akash
Deploy to Hugging Face (source code only, no binary files)
2379054
Raw History Blame Contribute Delete
849 Bytes
"""RAG chat helpers used by the engineering assistant."""
from typing import Any, List
from agent.local_agent import get_or_create_agent
def query_rag(query: str, project_name: str = "", n_results: int = 3) -> List[Any]:
"""Query project ChromaDB if available; otherwise return an empty list."""
try:
from core.chroma_project import query_project_rag
return query_project_rag(query, project_name, n_results=n_results) or []
except Exception:
return []
def chat(session_state, question: str) -> str:
"""Answer an engineering question using the local agent."""
agent = get_or_create_agent(session_state)
if hasattr(agent, "process_query"):
return agent.process_query(question)
if hasattr(agent, "process"):
return agent.process(question)
return "Agent is not available."