Download rag_agent/graph_state.py from janggi3/ragDumm: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/janggi3/ragDumm/resolve/main/rag_agent/graph_state.py
- Command line
-
hf download hf://spaces/janggi3/ragDumm/rag_agent/graph_state.py
-
curl -L -o graph_state.py https://huggingface.co/spaces/janggi3/ragDumm/resolve/main/rag_agent/graph_state.py
1.01 kB
| from typing import List, Annotated, Set | |
| from langgraph.graph import MessagesState | |
| import operator | |
| def accumulate_or_reset(existing: List[dict], new: List[dict]) -> List[dict]: | |
| if new and any(item.get('__reset__') for item in new): | |
| return [] | |
| return existing + new | |
| def set_union(a: Set[str], b: Set[str]) -> Set[str]: | |
| return a | b | |
| class State(MessagesState): | |
| """State for main agent graph""" | |
| questionIsClear: bool = False | |
| conversation_summary: str = "" | |
| originalQuery: str = "" | |
| rewrittenQuestions: List[str] = [] | |
| agent_answers: Annotated[List[dict], accumulate_or_reset] = [] | |
| class AgentState(MessagesState): | |
| """State for individual agent subgraph""" | |
| question: str = "" | |
| question_index: int = 0 | |
| context_summary: str = "" | |
| retrieval_keys: Annotated[Set[str], set_union] = set() | |
| final_answer: str = "" | |
| agent_answers: List[dict] = [] | |
| tool_call_count: Annotated[int, operator.add] = 0 | |
| iteration_count: Annotated[int, operator.add] = 0 |