Skip to content

Class UTryllSubsystem

ClassList > UTryllSubsystem

More...

  • #include <TryllSubsystem.h>

Inherits the following classes: UGameInstanceSubsystem, FTickableGameObject

Classes

Type Name
struct FEmbeddedStorageInfo

Public Types

Type Name
typedef void(FEmbeddedStorageInfo, FTryllError) FTryllOnEmbeddedStorageCreated
typedef void(FTryllError) FTryllOnEmbeddedStorageDestroyed
typedef void(FTryllError) FTryllOnStringStorage

Public Attributes

Type Name
FOnTryllAgentDestroyed OnAgentDestroyed
FOnTryllConfigureSession OnConfigureSessionComplete
FOnTryllConnectionChanged OnConnectionChanged
FOnTryllCreateEmbeddedStringStorage OnCreateEmbeddedStringStorageComplete
FOnTryllCreateStringStorage OnCreateStringStorageComplete
FOnTryllDestroyEmbeddedStringStorage OnDestroyEmbeddedStringStorageComplete
FOnTryllDestroyStringStorage OnDestroyStringStorageComplete
FOnTryllDownloadComplete OnDownloadComplete
FOnTryllDownloadProgress OnDownloadProgress
FOnTryllError OnError
FOnTryllListModels OnListModelsComplete
FOnTryllLoadModel OnLoadModelComplete
FOnTryllModelReady OnModelReady
FOnTryllToolCall OnToolCall
FOnTryllUnloadModel OnUnloadModelComplete

Public Functions

