50 lines
1.7 KiB
Go
50 lines
1.7 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type ChatMessage struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
UserID uint `gorm:"not null" json:"user_id"`
|
|
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
Message string `gorm:"type:text;not null" json:"message"`
|
|
Response string `gorm:"type:text;not null" json:"response"`
|
|
ContextData string `gorm:"type:json" json:"context_data"`
|
|
Intent string `gorm:"type:varchar(50)" json:"intent"`
|
|
ConfidenceScore float64 `gorm:"type:decimal(5,2);default:0.00" json:"confidence_score"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (ChatMessage) TableName() string {
|
|
return "chat_messages"
|
|
}
|
|
|
|
// Intent types
|
|
const (
|
|
IntentSearchItem = "search_item"
|
|
IntentReportLost = "report_lost"
|
|
IntentClaimHelp = "claim_help"
|
|
IntentGeneral = "general"
|
|
IntentRecommendItem = "recommend_item"
|
|
)
|
|
|
|
type ChatMessageResponse struct {
|
|
ID uint `json:"id"`
|
|
Message string `json:"message"`
|
|
Response string `json:"response"`
|
|
Intent string `json:"intent"`
|
|
ConfidenceScore float64 `json:"confidence_score"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (c *ChatMessage) ToResponse() ChatMessageResponse {
|
|
return ChatMessageResponse{
|
|
ID: c.ID,
|
|
Message: c.Message,
|
|
Response: c.Response,
|
|
Intent: c.Intent,
|
|
ConfidenceScore: c.ConfidenceScore,
|
|
CreatedAt: c.CreatedAt,
|
|
}
|
|
} |