5#include "CoreMinimal.h"
6#include "Provider/OpenAIProvider.h"
7#include "OpenAIProviderFake.generated.h"
13 virtual int32 GetResponseCode()
const override {
return static_cast<int32
>(EHttpResponseCodes::Ok); }
14 virtual FString GetContentAsString()
const override {
return ReponseData; }
15 virtual FString GetURL()
const override {
return FString(); }
16 virtual FString GetURLParameter(
const FString& ParameterName)
const override {
return FString(); }
17 virtual FString GetHeader(
const FString& HeaderName)
const override {
return FString(); }
18 virtual TArray<FString> GetAllHeaders()
const override {
return TArray<FString>(); }
19 virtual FString GetContentType()
const override {
return FString(); }
20 virtual uint64 GetContentLength()
const override {
return uint64(); }
21 virtual const TArray<uint8>& GetContent()
const override
23 static TArray<uint8> None;
26 virtual const FString& GetEffectiveURL()
const override {
return EffectiveURL; }
27 virtual EHttpRequestStatus::Type GetStatus()
const override {
return EHttpRequestStatus::Type::Succeeded; }
28 virtual EHttpFailureReason GetFailureReason()
const override {
return EHttpFailureReason::None; }
39 virtual FString GetURL()
const override {
return FString(); }
40 virtual FHttpRequestWillRetryDelegate& OnRequestWillRetry()
override {
return HttpRequestWillRetryDelegate; }
41 virtual FString GetURLParameter(
const FString& ParameterName)
const override {
return FString(); }
42 virtual FString GetHeader(
const FString& HeaderName)
const override {
return FString(); }
43 virtual TArray<FString> GetAllHeaders()
const override {
return TArray<FString>(); }
44 virtual FString GetContentType()
const override {
return FString(); }
45 virtual uint64 GetContentLength()
const override {
return uint64(); }
46 virtual const TArray<uint8>& GetContent()
const override
48 static TArray<uint8> None;
51 virtual FString GetVerb()
const override {
return FString{}; }
52 virtual void SetVerb(
const FString& Verb)
override {}
53 virtual void SetURL(
const FString& URL)
override {}
54 virtual void SetContent(
const TArray<uint8>& ContentPayload)
override {}
55 virtual void SetContent(TArray<uint8>&& ContentPayload)
override {}
56 virtual void SetContentAsString(
const FString& ContentString)
override {}
57 virtual bool SetContentAsStreamedFile(
const FString& Filename)
override {
return false; }
58 virtual bool SetContentFromStream(TSharedRef<FArchive, ESPMode::ThreadSafe> Stream)
override {
return false; }
59 virtual void SetHeader(
const FString& HeaderName,
const FString& HeaderValue)
override {}
60 virtual void AppendToHeader(
const FString& HeaderName,
const FString& AdditionalHeaderValue)
override {}
61 virtual void SetTimeout(
float InTimeoutSecs)
override {}
62 virtual void ClearTimeout()
override {}
63 virtual TOptional<float> GetTimeout()
const override {
return TOptional<float>(); }
64 virtual bool ProcessRequest()
override
66 HttpRequestCompleteDelegate.Execute(SharedThis(
this), GetResponse(),
true);
69 virtual FHttpRequestCompleteDelegate& OnProcessRequestComplete()
override {
return HttpRequestCompleteDelegate; }
70 virtual FHttpRequestHeaderReceivedDelegate& OnHeaderReceived()
override {
return HttpHeaderReceivedDelegate; }
71 virtual FHttpRequestProgressDelegate64& OnRequestProgress64()
override {
return HttpRequestProgressDelegate64; }
72 virtual FHttpRequestStatusCodeReceivedDelegate& OnStatusCodeReceived()
override {
return HttpRequestStatusCodeReceivedDelegate; }
73 virtual void CancelRequest()
override {}
74 virtual EHttpRequestStatus::Type GetStatus()
const override {
return EHttpRequestStatus::Type::NotStarted; }
75 virtual const FHttpResponsePtr GetResponse()
const override {
return MakeShareable(
new FFakeHttpResponse(ReponseData)); }
76 virtual void Tick(
float DeltaSeconds)
override {}
77 virtual float GetElapsedTime()
const override {
return float{}; }
78 virtual bool SetResponseBodyReceiveStream(TSharedRef<FArchive> Stream)
override {
return false; }
79 virtual void SetDelegateThreadPolicy(EHttpRequestDelegateThreadPolicy InThreadPolicy)
override {}
80 virtual EHttpRequestDelegateThreadPolicy GetDelegateThreadPolicy()
const override
82 return EHttpRequestDelegateThreadPolicy::CompleteOnGameThread;
84 virtual const FString& GetEffectiveURL()
const override {
return EffectiveURL; }
85 virtual EHttpFailureReason GetFailureReason()
const override {
return EHttpFailureReason::None; }
86 virtual void ProcessRequestUntilComplete()
override {}
87 virtual void SetActivityTimeout(
float InTimeoutSecs)
override {}
88 virtual FString GetOption(
const FName Option)
const override {
return {}; }
89 virtual void SetOption(
const FName Option,
const FString& OptionValue)
override {}
90 virtual void ResetTimeoutStatus()
override {}
93 FHttpRequestProgressDelegate HttpRequestProgressDelegate;
94 FHttpRequestProgressDelegate64 HttpRequestProgressDelegate64;
95 FHttpRequestCompleteDelegate HttpRequestCompleteDelegate;
96 FHttpRequestHeaderReceivedDelegate HttpHeaderReceivedDelegate;
97 FHttpRequestWillRetryDelegate HttpRequestWillRetryDelegate;
98 FHttpRequestStatusCodeReceivedDelegate HttpRequestStatusCodeReceivedDelegate;
102 FString EffectiveURL;
111 void SetResponse(
const FString& ResponseStr) { ReponseData = ResponseStr; };
116 virtual TSharedRef<IHttpRequest, ESPMode::ThreadSafe> CreateRequest()
const override
Definition: OpenAIProviderFake.h:36
Definition: OpenAIProviderFake.h:10
Definition: OpenAIProviderFake.h:107
Definition: OpenAIProvider.h:45