Type Name
void ConfigureSession (ETryllInferenceEngine Engine, bool bAllowAutoModelDownloading=false)
void Connect ()
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams (FOnTryllCreateEmbeddedStringStorage, const FString &, Name, int32, RecordCount, bool, bSuccess)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (FOnTryllCreateStringStorage, const FString &, Name, bool, bSuccess)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (FOnTryllDestroyStringStorage, const FString &, Name, bool, bSuccess)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (FOnTryllDestroyEmbeddedStringStorage, const FString &, Name, bool, bSuccess)
virtual void Deinitialize () override
void Disconnect ()
int64 GetSessionId () const
virtual TStatId GetStatId () override const
virtual ETickableTickType GetTickableTickType () override const
virtual void Initialize (FSubsystemCollectionBase & Collection) override
bool IsConnected () const
virtual bool IsTickable () override const
virtual bool IsTickableInEditor () override const
virtual bool IsTickableWhenPaused () override const
void RegisterAgent (std::uint64_t AgentId, TWeakPtr< FTryllAgent > Agent)
void RequestCreateAgent (const FTryllGraphDescription & Graph, TFunction< FTryllOnAgentCreated > OnComplete, bool bEnableDiagnostics=false)
void RequestCreateEmbeddedStringStorage (const FString & Name, const FString & ConfigPath, const FString & EmbeddingModel=FString{}, TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr)
void RequestCreateEmbeddedStringStorageFromStrings (const FString & Name, const TArray< FString > & Strings, const FString & EmbeddingModel, TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr)
void RequestCreateStringStorage (const FString & Name, const TArray< FString > & Strings, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestCreateStringStorageFromFile (const FString & Name, const FString & FilePath, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestDestroyAgent (TSharedPtr< FTryllAgent > Agent)
void RequestDestroyEmbeddedStringStorage (const FString & Name, TFunction< FTryllOnEmbeddedStorageDestroyed > OnComplete=nullptr)
void RequestDestroyStringStorage (const FString & Name, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestDownloadModel (const FString & ModelName)
void RequestListModels (TFunction< FTryllOnListModels > OnComplete)
void RequestLoadModel (const FString & ModelName)
void RequestModel (const FString & ModelName)
void RequestUnloadModel (const FString & ModelName)
virtual void Tick (float DeltaTime) override
UPROPERTY (EditAnywhere, BlueprintReadWrite, Category="Tryll|Connection", meta=(ToolTip="Host name or IP address of the Tryll server (default: 127.0.0.1)."))
UPROPERTY (EditAnywhere, BlueprintReadWrite, Category="Tryll|Connection", meta=(ToolTip="TCP port the Tryll server is listening on (default: 9100).", ClampMin="1", ClampMax="65535"))
void UnregisterAgent (std::uint64_t AgentId)

Detailed Description

Game-instance subsystem: one TCP session to the Tryll server. Manages the socket connection on a background thread (FTryllConnection) and drains the event queue on Tick(), dispatching to registered agents and delegates.

Lifecycle (game-thread, event-driven): * Connect() — open TCP session to ServerHost:ServerPort. * OnConnectionChanged(bConnected=true) — bind this to continue; or poll IsConnected(). * ConfigureSession(Engine) — select the inference engine for this session. Completion arrives on OnConfigureSessionComplete. * CreateAgent — either attach a UTryllAgentComponent (which calls RequestCreateAgent under the hood when bAutoCreateOnConnect is true) or invoke RequestCreateAgent() directly with a graph. On success the callback gets a TSharedPtr<FTryllAgent>. * SendMessage(Text) — drive one turn through the agent. Streaming chunks arrive on OnAnswerText; the turn ends with OnTurnComplete(Status). * RequestDestroyAgent / Disconnect — tear down when done.

All delegates fire on the game thread from Tick(); it is safe to touch UObjects and UI directly from callbacks.

Usage: UTryllSubsystem* Tryll = GetGameInstance()->GetSubsystem<UTryllSubsystem>(); Tryll->Connect(); // Bind OnConnectionChanged to ConfigureSession, then CreateAgent, then SendMessage.

Public Types Documentation

typedef FTryllOnEmbeddedStorageCreated

using UTryllSubsystem::FTryllOnEmbeddedStorageCreated = void(FEmbeddedStorageInfo, FTryllError);

typedef FTryllOnEmbeddedStorageDestroyed

using UTryllSubsystem::FTryllOnEmbeddedStorageDestroyed = void(FTryllError);

typedef FTryllOnStringStorage

using UTryllSubsystem::FTryllOnStringStorage = void(FTryllError);

Public Attributes Documentation

variable OnAgentDestroyed

FOnTryllAgentDestroyed UTryllSubsystem::OnAgentDestroyed;

variable OnConfigureSessionComplete

FOnTryllConfigureSession UTryllSubsystem::OnConfigureSessionComplete;

variable OnConnectionChanged

FOnTryllConnectionChanged UTryllSubsystem::OnConnectionChanged;

variable OnCreateEmbeddedStringStorageComplete

FOnTryllCreateEmbeddedStringStorage UTryllSubsystem::OnCreateEmbeddedStringStorageComplete;

variable OnCreateStringStorageComplete

FOnTryllCreateStringStorage UTryllSubsystem::OnCreateStringStorageComplete;

variable OnDestroyEmbeddedStringStorageComplete

FOnTryllDestroyEmbeddedStringStorage UTryllSubsystem::OnDestroyEmbeddedStringStorageComplete;

variable OnDestroyStringStorageComplete

FOnTryllDestroyStringStorage UTryllSubsystem::OnDestroyStringStorageComplete;

variable OnDownloadComplete

FOnTryllDownloadComplete UTryllSubsystem::OnDownloadComplete;

variable OnDownloadProgress

FOnTryllDownloadProgress UTryllSubsystem::OnDownloadProgress;

variable OnError

FOnTryllError UTryllSubsystem::OnError;

variable OnListModelsComplete

FOnTryllListModels UTryllSubsystem::OnListModelsComplete;

variable OnLoadModelComplete

FOnTryllLoadModel UTryllSubsystem::OnLoadModelComplete;

variable OnModelReady

FOnTryllModelReady UTryllSubsystem::OnModelReady;

Fired when a RequestModel sequence terminates (load succeeded, or fallback download+load succeeded, or any step failed). bSuccess is the final outcome.


variable OnToolCall

FOnTryllToolCall UTryllSubsystem::OnToolCall;

Broadcast when a ToolCallNode detects a tool call with notify_client enabled.


variable OnUnloadModelComplete

FOnTryllUnloadModel UTryllSubsystem::OnUnloadModelComplete;

Public Functions Documentation

function ConfigureSession

void UTryllSubsystem::ConfigureSession (
    ETryllInferenceEngine Engine,
    bool bAllowAutoModelDownloading=false
) 

Send ConfigureSessionRequest. Must be called after Connected and before CreateAgent. Result is delivered via OnConfigureSessionComplete delegate.

Parameters:

  • Engine Inference backend to use for this session.
  • bAllowAutoModelDownloading When true, CreateAgent automatically downloads any missing models referenced by the graph instead of failing immediately. Intended for development and prototyping only. Pass UTryllRuntimeSettings::bAllowAutoModelDownloading to drive this from the project settings asset.

function Connect

void UTryllSubsystem::Connect () 

Open a TCP session to ServerHost:ServerPort. Asynchronous — completion is reported via OnConnectionChanged(bConnected=true). Errors fire OnError. Calling Connect() while already connected is a no-op.


function DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams

UTryllSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams (
    FOnTryllCreateEmbeddedStringStorage,
    const FString &,
    Name,
    int32,
    RecordCount,
    bool,
    bSuccess
) 

function DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams [1/3]

UTryllSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (
    FOnTryllCreateStringStorage,
    const FString &,
    Name,
    bool,
    bSuccess
) 

function DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams [2/3]

UTryllSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (
    FOnTryllDestroyStringStorage,
    const FString &,
    Name,
    bool,
    bSuccess
) 

function DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams [3/3]

UTryllSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (
    FOnTryllDestroyEmbeddedStringStorage,
    const FString &,
    Name,
    bool,
    bSuccess
) 

function Deinitialize

virtual void UTryllSubsystem::Deinitialize () override

function Disconnect

void UTryllSubsystem::Disconnect () 

Close the active session. OnConnectionChanged(bConnected=false) fires once the socket is down.


function GetSessionId

int64 UTryllSubsystem::GetSessionId () const

Server-assigned session id, or 0 when not connected.


function GetStatId

virtual TStatId UTryllSubsystem::GetStatId () override const

function GetTickableTickType

virtual ETickableTickType UTryllSubsystem::GetTickableTickType () override const

function Initialize

virtual void UTryllSubsystem::Initialize (
    FSubsystemCollectionBase & Collection
) override

function IsConnected

bool UTryllSubsystem::IsConnected () const

True while the background connection is in the Connected state.


function IsTickable

virtual bool UTryllSubsystem::IsTickable () override const

function IsTickableInEditor

inline virtual bool UTryllSubsystem::IsTickableInEditor () override const

function IsTickableWhenPaused

inline virtual bool UTryllSubsystem::IsTickableWhenPaused () override const

function RegisterAgent

void UTryllSubsystem::RegisterAgent (
    std::uint64_t AgentId,
    TWeakPtr< FTryllAgent > Agent
) 

function RequestCreateAgent

void UTryllSubsystem::RequestCreateAgent (
    const FTryllGraphDescription & Graph,
    TFunction< FTryllOnAgentCreated > OnComplete,
    bool bEnableDiagnostics=false
) 

Begin create-agent; completion is delivered via OnComplete on the game thread.

Parameters:

  • Graph Workflow graph description to send to the server.
  • bEnableDiagnostics When true the server populates TurnComplete.debug_info.

function RequestCreateEmbeddedStringStorage

void UTryllSubsystem::RequestCreateEmbeddedStringStorage (
    const FString & Name,
    const FString & ConfigPath,
    const FString & EmbeddingModel=FString{},
    TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr
) 

Create an EmbeddedStringStorage from a server-side *.fig.json. Path A: config file + optional embeddingModel override.


function RequestCreateEmbeddedStringStorageFromStrings

void UTryllSubsystem::RequestCreateEmbeddedStringStorageFromStrings (
    const FString & Name,
    const TArray< FString > & Strings,
    const FString & EmbeddingModel,
    TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr
) 

Create an EmbeddedStringStorage from inline strings. Path B: requires EmbeddingModel.


function RequestCreateStringStorage

void UTryllSubsystem::RequestCreateStringStorage (
    const FString & Name,
    const TArray< FString > & Strings,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Create a named StringStorage on the server from an inline string array. Completion is broadcast via OnCreateStringStorageComplete.


function RequestCreateStringStorageFromFile

void UTryllSubsystem::RequestCreateStringStorageFromFile (
    const FString & Name,
    const FString & FilePath,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Create a named StringStorage on the server from a server-side file path. Completion is broadcast via OnCreateStringStorageComplete.


function RequestDestroyAgent

void UTryllSubsystem::RequestDestroyAgent (
    TSharedPtr< FTryllAgent > Agent
) 

Queue destroy for the given agent.


function RequestDestroyEmbeddedStringStorage

void UTryllSubsystem::RequestDestroyEmbeddedStringStorage (
    const FString & Name,
    TFunction< FTryllOnEmbeddedStorageDestroyed > OnComplete=nullptr
) 

Destroy a named EmbeddedStringStorage on the server. Nodes that already hold the storage are unaffected.


function RequestDestroyStringStorage

void UTryllSubsystem::RequestDestroyStringStorage (
    const FString & Name,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Destroy a named StringStorage on the server. Nodes that already hold the storage are unaffected.


function RequestDownloadModel

void UTryllSubsystem::RequestDownloadModel (
    const FString & ModelName
) 

Start downloading a model. Progress is broadcast via OnDownloadProgress; completion via OnDownloadComplete.


function RequestListModels

void UTryllSubsystem::RequestListModels (
    TFunction< FTryllOnListModels > OnComplete
) 

List models available for the session's inference engine.


function RequestLoadModel

void UTryllSubsystem::RequestLoadModel (
    const FString & ModelName
) 

Pin a model into memory on the server (LoadAndPin). Completion is broadcast via OnLoadModelComplete.


function RequestModel

void UTryllSubsystem::RequestModel (
    const FString & ModelName
) 

Ensure a model is loaded and pinned. Tries LoadModel first; if the model is not present on disk the subsystem falls back to DownloadModel and retries the load. Single completion event: OnModelReady(name, bSuccess).


function RequestUnloadModel

void UTryllSubsystem::RequestUnloadModel (
    const FString & ModelName
) 

Demote a pinned model to on-demand and evict it if no contexts hold it. Completion is broadcast via OnUnloadModelComplete.


function Tick

virtual void UTryllSubsystem::Tick (
    float DeltaTime
) override

function UPROPERTY [1/2]

UTryllSubsystem::UPROPERTY (
    EditAnywhere,
    BlueprintReadWrite,
    Category="Tryll|Connection",
    meta=(ToolTip="Host name or IP address of the Tryll server (default: 127.0.0.1).")
) 

Host name or IP address of the Tryll server. Defaults to localhost.


function UPROPERTY [2/2]

UTryllSubsystem::UPROPERTY (
    EditAnywhere,
    BlueprintReadWrite,
    Category="Tryll|Connection",
    meta=(ToolTip="TCP port the Tryll server is listening on (default: 9100).", ClampMin="1", ClampMax="65535")
) 

TCP port the Tryll server is listening on (default: 9100).


function UnregisterAgent

void UTryllSubsystem::UnregisterAgent (
    std::uint64_t AgentId
) 


The documentation for this class was generated from the following file C:/_tryll/_monorepo/server/client-unreal/Source/TryllClient/Public/TryllSubsystem.h