Cortex (Inference)

View as Markdown

The current UE plugin exposes both local node-backed cortex helpers and remote API-backed cortex helpers.

Local Cortex

Local inference is driven by Cortex/CortexThunks.h and currently loads a model from a file path.

1#include "RuntimeStore.h"
2#include "CLI/CliOperations.h"
3
4auto Store = createSDKStore();
5
6FCortexStatus Local = SDKOps::InitCortex(
7 Store,
8 TEXT("smollm2-135m"));
9
10FCortexResponse Response =
11 SDKOps::CompleteCortex(Store, TEXT("Write one short sentence."));

Important points:

  • InitCortex takes a model ID (e.g. smollm2-135m) which maps to a HuggingFace GGUF URL — the SDK downloads it automatically on first use to {ProjectSavedDir}/ForbocAI/models/
  • You can also pass a direct file path to a .gguf model
  • Local completion uses the currently initialized llama.cpp context (Metal GPU on Mac)
  • GenerateEmbedding is also available through SDKOps::GenerateEmbedding(...) — the embedding model (all-MiniLM-L6-v2) is also downloaded automatically on first use

Remote Cortex

1#include "RuntimeStore.h"
2#include "CLI/CliOperations.h"
3#include "RuntimeConfig.h"
4
5auto Store = createSDKStore();
6SDKConfig::SetApiConfig(TEXT("https://api.forboc.ai"), ApiKey);
7
8TArray<FCortexModelInfo> Models = SDKOps::ListCortexModels(Store);
9FCortexStatus Remote = SDKOps::InitRemoteCortex(Store, TEXT("api-integrated"));
10FCortexResponse RemoteResp =
11 SDKOps::CompleteRemoteCortex(Store, Remote.Id, TEXT("Summarize this."));

Protocol Requirement

rtk::processNPC(...) with rtk::LocalProtocolRuntime() uses local cortex for ExecuteInference instructions. Remote fallback is intentionally disabled in that path.

If local cortex is not initialized and the API requests inference, processNPC(...) fails fast.

Key Types

  • FCortexStatus
  • FCortexConfig
  • FCortexResponse
  • FCortexModelInfo

FCortexConfig also supports optional stop sequences and a JSON schema payload for remote completion requests.