Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Source/Private/Core/N2CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ UN2CSettings::UN2CSettings()
Anthropic_API_Key_UI = UserSecrets->Anthropic_API_Key;
Gemini_API_Key_UI = UserSecrets->Gemini_API_Key;
DeepSeek_API_Key_UI = UserSecrets->DeepSeek_API_Key;
OpenAICompatible_API_Key_UI = UserSecrets->OpenAICompatible_API_Key;

// Initialize token estimate
EstimatedReferenceTokens = GetReferenceFilesTokenEstimate();
Expand Down Expand Up @@ -80,6 +81,8 @@ FString UN2CSettings::GetActiveApiKey() const
return UserSecrets->Gemini_API_Key;
case EN2CLLMProvider::DeepSeek:
return UserSecrets->DeepSeek_API_Key;
case EN2CLLMProvider::OpenAICompatible:
return UserSecrets->OpenAICompatible_API_Key;
default:
return FString();
}
Expand All @@ -99,6 +102,8 @@ FString UN2CSettings::GetActiveModel() const
return FN2CLLMModelUtils::GetDeepSeekModelValue(DeepSeekModel);
case EN2CLLMProvider::Ollama:
return OllamaModel;
case EN2CLLMProvider::OpenAICompatible:
return OpenAICompatibleModel;
default:
return FString();
}
Expand Down Expand Up @@ -259,6 +264,17 @@ void UN2CSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChanged
UserSecrets->SaveSecrets();
return;
}
if (PropertyName == GET_MEMBER_NAME_CHECKED(UN2CSettings, OpenAICompatible_API_Key_UI))
{
if (!UserSecrets)
{
UserSecrets = NewObject<UN2CUserSecrets>();
UserSecrets->LoadSecrets();
}
UserSecrets->OpenAICompatible_API_Key = OpenAICompatible_API_Key_UI;
UserSecrets->SaveSecrets();
return;
}

// Update logger severity when MinSeverity changes
if (PropertyName == GET_MEMBER_NAME_CHECKED(UN2CSettings, MinSeverity))
Expand Down
6 changes: 4 additions & 2 deletions Source/Private/Core/N2CUserSecrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void UN2CUserSecrets::LoadSecrets()
Anthropic_API_Key = JsonObject->GetStringField(TEXT("Anthropic_API_Key"));
Gemini_API_Key = JsonObject->GetStringField(TEXT("Gemini_API_Key"));
DeepSeek_API_Key = JsonObject->GetStringField(TEXT("DeepSeek_API_Key"));

OpenAICompatible_API_Key = JsonObject->GetStringField(TEXT("OpenAICompatible_API_Key"));

FN2CLogger::Get().Log(
FString::Printf(TEXT("Successfully loaded secrets from: %s"), *SecretsFilePath),
EN2CLogSeverity::Info);
Expand All @@ -88,7 +89,8 @@ void UN2CUserSecrets::SaveSecrets()
JsonObject->SetStringField(TEXT("Anthropic_API_Key"), Anthropic_API_Key);
JsonObject->SetStringField(TEXT("Gemini_API_Key"), Gemini_API_Key);
JsonObject->SetStringField(TEXT("DeepSeek_API_Key"), DeepSeek_API_Key);

JsonObject->SetStringField(TEXT("OpenAICompatible_API_Key"), OpenAICompatible_API_Key);

// Serialize to string
FString JsonString;
TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&JsonString);
Expand Down
4 changes: 3 additions & 1 deletion Source/Private/LLM/N2CLLMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "LLM/Providers/N2CGeminiService.h"
#include "LLM/Providers/N2COpenAIService.h"
#include "LLM/Providers/N2COllamaService.h"
#include "LLM/Providers/N2COpenAICompatibleService.h"
#include "Utils/N2CLogger.h"

