Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

supporting local deployment of OpenAI-Compatible Server #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ bool UHttpGPTChatRequest::CanBindProgress() const

FString UHttpGPTChatRequest::GetEndpointURL() const
{
return FString::Format(TEXT("{0}/{1}"), { GetCommonOptions().Endpoint, UHttpGPTHelper::GetEndpointForModel(GetChatOptions().Model, GetCommonOptions().bIsAzureOpenAI, GetCommonOptions().AzureOpenAIAPIVersion) });
if(GetCommonOptions().bIsLocDeploy)
{
return FString::Format(TEXT("{0}/v1/chat/completions"), {GetCommonOptions().LocalAddress});
}
else
{
return FString::Format(TEXT("{0}/{1}"), { GetCommonOptions().Endpoint, UHttpGPTHelper::GetEndpointForModel(GetChatOptions().Model, GetCommonOptions().bIsAzureOpenAI, GetCommonOptions().AzureOpenAIAPIVersion) });
}
}

const FHttpGPTChatOptions UHttpGPTChatRequest::GetChatOptions() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void UHttpGPTSettings::SetToDefaults()
CommonOptions.bIsAzureOpenAI = false;
CommonOptions.Endpoint = TEXT("https://api.openai.com/");
CommonOptions.AzureOpenAIAPIVersion = TEXT("2023-05-15");
CommonOptions.bIsLocDeploy = false;
CommonOptions.LocalAddress = TEXT("http://localhost:8000/");

ChatOptions.Model = EHttpGPTChatModel::gpt35turbo;
ChatOptions.MaxTokens = 2048;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ void FHttpGPTCommonOptions::SetDefaults()
APIKey = Settings->CommonOptions.APIKey;
User = Settings->CommonOptions.User;
bIsAzureOpenAI = Settings->CommonOptions.bIsAzureOpenAI;
bIsLocDeploy = Settings->CommonOptions.bIsLocDeploy;
Endpoint = Settings->CommonOptions.Endpoint;
LocalAddress = Settings->CommonOptions.LocalAddress;
AzureOpenAIAPIVersion = Settings->CommonOptions.AzureOpenAIAPIVersion;
}
}
9 changes: 8 additions & 1 deletion Source/HttpGPTCommonModule/Private/Tasks/HttpGPTBaseTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,14 @@ void UHttpGPTBaseTask::BindRequestCallbacks()
return;
}

OnProgressCompleted(RequestResponse->GetContentAsString(), bWasSuccessful);
if(RequestResponse.IsValid())
{
OnProgressCompleted(RequestResponse->GetContentAsString(), bWasSuccessful);
}
else
{
UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to send request: RequestResponse is invalid"), *FString(__func__), GetUniqueID());
}
SetReadyToDestroy();
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ struct HTTPGPTCOMMONMODULE_API FHttpGPTCommonOptions
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HttpGPT | Common", Meta = (DisplayName = "Endpoint", EditCondition = "bIsAzureOpenAI"))
FString Endpoint;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HttpGPT | Common", Meta = (DisplayName = "Is Local Deployment"))
bool bIsLocDeploy;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HttpGPT | Common", Meta = (DisplayName = "LocalAddress", EditCondition = "bIsLocDeploy"))
FString LocalAddress;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HttpGPT | Common", Meta = (DisplayName = "Azure OpenAI API Version", EditCondition = "bIsAzureOpenAI"))
FString AzureOpenAIAPIVersion;

Expand Down