/SimpleHttpClient-UE5

Small plugin to get data via http requests in UE5 + lightweight json parser

Primary LanguageC++Apache License 2.0Apache-2.0

Description

This is very lightweight plugin to send HTTP requests and parse JSON in bluerpints.

Demo project shows interaction with two neural models: text-generative and text-to-speech.

Youtube Video

I used text-generation-webui to run this model and this fork of coqui TTS. Demo project also uses Runtime Audio Importer plugins (it's free on Unreal Marketplace).

How to use

Json parser starts with two global functions: "Json from File" or "Json from String". After you created JsonItem variable from a string template or loaded it from file, read or write any field inside using functions: SetBooleanField, SetNumericField, SetStringField and GetBooleanField, GetNumericField, GetStringField. All these functions require path, which consists of hierarchy of json fields separated by dot (.) symbol. For arrays use square brackets with element index or name of a field inside.

For exmaple, standard OpenAI request looks like this:

{
    "messages": [
      {
        "role": "user",
        "content": "Hello! Who are you?"
      },
      {
        "role": "system",
        "content": "Answer in rhyme."
      }
    ],
    "mode": "chat"
  }

Path to user content ("Hello! Who are you?" string) is messages[role="user"].content (quotes are optional) or messages[0].content.

FJsonItem::SetStringField

To send HTTP requests, use HTTPSubsystem. It has three useful events OnTextResponse, OnDataResponse and OnResponseError and simple function HTTPRequest.

UHTTPSubsystem::OnDataResponse

UHTTPSubsystem::HTTPRequest