I’m having a lot of issues with the c# module that was previously working in CloudCode. I didn’t change anything and it started to throw errors. For example, this is the C# on CloudCode
[CloudCodeFunction("ModeratorCheck")]
public async Task<string> ModeratorCheck(string _customQuestion)
{
try
{
api = new OpenAIAPI("API_KEY");
var result = await api.Moderation.CallModerationAsync(_customQuestion);
if (result.Results[0].Flagged)
{
return result.Results[0].MainContentFlag;
}
else
{
return "OK";
}
}catch (ApiException ex)
{
_logger.LogError("Failed to process moderation api");
return "exception";
}
}
And this is how its called in the game. I am running this from the Editor but I also have this error on my android build.
public async Task<string> ModerateQuestion(string _customQuestion)
{
try
{
var result = await CloudCodeService.Instance.CallModuleEndpointAsync("Project", "ModeratorCheck", new Dictionary<string, object>
{
{ "_customQuestion", _customQuestion }
});
return result;
}
catch (CloudCodeException exception)
{
Debug.Log("Moderator exception "+exception);
}
return "error";
}
This is the error being thrown all the time:
Cloud Code returned an Unprocessable Entity exception, but it could not be parsed: Cloud Code Unprocessable Entity exception is in an unexpected format and couldn't be parsed: StartIndex cannot be less than zero.
Parameter name: startIndex. Original error: ScriptError
(422) HTTP/1.1 422 Unprocessable Entity
Unprocessable Entity
Invocation Error
Common.Exceptions.InvalidModuleException: Error in Cloud Code Setup
