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