修复问题
This commit is contained in:
parent
34880b0122
commit
d4ba8bc0d4
|
|
@ -52,7 +52,7 @@ public class ChatBLL : MiaoYuBase
|
|||
list.Add(chat);
|
||||
return new BaseResponse<List<ChatMessageDto>>(ResonseCode.Success, "", list);
|
||||
}
|
||||
var userChatSession = await Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.CharacterId == characterId && it.UserId == _UserId && !it.IsDelete).FirstOrDefaultAsync();
|
||||
var userChatSession = await Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.CharacterId == characterId && it.UserId == _UserId && !it.IsDelete && it.TotalCount > 0).FirstOrDefaultAsync();
|
||||
if (userChatSession == null)
|
||||
{
|
||||
userChatSession = new T_User_Chat()
|
||||
|
|
@ -67,6 +67,7 @@ public class ChatBLL : MiaoYuBase
|
|||
TenantId = charact.TenantId,
|
||||
UserId = _UserId,
|
||||
TotalToken = 0,
|
||||
TotalCount = 0,
|
||||
};
|
||||
Dao.daoDbMiaoYu.context.T_User_Chat.Add(userChatSession);
|
||||
Dao.daoDbMiaoYu.context.SaveChanges();
|
||||
|
|
@ -228,6 +229,7 @@ public class ChatBLL : MiaoYuBase
|
|||
TenantId = charact.TenantId,
|
||||
UserId = _UserId,
|
||||
TotalToken = 0,
|
||||
TotalCount = 0,
|
||||
};
|
||||
Dao.daoDbMiaoYu.context.T_User_Chat.Add(userChatSession);
|
||||
Dao.daoDbMiaoYu.context.SaveChanges();
|
||||
|
|
@ -328,13 +330,10 @@ public class ChatBLL : MiaoYuBase
|
|||
t_Character.Token = charact.Token;
|
||||
}
|
||||
}
|
||||
t_Chat1.Tokens = claudeChatResponse.InputTokens ;
|
||||
t_Chat1.Tokens = claudeChatResponse.InputTokens;
|
||||
t_Chat1.Input_tokens = claudeChatResponse.InputTokens;
|
||||
//设置消耗的总token
|
||||
if (userChatSession.TotalToken == null)
|
||||
{
|
||||
userChatSession.TotalToken = 0;
|
||||
}
|
||||
userChatSession.TotalCount++;
|
||||
userChatSession.TotalToken += claudeChatResponse.InputTokens + claudeChatResponse.OutputTokens;
|
||||
Dao.daoDbMiaoYu.context.Add(t_Chat1);
|
||||
Dao.daoDbMiaoYu.context.Add(t_Chat);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
var memoryCard = Dao.daoDbMiaoYu.context.T_User_MemoryCard.Where(it => it.UserId == _UserId && it.CharacterId == 0).Count();
|
||||
//var memoryCard = user.GetUserCurrencyMoney(UserCurrencyType.记忆卡, Dao);
|
||||
//获取聊天次数
|
||||
var hasTalked = Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.UserId == _UserId && !it.IsDelete ).Count();
|
||||
var hasTalked = Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.UserId == _UserId && !it.IsDelete && it.TotalCount > 0).Count();
|
||||
List<CreateCharacterInfo> characters = new List<CreateCharacterInfo>();
|
||||
return new BaseResponse<ResponseUserInfo>(ResonseCode.Success, "请求成功", new ResponseUserInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
.HasMaxLength(50)
|
||||
.HasComment("会话名称");
|
||||
entity.Property(e => e.TenantId).HasComment("租户");
|
||||
entity.Property(e => e.TotalCount).HasComment("聊天次数");
|
||||
entity.Property(e => e.TotalToken).HasComment("消耗的总token");
|
||||
entity.Property(e => e.UpdateAt)
|
||||
.HasComment("修改时间")
|
||||
|
|
|
|||
|
|
@ -59,5 +59,10 @@ public partial class T_User_Chat: MultiTenantEntity
|
|||
/// <summary>
|
||||
/// 消耗的总token
|
||||
/// </summary>
|
||||
public virtual int? TotalToken { get; set; }
|
||||
public virtual int TotalToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 聊天次数
|
||||
/// </summary>
|
||||
public virtual int TotalCount { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user