package ai

import (
	"context"

	"haixun-backend/internal/model/ai/domain/enum"
	aiuc "haixun-backend/internal/model/ai/domain/usecase"
	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"
)

type ListAIProviderModelsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListAIProviderModelsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAIProviderModelsLogic {
	return &ListAIProviderModelsLogic{ctx: ctx, svcCtx: svcCtx}
}

func (l *ListAIProviderModelsLogic) ListAIProviderModels(req *types.AIProviderPath, token string) (*types.AIProviderModelsData, error) {
	result := l.svcCtx.AI.ListProviderModels(l.ctx, enum.ProviderID(req.Provider), aiuc.Credential{APIKey: token})
	return &types.AIProviderModelsData{
		ID:      result.ID,
		Label:   result.Label,
		Models:  result.Models,
		Streams: result.Streams,
		Error:   result.Error,
	}, nil
}
