package ai

import (
	"errors"
	"strings"

	"senlinai-agent/backend/internal/models"
)

type SessionService struct {
}

func NewSessionService() *SessionService {
	return &SessionService{}
}

func (s *SessionService) Create(projectID uint, userID uint, title string) (*models.SenlinAgentAISession, error) {
	title = strings.TrimSpace(title)
	if title == "" {
		return nil, errors.New("session title is required")
	}
	session := &models.SenlinAgentAISession{ProjectID: projectID, CreatedBy: userID, Title: title}
	return session, models.DBService.Create(session).Error
}
