Download agent/rag_chat.py from Surajnitp/flowmarg: direct link, hf CLI and curl.
- Browser
- Download file 849 Bytes
-
https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/agent/rag_chat.py
- Command line
-
hf download hf://spaces/Surajnitp/flowmarg/agent/rag_chat.py
-
curl -L -o rag_chat.py https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/agent/rag_chat.py
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." | |