evo-ai/src/schemas/chat.py

69 lines
4.1 KiB
Python

"""
┌──────────────────────────────────────────────────────────────────────────────┐
│ @author: Davidson Gomes │
│ @file: chat.py │
│ Developed by: Davidson Gomes │
│ Creation date: May 13, 2025 │
│ Contact: contato@evolution-api.com │
├──────────────────────────────────────────────────────────────────────────────┤
│ @copyright © Evolution API 2025. All rights reserved. │
│ Licensed under the Apache License, Version 2.0 │
│ │
│ You may not use this file except in compliance with the License. │
│ You may obtain a copy of the License at │
│ │
│ http://www.apache.org/licenses/LICENSE-2.0 │
│ │
│ Unless required by applicable law or agreed to in writing, software │
│ distributed under the License is distributed on an "AS IS" BASIS, │
│ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │
│ See the License for the specific language governing permissions and │
│ limitations under the License. │
├──────────────────────────────────────────────────────────────────────────────┤
│ @important │
│ For any future changes to the code in this file, it is recommended to │
│ include, together with the modification, the information of the developer │
│ who changed it and the date of modification. │
└──────────────────────────────────────────────────────────────────────────────┘
"""
from pydantic import BaseModel, Field, validator
from typing import Dict, List, Optional, Any
from datetime import datetime
class FileData(BaseModel):
"""Model to represent file data sent in a chat request."""
filename: str = Field(..., description="File name")
content_type: str = Field(..., description="File content type")
data: str = Field(..., description="File content encoded in base64")
class ChatRequest(BaseModel):
"""Model to represent a chat request."""
agent_id: str = Field(..., description="Agent ID to process the message")
external_id: str = Field(..., description="External ID for user identification")
message: str = Field(..., description="User message to the agent")
files: Optional[List[FileData]] = Field(
None, description="List of files attached to the message"
)
class ChatResponse(BaseModel):
"""Model to represent a chat response."""
response: str = Field(..., description="Response generated by the agent")
message_history: List[Dict[str, Any]] = Field(
default_factory=list, description="Message history"
)
status: str = Field(..., description="Response status (success/error)")
timestamp: str = Field(..., description="Response timestamp")
class ErrorResponse(BaseModel):
"""Model to represent an error response."""
detail: str = Field(..., description="Error details")