Commit f697c92e authored by 吴春's avatar 吴春

1

parent 047eab17
......@@ -12,7 +12,7 @@ namespace Edu.Common.API
public int AccountId { get; set; }
public int ApplicationId { get; set; }
public string KeyWord { get; set; }
public string TimeUtc { get; set; }
public int LogId { get; set; }
public int Status { get; set; }
public string CompletionResultModel { get; set; }
......
......@@ -229,9 +229,8 @@ namespace Edu.WebApi.Controllers.AI
return ApiResult.Failed(jsonObject.GetStringValue("msg"));
}
}
return ApiResult.Failed("获取失败");
}
return ApiResult.Success();
return ApiResult.Failed("解析失败!");
}
else if (supplierModel.SupplierType == Common.Enum.AI.SupplierTypeEnum.OpenAI)
{
......@@ -247,39 +246,42 @@ namespace Edu.WebApi.Controllers.AI
AccountId = this.AppletUserInfo.AccountId,
ApplicationId = applicationId,
KeyWord = keyWord,
TimeUtc = dateStr,
LogId = 0,
Status = 0,
CompletionResultModel = "",
};
Cache.User.UserReidsCache.Set(this.AppletUserInfo.AccountId + "_" + "TimeUtc" + dateStr, resultModel, Common.Config.JwtExpirTime);
var result = openai.Completions.CreateCompletionAsync(completion);
int addId = aiModule.SetAIUseLogModule(userLogModel);
if (result != null)
if (addId > 0)
{
try
Cache.User.UserReidsCache.Set(this.AppletUserInfo.AccountId + "_" + "LogId_" + addId, resultModel, Common.Config.JwtExpirTime);
if (result != null)
{
var returnModel = Cache.User.UserReidsCache.OpenAIGet(this.AppletUserInfo.AccountId + "_" + "TimeUtc" + dateStr);
if (returnModel != null)
try
{
returnModel.Status = 1;
string completionResult = "";
if (result.Result != null)
resultModel.LogId = addId;
var returnModel = Cache.User.UserReidsCache.OpenAIGet(this.AppletUserInfo.AccountId + "_" + "LogId_" + addId);
if (returnModel != null)
{
completionResult = JsonHelper.Serialize(result.Result);
returnModel.Status = 1;
string completionResult = "";
if (result.Result != null)
{
completionResult = JsonHelper.Serialize(result.Result);
}
returnModel.CompletionResultModel = completionResult;
Cache.User.UserReidsCache.Set(this.AppletUserInfo.AccountId + "_" + "LogId_" + addId, resultModel, Common.Config.JwtExpirTime);
}
returnModel.CompletionResultModel = completionResult;
Cache.User.UserReidsCache.Set(this.AppletUserInfo.AccountId + "_" + "TimeUtc" + dateStr, resultModel, Common.Config.JwtExpirTime);
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetUserLoginInfo");
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetUserLoginInfo");
}
}
return ApiResult.Success(data: new { result = resultModel, Id = addId });
}
return ApiResult.Success(data: new { result = resultModel, Id = addId });
}
return ApiResult.Success();
return ApiResult.Failed("解析失败!");
}
/// <summary>
......@@ -289,18 +291,18 @@ namespace Edu.WebApi.Controllers.AI
[HttpPost]
public ApiResult GetOpenAIResult()
{
string dateStr = base.ParmJObj.GetStringValue("TimeUtc");
//string dateStr = base.ParmJObj.GetStringValue("TimeUtc");
int Id = base.ParmJObj.GetInt("Id", 0);
if (string.IsNullOrWhiteSpace(dateStr) || Id <= 0)
if (Id <= 0)
{
return ApiResult.ParamIsNull();
}
var returnModel = Cache.User.UserReidsCache.OpenAIGet(this.AppletUserInfo.AccountId + "_" + "TimeUtc" + dateStr);
var returnModel = Cache.User.UserReidsCache.OpenAIGet(this.AppletUserInfo.AccountId + "_" + "LogId_" + Id);
if (returnModel == null)
{
return ApiResult.Failed("获取失败请重新调用");
}
else
else if (returnModel.Status == 1)
{
var model = aiModule.GetAIUseLogEntity(Id);
model.ResultInfo = returnModel.CompletionResultModel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment