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

#include "Primitives/TextEmbedder/InworldTextEmbedderTypes.h"

#include "InworldRuntimeSettings.h"
#include "InworldRuntimeUtils.h"

THIRD_PARTY_INCLUDES_START
#include "InworldRuntimeLibrary/inworld.h"
THIRD_PARTY_INCLUDES_END

DEFINE_LOG_CATEGORY(LogInworldTextEmbedder);

namespace inworld
{

void Convert(const FInworldLocalTextEmbedderCreationConfig& In, inworld::LocalTextEmbedderConfig& Out)
{
#if defined(INWORLD_IMPLEMENTATION)
	inworld::Device device{FInworldRuntimeUtils::GetDevice(
		(In.LocalComputeHost == EInworldLocalComputeHost::CPU) ? inworld::DeviceType::kCPU : inworld::DeviceType::kCUDA)};
	Out.device(&device);
	Out.model_path({TCHAR_TO_UTF8(*GetInworldExtrasPath("embedders", In.Model))});
#endif
}

void Convert(const FInworldRemoteTextEmbedderCreationConfig& In, inworld::RemoteTextEmbedderConfig& Out)
{
#if defined(INWORLD_IMPLEMENTATION)
	Out.api_key({TCHAR_TO_UTF8(*GetInworldRuntimeApiKey())});
	Out.model_name({TCHAR_TO_UTF8(*In.Model)});
	Out.provider({TCHAR_TO_UTF8(*In.Provider)});
#endif
}

}	 // namespace inworld
