Skip to content

improvement #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
52ebde8
fix issue-273
Sep 17, 2024
b89d88f
Add update password API
AnonymousDotNet Sep 17, 2024
b0e3349
issue-273 update file name
Sep 17, 2024
0d47316
Modify update password API
AnonymousDotNet Sep 18, 2024
81dfb1f
Handle verification code sent by logged in users
AnonymousDotNet Sep 18, 2024
bad946b
Merge branch 'master' into lida_dev
AnonymousDotNet Sep 18, 2024
5fceb2c
Add UserType.
Oceania2018 Sep 19, 2024
a126852
Merge pull request #11 from AnonymousDotNet/lida_dev
Oceania2018 Sep 19, 2024
cadec5c
merge by master
Sep 19, 2024
2bc1535
Merge pull request #10 from Qtoss-AI/issue-273
Oceania2018 Sep 19, 2024
a9abc96
Add user role
Oceania2018 Sep 19, 2024
5645554
AllowMultipleDeviceLoginUserIds
Oceania2018 Sep 19, 2024
c381601
Add switcher EnableSingleLogin
Oceania2018 Sep 19, 2024
4752073
add client & affiliate token
Sep 20, 2024
1ff151d
fix: phone is empty judgment
AnonymousDotNet Sep 20, 2024
d31605f
Merge branch 'master' into lida_dev
AnonymousDotNet Sep 20, 2024
a09d47a
Merge pull request #12 from AnonymousDotNet/lida_dev
Oceania2018 Sep 20, 2024
d8cd0d7
Merge branch 'SciSharp:master' into master
Oceania2018 Sep 21, 2024
d85e16d
add affiliate token api
Sep 21, 2024
ecdcb2a
Add ProductCount to VideoStats
Oceania2018 Sep 21, 2024
86289b0
update IsDisable => IsDisabled
Sep 21, 2024
fe2d6f3
Merge pull request #13 from Qtoss-AI/jason_dev
Oceania2018 Sep 21, 2024
d9996fd
Add UpsertVectorCollectionData
Oceania2018 Sep 22, 2024
b76f9bb
add question to GetRelevantKnowledges.
Oceania2018 Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface IKnowledgeHook
Task<List<KnowledgeChunk>> CollectChunkedKnowledge()
=> Task.FromResult(new List<KnowledgeChunk>());

Task<List<string>> GetRelevantKnowledges()
Task<List<string>> GetRelevantKnowledges(string text)
=> Task.FromResult(new List<string>());

Task<List<string>> GetGlobalKnowledges()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public interface IKnowledgeService
Task<bool> DeleteVectorCollectionAllData(string collectionName);
Task<bool> CreateVectorCollectionData(string collectionName, VectorCreateModel create);
Task<bool> UpdateVectorCollectionData(string collectionName, VectorUpdateModel update);
Task<bool> UpsertVectorCollectionData(string collectionName, VectorUpdateModel update);
#endregion

#region Graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ public class GenericTemplateMessage<T> : IRichMessage, ITemplateMessage
[JsonPropertyName("rich_type")]
public string RichType => RichTypeEnum.GenericTemplate;

