Unreal OpenAI API 1.0.0
WorldTimeService.h
1// OpenAI ServiceSample, Copyright LifeEXE. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "ChatGPT/BaseService.h"
7#include "HTTP.h"
8#include "WorldTimeService.generated.h"
9
10USTRUCT()
12{
13 GENERATED_BODY()
14
15 UPROPERTY()
16 FString DateTime; // "2023-11-05T21:57:12.151253+00:00"
17
18 UPROPERTY()
19 FString TimeZone; // Europe/London
20
21 UPROPERTY()
22 FString UTC_DateTime; // "2023-11-05T21:57:12.151253+00:00"
23
24 UPROPERTY()
25 uint32 Week_Number{};
26
27 // @todo: more fields can be added
28 // http://worldtimeapi.org
29};
30
31UCLASS()
32class OPENAI_API UWorldTimeService : public UBaseService
33{
34 GENERATED_BODY()
35
36public:
37 virtual bool Init(const OpenAI::ServiceSecrets& Secrets) override { return true; }
38
39 virtual FString Description() const override;
40 virtual FString FunctionName() const override;
41 virtual void Call(const TSharedPtr<FJsonObject>& Args, const FString& ToolID) override;
42
43 virtual FString Name() const override { return "Time"; };
44 virtual FString TooltipDescription() const override { return "World time from http://worldtimeapi.org"; };
45
46protected:
47 virtual FString MakeFunction() const override;
48
49private:
50 void OnRequestCompleted(FHttpRequestPtr Request, FHttpResponsePtr Response, bool WasSuccessful);
51};
Definition: BaseService.h:16
Definition: WorldTimeService.h:33
Definition: WorldTimeService.h:12