SurfSense/surfsense_backend/app/schemas/chats.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

70 lines
1.4 KiB
Python

from typing import Any
from pydantic import BaseModel, ConfigDict
from app.db import ChatType
from .base import IDModel, TimestampModel
class ChatBase(BaseModel):
type: ChatType
title: str
initial_connectors: list[str] | None = None
messages: list[Any]
search_space_id: int
class ChatBaseWithoutMessages(BaseModel):
type: ChatType
title: str
search_space_id: int
class ClientAttachment(BaseModel):
name: str
content_type: str
url: str
class ToolInvocation(BaseModel):
tool_call_id: str
tool_name: str
args: dict
result: dict
# class ClientMessage(BaseModel):
# role: str
# content: str
# experimental_attachments: Optional[List[ClientAttachment]] = None
# toolInvocations: Optional[List[ToolInvocation]] = None
class AISDKChatRequest(BaseModel):
messages: list[Any]
data: dict[str, Any] | None = None
@property
def alison_enabled(self) -> bool:
return self.data.get("alison_enabled", False) if self.data else False
@property
def user_role(self) -> str:
return self.data.get("user_role", "professor") if self.data else "professor"
class ChatCreate(ChatBase):
pass
class ChatUpdate(ChatBase):
pass
class ChatRead(ChatBase, IDModel, TimestampModel):
model_config = ConfigDict(from_attributes=True)
class ChatReadWithoutMessages(ChatBaseWithoutMessages, IDModel, TimestampModel):
model_config = ConfigDict(from_attributes=True)