fixed linting issues
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,6 @@ from modules.auth.models import User
|
||||
from modules.nlp.service import process_request, ask_ai, save_chat_message, get_chat_history, MessageSender
|
||||
# Import the response schema and the new ChatMessage model for response type hinting
|
||||
from modules.nlp.schemas import ProcessCommandRequest, ProcessCommandResponse
|
||||
from modules.nlp.models import ChatMessage # Import ChatMessage model
|
||||
from modules.calendar.service import create_calendar_event, get_calendar_events, update_calendar_event, delete_calendar_event
|
||||
from modules.calendar.models import CalendarEvent
|
||||
from modules.calendar.schemas import CalendarEventCreate, CalendarEventUpdate
|
||||
@@ -19,7 +18,18 @@ from modules.calendar.schemas import CalendarEventCreate, CalendarEventUpdate
|
||||
from modules.todo import service as todo_service
|
||||
from modules.todo.models import Todo
|
||||
from modules.todo.schemas import TodoCreate, TodoUpdate
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class ChatMessageResponse(BaseModel):
|
||||
id: int
|
||||
sender: MessageSender # Use the enum directly
|
||||
text: str
|
||||
timestamp: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allow Pydantic to work with ORM models
|
||||
|
||||
router = APIRouter(prefix="/nlp", tags=["nlp"])
|
||||
|
||||
# Helper to format calendar events (expects list of CalendarEvent models)
|
||||
@@ -217,20 +227,6 @@ def process_command(request_data: ProcessCommandRequest, current_user: User = De
|
||||
# ----------------------------------
|
||||
return ProcessCommandResponse(responses=[error_response])
|
||||
|
||||
# --- New Endpoint for Chat History ---
|
||||
# Define a Pydantic schema for the response (optional but good practice)
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class ChatMessageResponse(BaseModel):
|
||||
id: int
|
||||
sender: MessageSender # Use the enum directly
|
||||
text: str
|
||||
timestamp: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allow Pydantic to work with ORM models
|
||||
|
||||
@router.get("/history", response_model=List[ChatMessageResponse])
|
||||
def read_chat_history(current_user: User = Depends(get_current_user), db: Session = Depends(get_db)):
|
||||
"""Retrieves the last 50 chat messages for the current user."""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
\
|
||||
# /home/cdp/code/MAIA/backend/modules/nlp/models.py
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy import Column, Integer, Text, DateTime, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
import enum
|
||||
|
||||
Reference in New Issue
Block a user