UN2CLLMModule* UN2CLLMModule::Get()
Expand Down Expand Up @@ -491,6 +492,7 @@ void UN2CLLMModule::InitializeProviderRegistry()
Registry->RegisterProvider(EN2CLLMProvider::Gemini, UN2CGeminiService::StaticClass());
Registry->RegisterProvider(EN2CLLMProvider::DeepSeek, UN2CDeepSeekService::StaticClass());
Registry->RegisterProvider(EN2CLLMProvider::Ollama, UN2COllamaService::StaticClass());

Registry->RegisterProvider(EN2CLLMProvider::OpenAICompatible, UN2COpenAICompatibleService::StaticClass());

FN2CLogger::Get().Log(TEXT("Provider registry initialized"), EN2CLogSeverity::Info, TEXT("LLMModule"));
}
9 changes: 9 additions & 0 deletions Source/Private/LLM/Providers/N2COpenAICompatibleService.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "LLM/Providers/N2COpenAICompatibleService.h"

#include "Core/N2CSettings.h"

FString UN2COpenAICompatibleService::GetDefaultEndpoint() const
{
const UN2CSettings* Settings = GetDefault<UN2CSettings>();
return Settings->OpenAICompatibleBaseUrl;
}
12 changes: 12 additions & 0 deletions Source/Public/Core/N2CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ class NODETOCODE_API UN2CSettings : public UDeveloperSettings
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Node to Code | LLM Services | Ollama",
meta=(DisplayName="Model Name"))
FString OllamaModel = "qwen2.5-coder:32b";

UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Node to Code | LLM Services | OpenAI Compatible",
meta = (DisplayName = "API Key"))
FString OpenAICompatible_API_Key_UI;

UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Node to Code | LLM Services | OpenAI Compatible",
meta = (DisplayName = "Model Name"))
FString OpenAICompatibleModel;

UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Node to Code | LLM Services | OpenAI Compatible",
meta = (DisplayName = "Base Url"))
FString OpenAICompatibleBaseUrl;

/** OpenAI Model Pricing */
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Node to Code | LLM Services | Pricing | OpenAI", DisplayName = "OpenAI Model Pricing")
Expand Down
4 changes: 4 additions & 0 deletions Source/Public/Core/N2CUserSecrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class NODETOCODE_API UN2CUserSecrets : public UObject
/** DeepSeek API Key */
UPROPERTY(EditAnywhere, Category = "Node to Code | API Keys")
FString DeepSeek_API_Key;

/** OpenAI Compatible API Key */
UPROPERTY(EditAnywhere, Category = "Node to Code | API Keys")
FString OpenAICompatible_API_Key;

private:
/** Ensure the secrets directory exists */
Expand Down
3 changes: 2 additions & 1 deletion Source/Public/LLM/N2CLLMTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ enum class EN2CLLMProvider : uint8
Anthropic UMETA(DisplayName = "Anthropic"),
Gemini UMETA(DisplayName = "Gemini"),
Ollama UMETA(DisplayName = "Ollama"),
DeepSeek UMETA(DisplayName = "DeepSeek")
DeepSeek UMETA(DisplayName = "DeepSeek"),
OpenAICompatible UMETA(DisplayName = "OpenAICompatible")
};

/** Status of the Node to Code system */
Expand Down
29 changes: 29 additions & 0 deletions Source/Public/LLM/Providers/N2COpenAICompatibleService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2025 Nick McClure (Protospatial). All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "LLM/N2CBaseLLMService.h"
#include "N2COpenAIService.h"
#include "N2COpenAICompatibleService.generated.h"

// Forward declarations
class UN2CSystemPromptManager;

/**
* @class UN2COpenAICompatibleService
* @brief Implementation of OpenAI's Chat Completion API integration
*/
UCLASS()
class NODETOCODE_API UN2COpenAICompatibleService : public UN2COpenAIService
{
GENERATED_BODY()

public:
// Provider-specific implementations
virtual EN2CLLMProvider GetProviderType() const override { return EN2CLLMProvider::OpenAICompatible; }

protected:
// Provider-specific implementations
virtual FString GetDefaultEndpoint() const override;
};