from rest_framework import serializers
from api.models import InferenceAuditLog

class InferenceAuditLogSerializer(serializers.ModelSerializer):
    # แสดงข้อมูล Model และ User ที่เกี่ยวข้อง
    #model_name = serializers.CharField(source='model.name', read_only=True)
    username = serializers.CharField(source='user.username', read_only=True)

    class Meta:
        model = InferenceAuditLog
        fields = (
            'id', 'user', 'username',
            #'model', 'model_name',
            'timestamp', 'http_status', 'latency_ms',
            'is_success', 'response_summary'
        )
        read_only_fields = fields