| from src.agents.CallState import CallState | |
| class Router: | |
| def __call__(self, state: CallState) -> str: | |
| """Invokes above agents accordingly.""" | |
| if state.get("metadata", {}).get("intake_error"): | |
| return "end" | |
| file_type = state["file_type"] | |
| if file_type in ["mp3", "wav"] and not state.get("content"): | |
| return "transcribe" | |
| return "summarize" | |
| class PostSummarizeRouter: | |
| def __call__(self, state: CallState) -> str: | |
| """Routes based on model output quality.""" | |
| if state.get("metadata", {}).get("intake_error"): | |
| return "end" | |
| text = state.get("clean_content") or state.get("content") or "" | |
| if len(text.strip()) < 40: | |
| return "end" | |
| if not (state.get("summary") or "").strip(): | |
| return "end" | |
| return "score" | |