@@ -81,7 +81,7 @@ bool UHttpGPTChatRequest::CanActivateTask() const
81
81
82
82
if (HttpGPT::Internal::HasEmptyParam (Messages))
83
83
{
84
- UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Can't activate task: Invalid Messages." ), *FString (__func__ ), GetUniqueID ());
84
+ UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Can't activate task: Invalid Messages." ), *FString (__FUNCTION__ ), GetUniqueID ());
85
85
return false ;
86
86
}
87
87
@@ -116,7 +116,7 @@ FString UHttpGPTChatRequest::SetRequestContent()
116
116
return FString ();
117
117
}
118
118
119
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Mounting content" ), *FString (__func__ ), GetUniqueID ());
119
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Mounting content" ), *FString (__FUNCTION__ ), GetUniqueID ());
120
120
121
121
const TSharedPtr<FJsonObject> JsonRequest = MakeShared<FJsonObject>();
122
122
JsonRequest->SetStringField (" model" , UHttpGPTHelper::ModelToName (GetChatOptions ().Model ).ToString ().ToLower ());
@@ -157,7 +157,7 @@ FString UHttpGPTChatRequest::SetRequestContent()
157
157
158
158
if (UHttpGPTHelper::ModelSupportsChat (GetChatOptions ().Model ))
159
159
{
160
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Selected model supports Chat API. Mounting section history." ), *FString (__func__ ),
160
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Selected model supports Chat API. Mounting section history." ), *FString (__FUNCTION__ ),
161
161
GetUniqueID ());
162
162
163
163
TArray<TSharedPtr<FJsonValue>> MessagesJson;
@@ -182,7 +182,7 @@ FString UHttpGPTChatRequest::SetRequestContent()
182
182
else
183
183
{
184
184
UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Selected model does not supports Chat API. Using last message as prompt content." ),
185
- *FString (__func__ ), GetUniqueID ());
185
+ *FString (__FUNCTION__ ), GetUniqueID ());
186
186
JsonRequest->SetStringField (" prompt" , Messages.Top ().Content );
187
187
}
188
188
@@ -206,8 +206,8 @@ void UHttpGPTChatRequest::OnProgressUpdated(const FString& Content, int32 BytesS
206
206
207
207
TArray<FString> Deltas = GetDeltasFromContent (Content);
208
208
209
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Progress Updated" ), *FString (__func__ ), GetUniqueID ());
210
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Content: %s; Bytes Sent: %d; Bytes Received: %d" ), *FString (__func__ ), GetUniqueID (),
209
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Progress Updated" ), *FString (__FUNCTION__ ), GetUniqueID ());
210
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Content: %s; Bytes Sent: %d; Bytes Received: %d" ), *FString (__FUNCTION__ ), GetUniqueID (),
211
211
*Deltas.Top (), BytesSent, BytesReceived);
212
212
213
213
DeserializeStreamedResponse (Deltas);
@@ -245,7 +245,7 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool
245
245
246
246
if (!bWasSuccessful || HttpGPT::Internal::HasEmptyParam (Content))
247
247
{
248
- UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Request failed" ), *FString (__func__ ), GetUniqueID ());
248
+ UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Request failed" ), *FString (__FUNCTION__ ), GetUniqueID ());
249
249
AsyncTask (ENamedThreads::GameThread, [this ]
250
250
{
251
251
RequestFailed.Broadcast ();
@@ -254,8 +254,8 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool
254
254
return ;
255
255
}
256
256
257
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Process Completed" ), *FString (__func__ ), GetUniqueID ());
258
- UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Content: %s" ), *FString (__func__ ), GetUniqueID (), *Content);
257
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Process Completed" ), *FString (__FUNCTION__ ), GetUniqueID ());
258
+ UE_LOG (LogHttpGPT_Internal, Display, TEXT (" %s (%d): Content: %s" ), *FString (__FUNCTION__ ), GetUniqueID (), *Content);
259
259
260
260
if (!GetChatOptions ().bStream )
261
261
{
@@ -283,7 +283,7 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool
283
283
}
284
284
else
285
285
{
286
- UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Request failed" ), *FString (__func__ ), GetUniqueID ());
286
+ UE_LOG (LogHttpGPT, Error, TEXT (" %s (%d): Request failed" ), *FString (__FUNCTION__ ), GetUniqueID ());
287
287
AsyncTask (ENamedThreads::GameThread, [this ]
288
288
{
289
289
FScopeLock Lock (&Mutex);
@@ -342,16 +342,16 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content)
342
342
343
343
Response.bSuccess = true ;
344
344
345
- Response.ID = *JsonResponse->GetStringField (" id" );
346
- Response.Object = *JsonResponse->GetStringField (" object" );
347
- Response.Created = JsonResponse->GetNumberField (" created" );
345
+ Response.ID = *JsonResponse->GetStringField (TEXT ( " id" ) );
346
+ Response.Object = *JsonResponse->GetStringField (TEXT ( " object" ) );
347
+ Response.Created = JsonResponse->GetNumberField (TEXT ( " created" ) );
348
348
349
- const TArray<TSharedPtr<FJsonValue>> ChoicesArr = JsonResponse->GetArrayField (" choices" );
349
+ const TArray<TSharedPtr<FJsonValue>> ChoicesArr = JsonResponse->GetArrayField (TEXT ( " choices" ) );
350
350
351
351
for (auto Iterator = ChoicesArr.CreateConstIterator (); Iterator; ++Iterator)
352
352
{
353
353
const TSharedPtr<FJsonObject> ChoiceObj = (*Iterator)->AsObject ();
354
- const int32 ChoiceIndex = ChoiceObj->GetIntegerField (" index" );
354
+ const int32 ChoiceIndex = ChoiceObj->GetIntegerField (TEXT ( " index" ) );
355
355
356
356
FHttpGPTChatChoice* Choice = Response.Choices .FindByPredicate ([this , ChoiceIndex](const FHttpGPTChatChoice& Element)
357
357
{
@@ -365,54 +365,54 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content)
365
365
Choice = &Response.Choices .Add_GetRef (NewChoice);
366
366
}
367
367
368
- if (const TSharedPtr<FJsonObject>* MessageObj; ChoiceObj->TryGetObjectField (" message" , MessageObj))
368
+ if (const TSharedPtr<FJsonObject>* MessageObj; ChoiceObj->TryGetObjectField (TEXT ( " message" ) , MessageObj))
369
369
{
370
- if (FString RoleStr; (*MessageObj)->TryGetStringField (" role" , RoleStr))
370
+ if (FString RoleStr; (*MessageObj)->TryGetStringField (TEXT ( " role" ) , RoleStr))
371
371
{
372
372
Choice->Message .Role = RoleStr == " user" ? EHttpGPTChatRole::User : EHttpGPTChatRole::Assistant;
373
373
}
374
374
375
- if (FString ContentStr; (*MessageObj)->TryGetStringField (" content" , ContentStr))
375
+ if (FString ContentStr; (*MessageObj)->TryGetStringField (TEXT ( " content" ) , ContentStr))
376
376
{
377
377
Choice->Message .Content = ContentStr;
378
378
}
379
379
380
- if (const TSharedPtr<FJsonObject>* FunctionObj; (*MessageObj)->TryGetObjectField (" function_call" , FunctionObj))
380
+ if (const TSharedPtr<FJsonObject>* FunctionObj; (*MessageObj)->TryGetObjectField (TEXT ( " function_call" ) , FunctionObj))
381
381
{
382
- if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField (" name" , FunctionNameStr))
382
+ if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField (TEXT ( " name" ) , FunctionNameStr))
383
383
{
384
384
Choice->Message .FunctionCall .Name = *FunctionNameStr;
385
385
}
386
- if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField (" arguments" , FunctionArgumentsStr))
386
+ if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField (TEXT ( " arguments" ) , FunctionArgumentsStr))
387
387
{
388
388
Choice->Message .FunctionCall .Arguments = FunctionArgumentsStr;
389
389
}
390
390
}
391
391
}
392
- else if (const TSharedPtr<FJsonObject>* DeltaObj; ChoiceObj->TryGetObjectField (" delta" , DeltaObj))
392
+ else if (const TSharedPtr<FJsonObject>* DeltaObj; ChoiceObj->TryGetObjectField (TEXT ( " delta" ) , DeltaObj))
393
393
{
394
- if (FString RoleStr; (*DeltaObj)->TryGetStringField (" role" , RoleStr))
394
+ if (FString RoleStr; (*DeltaObj)->TryGetStringField (TEXT ( " role" ) , RoleStr))
395
395
{
396
396
Choice->Message .Role = UHttpGPTHelper::NameToRole (*RoleStr);
397
397
}
398
- else if (FString ContentStr; (*DeltaObj)->TryGetStringField (" content" , ContentStr))
398
+ else if (FString ContentStr; (*DeltaObj)->TryGetStringField (TEXT ( " content" ) , ContentStr))
399
399
{
400
400
Choice->Message .Content += ContentStr;
401
401
}
402
402
403
- if (const TSharedPtr<FJsonObject>* FunctionObj; (*DeltaObj)->TryGetObjectField (" function_call" , FunctionObj))
403
+ if (const TSharedPtr<FJsonObject>* FunctionObj; (*DeltaObj)->TryGetObjectField (TEXT ( " function_call" ) , FunctionObj))
404
404
{
405
- if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField (" name" , FunctionNameStr))
405
+ if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField (TEXT ( " name" ) , FunctionNameStr))
406
406
{
407
407
Choice->Message .FunctionCall .Name = *FunctionNameStr;
408
408
}
409
- if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField (" arguments" , FunctionArgumentsStr))
409
+ if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField (TEXT ( " arguments" ) , FunctionArgumentsStr))
410
410
{
411
411
Choice->Message .FunctionCall .Arguments += FunctionArgumentsStr;
412
412
}
413
413
}
414
414
}
415
- else if (FString MessageText; ChoiceObj->TryGetStringField (" text" , MessageText))
415
+ else if (FString MessageText; ChoiceObj->TryGetStringField (TEXT ( " text" ) , MessageText))
416
416
{
417
417
Choice->Message .Role = EHttpGPTChatRole::Assistant;
418
418
Choice->Message .Content += MessageText;
@@ -423,16 +423,16 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content)
423
423
Choice->Message .Content .RemoveAt (0 );
424
424
}
425
425
426
- if (FString FinishReasonStr; ChoiceObj->TryGetStringField (" finish_reason" , FinishReasonStr))
426
+ if (FString FinishReasonStr; ChoiceObj->TryGetStringField (TEXT ( " finish_reason" ) , FinishReasonStr))
427
427
{
428
428
Choice->FinishReason = *FinishReasonStr;
429
429
}
430
430
}
431
431
432
- if (const TSharedPtr<FJsonObject>* UsageObj; JsonResponse->TryGetObjectField (" usage" , UsageObj))
432
+ if (const TSharedPtr<FJsonObject>* UsageObj; JsonResponse->TryGetObjectField (TEXT ( " usage" ) , UsageObj))
433
433
{
434
- Response.Usage = FHttpGPTChatUsage ((*UsageObj)->GetNumberField (" prompt_tokens" ), (*UsageObj)->GetNumberField (" completion_tokens" ),
435
- (*UsageObj)->GetNumberField (" total_tokens" ));
434
+ Response.Usage = FHttpGPTChatUsage ((*UsageObj)->GetNumberField (TEXT ( " prompt_tokens" )) , (*UsageObj)->GetNumberField (TEXT ( " completion_tokens" ) ),
435
+ (*UsageObj)->GetNumberField (TEXT ( " total_tokens" ) ));
436
436
}
437
437
}
438
438
0 commit comments