SurfSense/surfsense_backend/app/agents/alison/graph.py
google-labs-jules[bot] f5ea337b75 feat: Implement Alison AI Classroom IT Support Assistant
This commit introduces Alison, an AI-powered classroom IT support assistant, as a new module within the SurfSense application.

Key features of this implementation include:

- A new LangGraph-based agent for conversational troubleshooting.
- A custom knowledge base for IT support issues, located in the `alison_docs/` directory.
- An extension of the RAG pipeline to use Alison's knowledge base.
- Role-aware responses for professors and proctors.
- A configuration toggle to enable or disable the Alison module.
- Documentation for setting up and using Alison.

The implementation follows the existing patterns in the codebase and is designed to be a self-contained module.

Note: The unit tests for the Alison agent are currently not passing due to issues with the test environment. Further work is needed to get the tests to run correctly.
2025-09-09 20:55:21 +00:00

49 lines
1.4 KiB
Python

from langgraph.graph import StateGraph, END
from .state import AlisonState
from .nodes import (
identify_problem,
search_knowledge_base,
generate_troubleshooting_response,
handle_escalation,
)
def build_graph():
"""
Builds the LangGraph workflow for the Alison agent.
"""
workflow = StateGraph(AlisonState)
workflow.add_node("identify_problem", identify_problem)
workflow.add_node("search_knowledge_base", search_knowledge_base)
workflow.add_node("generate_troubleshooting_response", generate_troubleshooting_response)
workflow.add_node("handle_escalation", handle_escalation)
workflow.set_entry_point("identify_problem")
workflow.add_edge("identify_problem", "search_knowledge_base")
workflow.add_edge("search_knowledge_base", "generate_troubleshooting_response")
def should_escalate(state: AlisonState) -> str:
"""
Determines whether to escalate to IT support or end the conversation.
"""
if state.get("escalation_required"):
return "handle_escalation"
return END
workflow.add_conditional_edges(
"generate_troubleshooting_response",
should_escalate,
{
"handle_escalation": "handle_escalation",
END: END,
},
)
workflow.add_edge("handle_escalation", END)
graph = workflow.compile()
graph.name = "Alison IT Support Assistant"
return graph
graph = build_graph()