/// <summary>
/// Use model refined content if leaving blank
/// </summary>
[JsonPropertyName("text")]
[Translate]
public string Text { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public interface IPlanningHook
{
Task<string> GetSummaryAdditionalRequirements(string planner)
=> Task.FromResult(string.Empty);

Task OnPlanningCompleted(string planner, RoleDialogModel msg)
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ public interface IBotSharpRepository
#region User
User? GetUserByEmail(string email) => throw new NotImplementedException();
User? GetUserByPhone(string phone) => throw new NotImplementedException();
User? GetUserById(string id) => throw new NotImplementedException();
User? GetAffiliateUserByPhone(string phone) => throw new NotImplementedException();
User? GetUserById(string id) => throw new NotImplementedException();
List<User> GetUserByIds(List<string> ids) => throw new NotImplementedException();
User? GetUserByAffiliateId(string affiliateId) => throw new NotImplementedException();
User? GetUserByUserName(string userName) => throw new NotImplementedException();
void CreateUser(User user) => throw new NotImplementedException();
void UpdateUserVerified(string userId) => throw new NotImplementedException();
void UpdateUserVerificationCode(string userId, string verficationCode) => throw new NotImplementedException();
void UpdateUserPassword(string userId, string password) => throw new NotImplementedException();
void UpdateUserEmail(string userId, string email)=> throw new NotImplementedException();
void UpdateUserPhone(string userId, string Iphone) => throw new NotImplementedException();
void UpdateUserIsDisable(string userId, bool isDisable) => throw new NotImplementedException();
#endregion

#region Agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class UserRole
public const string CSR = "csr";

/// <summary>
/// Client
/// Authorized user
/// </summary>
public const string Client = "client";
public const string User = "user";

/// <summary>
/// Back office operations
Expand Down
13 changes: 13 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Users/Enums/UserSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BotSharp.Abstraction.Users.Enums
{
public static class UserSource
{
public const string Internal = "internal";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BotSharp.Abstraction.Users.Enums;

public class UserType
{
public const string Internal = "internal";
public const string Client = "client";
public const string Affiliate = "affiliate";
}
3 changes: 3 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface IUserService
Task<User> GetUser(string id);
Task<User> CreateUser(User user);
Task<Token> ActiveUser(UserActivationModel model);
Task<Token?> GetAffiliateToken(string authorization);
Task<Token?> GetToken(string authorization);
Task<User> GetMyProfile();
Task<bool> VerifyUserNameExisting(string userName);
Expand All @@ -16,4 +17,6 @@ public interface IUserService
Task<bool> ResetUserPassword(User user);
Task<bool> ModifyUserEmail(string email);
Task<bool> ModifyUserPhone(string phone);
Task<bool> UpdatePassword(string newPassword, string verificationCode);
Task<DateTime> GetUserTokenExpires();
}
10 changes: 8 additions & 2 deletions src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ public class User
public string? Phone { get; set; }
public string Salt { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Source { get; set; } = "internal";
public string Source { get; set; } = UserSource.Internal;
public string? ExternalId { get; set; }
public string Role { get; set; } = UserRole.Client;
/// <summary>
/// internal, client, affiliate
/// </summary>
public string Type { get; set; } = UserType.Client;
public string Role { get; set; } = UserRole.User;
public string? VerificationCode { get; set; }
public bool Verified { get; set; }
public string? AffiliateId { get; set; }
public bool IsDisabled { get; set; }
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ public class AccountSetting
/// Whether to enable verification code to verify the authenticity of new users
/// </summary>
public bool NewUserVerification { get; set; }
public string[] AllowMultipleDeviceLoginUserIds { get; set; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ public class VectorCollectionData
public string Id { get; set; }
public Dictionary<string, string> Data { get; set; } = new();
public double? Score { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public float[]? Vector { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using BotSharp.Abstraction.Knowledges.Enums;

namespace BotSharp.Abstraction.VectorStorage.Models;

public class VectorSearchResult : VectorCollectionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ response.RichContent is RichContent<IRichMessage> template &&
Message = new TextMessage(response.SecondaryContent ?? response.Content)
};

// Use model refined response
if (string.IsNullOrEmpty(response.RichContent.Message.Text))
{
response.RichContent.Message.Text = response.Content;
}

// Patch return function name
if (response.PostbackFunctionName != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Dictionary<string, string> Load(string conversationId, bool isReadOnly =

_historyStates = _db.GetConversationStates(conversationId);
var dialogs = _db.GetConversationDialogs(conversationId);
var userDialogs = dialogs.Where(x => x.MetaData?.Role == AgentRole.User || x.MetaData?.Role == UserRole.Client)
var userDialogs = dialogs.Where(x => x.MetaData?.Role == AgentRole.User || x.MetaData?.Role == UserRole.User)
.GroupBy(x => x.MetaData?.MessageId)
.Select(g => g.First())
.OrderBy(x => x.MetaData?.CreateTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ public partial class FileRepository
return Users.FirstOrDefault(x => x.Phone == phone);
}

public User? GetAffiliateUserByPhone(string phone)
{
return Users.FirstOrDefault(x => x.Phone == phone && x.Type == UserType.Affiliate);
}

public User? GetUserById(string id = null)
{
return Users.FirstOrDefault(x => x.Id == id || (x.ExternalId != null && x.ExternalId == id));
}

public List<User> GetUserByIds(List<string> ids)
{
return Users.Where(x => ids.Contains(x.Id) || (x.ExternalId != null && ids.Contains(x.ExternalId)))?.ToList() ?? new List<User>();
}

public User? GetUserByAffiliateId(string affiliateId)
{
return Users.FirstOrDefault(x => x.AffiliateId == affiliateId);
}

public User? GetUserByUserName(string userName = null)
{
return Users.FirstOrDefault(x => x.UserName == userName.ToLower());
Expand Down
Loading