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
4 changes: 2 additions & 2 deletions Source/Private/Core/N2CSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ bool FN2CSerializer::ParseFlowsFromJson(const TSharedPtr<FJsonObject>& JsonObjec
{
if (DataFlow.Value->Type == EJson::String)
{
OutFlows.Data.Add(DataFlow.Key, DataFlow.Value->AsString());
OutFlows.Data.Add(FString(DataFlow.Key.ToView()), DataFlow.Value->AsString());
}
}

Expand Down Expand Up @@ -921,4 +921,4 @@ bool FN2CSerializer::ParseEnumFromJson(const TSharedPtr<FJsonObject>& JsonObject
}

return true;
}
}
14 changes: 14 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;
OllamaConfig.ApiKey = UserSecrets->Ollama_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::Ollama:
return UserSecrets->Ollama_API_Key;
case EN2CLLMProvider::LMStudio:
return "lm-studio"; // LM Studio just requires a dummy API key for its OpenAI endpoint
default:
Expand Down Expand Up @@ -269,6 +272,17 @@ void UN2CSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChanged
UserSecrets->SaveSecrets();
return;
}
if (PropertyName == GET_MEMBER_NAME_CHECKED(FN2COllamaConfig, ApiKey))
{
if (!UserSecrets)
{
UserSecrets = NewObject<UN2CUserSecrets>();
UserSecrets->LoadSecrets();
}
UserSecrets->Ollama_API_Key = OllamaConfig.ApiKey;
UserSecrets->SaveSecrets();
return;
}

// Update logger severity when MinSeverity changes
if (PropertyName == GET_MEMBER_NAME_CHECKED(UN2CSettings, MinSeverity))
Expand Down
2 changes: 2 additions & 0 deletions Source/Private/Core/N2CUserSecrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ 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"));
JsonObject->TryGetStringField(TEXT("Ollama_API_Key"), Ollama_API_Key);

FN2CLogger::Get().Log(
FString::Printf(TEXT("Successfully loaded secrets from: %s"), *SecretsFilePath),
Expand All @@ -88,6 +89,7 @@ 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("Ollama_API_Key"), Ollama_API_Key);

// Serialize to string
FString JsonString;
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;

/** Ollama API Key */
UPROPERTY(EditAnywhere, Category = "Node to Code | API Keys")
FString Ollama_API_Key;

private:
/** Ensure the secrets directory exists */
Expand Down
6 changes: 6 additions & 0 deletions Source/Public/LLM/N2COllamaConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ struct FN2COllamaConfig
ToolTip="The base endpoint to use for the Ollama API. Defaults to http:localhost:11434"))
FString OllamaEndpoint = "http://localhost:11434";

/** Optional API key for authenticated Ollama endpoints such as Ollama Cloud. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category = "Cloud",
meta=(DisplayName="API Key", PasswordField=true,
ToolTip="API key for authenticated Ollama endpoints such as Ollama Cloud. Leave empty for local Ollama servers."))
FString ApiKey;

/** Whether to use system prompts with Ollama models */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "General",
meta=(DisplayName="Use System Prompts",
Expand Down