presenton/servers/fastapi/api/v1/ppt/endpoints/chat.py
sudipnext efd69cc134 Add chat functionality to FastAPI presentation service
- Introduced a new chat endpoint for handling user messages and generating responses.
- Added models for chat message requests and responses.
- Implemented a conversation store to manage chat history.
- Integrated memory layer for retrieving presentation context.
- Created tools for accessing presentation outlines and searching slides.
- Updated dependencies to include jsonschema for validation.
- Enhanced the API router to include the new chat functionality.
2026-04-24 09:34:56 +05:45

26 lines
892 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from models.chat import ChatMessageRequest, ChatMessageResponse
from services.chat import PresentationChatService
from services.database import get_async_session
CHAT_ROUTER = APIRouter(prefix="/chat", tags=["Chat"])
@CHAT_ROUTER.post("/message", response_model=ChatMessageResponse)
async def chat_message(
payload: ChatMessageRequest,
sql_session: AsyncSession = Depends(get_async_session),
):
service = PresentationChatService(
sql_session=sql_session,
presentation_id=payload.presentation_id,
conversation_id=payload.conversation_id,
)
result = await service.generate_reply(payload.message)
return ChatMessageResponse(
conversation_id=result.conversation_id,
response=result.response_text,
tool_calls=result.tool_calls,
)