|
|
|
@ -61,15 +61,25 @@ public static class LocalMode
|
|
|
|
|
var responseBody = await SendRequestAsync(json, getToken, "LMT_handle_jobs");
|
|
|
|
|
|
|
|
|
|
var jNode = JsonNode.Parse(responseBody);
|
|
|
|
|
var data = jNode?["result"]?["translations"]?[0]?["beams"]?[0]?["sentences"]?[0]?["text"]?.ToString();
|
|
|
|
|
var resultList = jNode?["result"]?["translations"];
|
|
|
|
|
var data = "";
|
|
|
|
|
if (resultList is not JsonArray jsonArray)
|
|
|
|
|
return Utilities.Serialize(new Response
|
|
|
|
|
{
|
|
|
|
|
Code = 500,
|
|
|
|
|
Data = "Error: No translation result"
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
data = jsonArray.Aggregate(data, (current, item) => current + item?["beams"]?[0]?["sentences"]?[0]?["text"]);
|
|
|
|
|
// data = jNode?["result"]?["translations"]?[0]?["beams"]?[0]?["sentences"]?[0]?["text"]?.ToString();
|
|
|
|
|
var errorMsg = jNode?["error"]?["message"]?.ToString();
|
|
|
|
|
var detailsMsg = jNode?["error"]?["data"]?["what"]?.ToString();
|
|
|
|
|
var error = $"Error: {errorMsg}\nDetails: {detailsMsg}";
|
|
|
|
|
|
|
|
|
|
return Utilities.Serialize(new Response
|
|
|
|
|
{
|
|
|
|
|
Code = data != null ? 200 : 500,
|
|
|
|
|
Data = data ?? error
|
|
|
|
|
Code = string.IsNullOrEmpty(data) ? 500 : 200,
|
|
|
|
|
Data = string.IsNullOrEmpty(data) ? error : data
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|