/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */

#pragma once

#include "CoreMinimal.h"
#include "Graph/InworldNode.h"
#include "Primitives/TextClassifier/InworldTextClassifierTypes.h"

#include "InworldNode_TextClassifier.generated.h"

/**
 * @class UInworldNode_TextClassifier
 * @brief A node that classifies text content into categories.
 *
 * This node takes text input and classifies it into configured categories.
 * It can be used for various purposes such as content categorization, sentiment
 * analysis, topic detection, or any other classification task.
 * It inherits from TypedNode with ClassificationResult as output and Text as
 * input.
 *
 * @input FInworldData_Text
 * @output FInworldData_ClassificationResult
 */
UCLASS()
class INWORLDRUNTIME_API UInworldNode_TextClassifier : public UInworldNode
{
	GENERATED_BODY()

public:
	/**
	 * @brief Default constructor for the text classifier node.
	 *
	 * Initializes the node with default settings for text classification operations.
	 */
	UInworldNode_TextClassifier();

	/** Configuration settings for text classifier creation including compute host and model selection */
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Inworld",
		Meta = (ToolTip = "Configuration settings for text classifier creation including compute host and model selection"))
	FInworldTextClassifierNodeCreationConfig CreationConfig{};

	/** Configuration settings for text classifier execution including classification categories and thresholds */
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Inworld",
		Meta =
			(ToolTip = "Configuration settings for text classifier execution including classification categories and thresholds"))
	FInworldTextClassifierNodeExecutionConfig ExecutionConfig{};

private:
	/**
	 * @brief Generates JSON configuration for the text classifier node.
	 *
	 * This override generates the JSON configuration needed for the text classifier node's
	 * processing operations, including creation config (compute host, model selection)
	 * and execution config (classification categories, thresholds, and filtering options).
	 *
	 * @param GraphJson The JSON object to populate with the node's configuration data
	 * @return Error code indicating success or failure of configuration generation
	 */
	virtual EInworldRuntimeErrors GetJsonConfig(const TSharedRef<FJsonObject>& GraphJson) override;

	/**
	 * @brief Processes text input to classify it into configured categories.
	 *
	 * This function analyzes the input text using the configured classification model
	 * to determine which categories or labels apply to the content. The classification
	 * can be used for content filtering, sentiment analysis, topic detection, safety
	 * checks, or any other categorization task.
	 *
	 * @param Text The input text to classify into categories
	 * @return Classification result containing category matches with confidence scores
	 */
	UFUNCTION()
	UPARAM(meta = (DisplayName = "Classification"))
	FInworldData_ClassificationResult Process_Text(const FInworldData_Text& Text)
	{
		checkNoEntry();
		return {};
	}
};
