diff --git a/src/Service/FastWiki.Service/Application/Wikis/WikiCommandHandler.cs b/src/Service/FastWiki.Service/Application/Wikis/WikiCommandHandler.cs index 2b756dce..4a03bcda 100644 --- a/src/Service/FastWiki.Service/Application/Wikis/WikiCommandHandler.cs +++ b/src/Service/FastWiki.Service/Application/Wikis/WikiCommandHandler.cs @@ -29,10 +29,12 @@ public async Task RemoveWiki(RemoveWikiCommand command) await wikiRepository.RemoveDetailsAsync(ids); + var wiki = await wikiRepository.FindAsync(command.Id); + foreach (var id in ids) try { - var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty,string.Empty); + var memoryServerless = wikiMemoryService.CreateMemoryServerless(wiki.EmbeddingModel, wiki.Model); await memoryServerless.DeleteDocumentAsync(id.ToString(), "wiki"); } catch (Exception e) @@ -102,7 +104,7 @@ public async Task RemoveWikiDetailsCommand(RemoveWikiDetailsCommand command) try { - var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty,string.Empty); + var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty, string.Empty); await memoryServerless.DeleteDocumentAsync(command.Id.ToString(), "wiki"); } catch (Exception e) @@ -114,7 +116,8 @@ public async Task RemoveWikiDetailsCommand(RemoveWikiDetailsCommand command) [EventHandler] public async Task RemoveWikiDetailVectorQuantityAsync(RemoveWikiDetailVectorQuantityCommand command) { - var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty,string.Empty); + + var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty, string.Empty); await memoryServerless.DeleteDocumentAsync(command.DocumentId, "wiki"); } diff --git a/src/Service/FastWiki.Service/Application/Wikis/WikiQueryHandler.cs b/src/Service/FastWiki.Service/Application/Wikis/WikiQueryHandler.cs index 17c29d94..39351a0b 100644 --- a/src/Service/FastWiki.Service/Application/Wikis/WikiQueryHandler.cs +++ b/src/Service/FastWiki.Service/Application/Wikis/WikiQueryHandler.cs @@ -41,7 +41,9 @@ public async Task GetWikiDetails(WikiDetailsQuery query) [EventHandler] public async Task WikiDetailVectorQuantityAsync(WikiDetailVectorQuantityQuery query) { - var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty,string.Empty); + var wiki = await wikiRepository.FindAsync(x => long.Parse(query.WikiDetailId) == x.Id); + + var memoryServerless = wikiMemoryService.CreateMemoryServerless(wiki.EmbeddingModel, wiki.Model); var memoryDbs = memoryServerless.Orchestrator.GetMemoryDbs(); var result = new PaginatedListBase(); @@ -92,7 +94,10 @@ public async Task WikiDetailVectorQuantityAsync(WikiDetailVectorQuantityQuery qu public async Task SearchVectorQuantityAsync(SearchVectorQuantityQuery query) { var stopwatch = Stopwatch.StartNew(); - var memoryServerless = wikiMemoryService.CreateMemoryServerless(string.Empty,string.Empty); + + var wiki = await wikiRepository.FindAsync(query.WikiId); + + var memoryServerless = wikiMemoryService.CreateMemoryServerless(wiki.EmbeddingModel, wiki.Model); var searchResult = await memoryServerless.SearchAsync(query.Search, "wiki", new MemoryFilter().ByTag("wikiId", query.WikiId.ToString()), minRelevance: query.MinRelevance, limit: 5); diff --git a/src/Service/FastWiki.Service/DataAccess/Repositories/Function/FastWikiFunctionCallRepository.cs b/src/Service/FastWiki.Service/DataAccess/Repositories/Function/FastWikiFunctionCallRepository.cs index 84533d23..56f83ec5 100644 --- a/src/Service/FastWiki.Service/DataAccess/Repositories/Function/FastWikiFunctionCallRepository.cs +++ b/src/Service/FastWiki.Service/DataAccess/Repositories/Function/FastWikiFunctionCallRepository.cs @@ -49,7 +49,7 @@ public async Task InsertAsync(FastWikiFunctionCall functionCall) { await Context.FunctionCalls.AddAsync(functionCall); - await UnitOfWork.SaveChangesAsync(); + await Context.SaveChangesAsync(); } private IQueryable CreateQuery(Guid? userId) diff --git a/src/Service/FastWiki.Service/DataAccess/Repositories/Users/UserRepository.cs b/src/Service/FastWiki.Service/DataAccess/Repositories/Users/UserRepository.cs index 925a31c0..3307e021 100644 --- a/src/Service/FastWiki.Service/DataAccess/Repositories/Users/UserRepository.cs +++ b/src/Service/FastWiki.Service/DataAccess/Repositories/Users/UserRepository.cs @@ -22,13 +22,13 @@ public async Task GetCountAsync(string? keyword) public async Task DeleteAsync(Guid id) { - // 管理员不能删除 + // 绠$悊鍛樹笉鑳藉垹闄 return await Context.Users.Where(x => x.Id == id && x.Role != RoleType.Admin).ExecuteDeleteAsync() > 1; } public async Task DisableAsync(Guid id, bool disable) { - // 管理员不能禁用 + // 绠$悊鍛樹笉鑳界鐢 return await Context.Users.Where(x => x.Id == id && x.Role != RoleType.Admin) .ExecuteUpdateAsync(item => item.SetProperty(x => x.IsDisable, disable)) > 0; } @@ -44,6 +44,13 @@ public async Task IsExistAccountAsync(string account) return await Context.Users.AnyAsync(x => x.Account == account); } + public async Task InsertAsync(User user) + { + await Context.Users.AddAsync(user); + + await Context.SaveChangesAsync(); + } + private IQueryable GetQuery(string? keyword) { var query = Context.Users.AsQueryable(); diff --git a/src/Service/FastWiki.Service/Domain/Users/Repositories/IUserRepository.cs b/src/Service/FastWiki.Service/Domain/Users/Repositories/IUserRepository.cs index 8e73e2ea..6646dc8f 100644 --- a/src/Service/FastWiki.Service/Domain/Users/Repositories/IUserRepository.cs +++ b/src/Service/FastWiki.Service/Domain/Users/Repositories/IUserRepository.cs @@ -1,39 +1,39 @@ namespace FastWiki.Service.Domain.Users.Repositories; /// -/// 用户仓储 +/// 鐢ㄦ埛浠撳偍 /// public interface IUserRepository : IRepository { /// - /// 获取用户列表 + /// 鑾峰彇鐢ㄦ埛鍒楄〃 /// Task> GetListAsync(string? keyword, int page, int pageSize); /// - /// 获取用户数量 + /// 鑾峰彇鐢ㄦ埛鏁伴噺 /// /// /// Task GetCountAsync(string? keyword); /// - /// 删除用户 + /// 鍒犻櫎鐢ㄦ埛 /// /// /// Task DeleteAsync(Guid id); /// - /// 禁用用户/启用用户 + /// 绂佺敤鐢ㄦ埛/鍚敤鐢ㄦ埛 /// /// - /// 是否禁用 + /// 鏄惁绂佺敤 /// Task DisableAsync(Guid id, bool disable); /// - /// 修改角色 + /// 淇敼瑙掕壊 /// /// /// @@ -41,9 +41,16 @@ public interface IUserRepository : IRepository Task UpdateRoleAsync(Guid id, RoleType role); /// - /// 验证账户是否存在 + /// 楠岃瘉璐︽埛鏄惁瀛樺湪 /// /// /// Task IsExistAccountAsync(string account); + + /// + /// 娣诲姞 + /// + /// + /// + Task InsertAsync(User user); } \ No newline at end of file diff --git a/src/Service/FastWiki.Service/Service/UserService.cs b/src/Service/FastWiki.Service/Service/UserService.cs index edd7009c..ca0040be 100644 --- a/src/Service/FastWiki.Service/Service/UserService.cs +++ b/src/Service/FastWiki.Service/Service/UserService.cs @@ -82,7 +82,7 @@ public async Task CreateAsync(CreateUserInput input) "https://blog-simple.oss-cn-shenzhen.aliyuncs.com/Avatar.jpg", input.Email, input.Phone, false); - await userRepository.AddAsync(user); + await userRepository.InsertAsync(user); } [Authorize]