- Added `transcription_service.py` to handle audio transcription via Whisper API. - Integrated logging for transcription processes and error handling. - Supported audio format checks based on configuration settings. docs: Create Ordre System Implementation Plan - Drafted comprehensive implementation plan for e-conomic order integration. - Outlined business requirements, database changes, backend and frontend implementation details. - Included testing plan and deployment steps for the new order system. feat: Add AI prompts and regex action capabilities - Created `ai_prompts` table for storing custom AI prompts. - Added regex extraction and linking action to email workflow actions. feat: Introduce conversations module for transcribed audio - Created `conversations` table to store transcribed conversations with relevant metadata. - Added indexing for customer, ticket, and user linkage. - Implemented full-text search capabilities for Danish language. fix: Add category column to conversations for classification - Added `category` column to `conversations` table for better conversation classification.
142 lines
3.5 KiB
Python
142 lines
3.5 KiB
Python
"""
|
|
Pydantic Models and Schemas
|
|
"""
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class CustomerBase(BaseModel):
|
|
"""Base customer schema"""
|
|
name: str
|
|
email: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
address: Optional[str] = None
|
|
|
|
|
|
class CustomerCreate(CustomerBase):
|
|
"""Schema for creating a customer"""
|
|
pass
|
|
|
|
|
|
class CustomerUpdate(BaseModel):
|
|
"""Schema for updating a customer"""
|
|
name: Optional[str] = None
|
|
email: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
address: Optional[str] = None
|
|
cvr_number: Optional[str] = None
|
|
city: Optional[str] = None
|
|
postal_code: Optional[str] = None
|
|
country: Optional[str] = None
|
|
website: Optional[str] = None
|
|
mobile_phone: Optional[str] = None
|
|
invoice_email: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class Customer(CustomerBase):
|
|
"""Full customer schema"""
|
|
id: int
|
|
created_at: str # Changed from datetime to str for serialization
|
|
updated_at: Optional[str] = None # Changed from datetime to str for serialization
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class HardwareBase(BaseModel):
|
|
"""Base hardware schema"""
|
|
serial_number: str
|
|
model: str
|
|
customer_id: int
|
|
|
|
|
|
class HardwareCreate(HardwareBase):
|
|
"""Schema for creating hardware"""
|
|
pass
|
|
|
|
|
|
class Hardware(HardwareBase):
|
|
"""Full hardware schema"""
|
|
id: int
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class VendorBase(BaseModel):
|
|
"""Base vendor schema"""
|
|
name: str
|
|
cvr_number: Optional[str] = None
|
|
domain: Optional[str] = None
|
|
email: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
contact_person: Optional[str] = None
|
|
category: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
|
|
|
|
class VendorCreate(VendorBase):
|
|
"""Schema for creating a vendor"""
|
|
pass
|
|
|
|
|
|
class VendorUpdate(BaseModel):
|
|
"""Schema for updating a vendor"""
|
|
name: Optional[str] = None
|
|
cvr_number: Optional[str] = None
|
|
domain: Optional[str] = None
|
|
email: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
contact_person: Optional[str] = None
|
|
category: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class Vendor(VendorBase):
|
|
"""Full vendor schema"""
|
|
id: int
|
|
is_active: bool = True
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class ConversationBase(BaseModel):
|
|
title: str
|
|
transcript: Optional[str] = None
|
|
summary: Optional[str] = None
|
|
is_private: bool = False
|
|
customer_id: Optional[int] = None
|
|
ticket_id: Optional[int] = None
|
|
category: str = "General"
|
|
|
|
class ConversationCreate(ConversationBase):
|
|
audio_file_path: str
|
|
duration_seconds: int = 0
|
|
email_message_id: Optional[int] = None
|
|
|
|
class ConversationUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
is_private: Optional[bool] = None
|
|
ticket_id: Optional[int] = None
|
|
customer_id: Optional[int] = None
|
|
category: Optional[str] = None
|
|
# For soft delete via update if needed, though usually strict API endpoint
|
|
|
|
class Conversation(ConversationBase):
|
|
id: int
|
|
audio_file_path: str
|
|
duration_seconds: int
|
|
user_id: Optional[int] = None
|
|
source: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
deleted_at: Optional[datetime] = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|