Skip to content

add comments #774

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 67 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a14981e
Add Redis timestamp
Oceania2018 Nov 18, 2024
9b77a7a
Merge branch 'SciSharp:master' into master
Oceania2018 Nov 19, 2024
6432f22
issues-34
Nov 20, 2024
9ad3c7b
Fix FileRepository.GetUserByPhone
Oceania2018 Nov 20, 2024
94018db
fix: date time
AnonymousDotNet Nov 20, 2024
46b3299
Merge branch 'master' into lida_Dev
AnonymousDotNet Nov 20, 2024
fe8a462
Merge branch 'SciSharp:master' into master
Oceania2018 Nov 21, 2024
0d048dd
Merge pull request #46 from AnonymousDotNet/lida_Dev
Oceania2018 Nov 21, 2024
7786466
CheckMessageExists
Oceania2018 Nov 21, 2024
a4e2bfc
Merge branch 'master' of https://github.com/Qtoss-AI/BotSharp
Oceania2018 Nov 21, 2024
93a4bd9
hdong: split some phone number from client and admin.
YouWeiDH Nov 21, 2024
0078b97
hdong:clean up for client,user and admin split logic.
YouWeiDH Nov 21, 2024
7212731
video comment crawl
Nov 21, 2024
d958322
Merge pull request #47 from Qtoss-AI/hdongDev
Oceania2018 Nov 21, 2024
6a5b745
Merge pull request #45 from Qtoss-AI/jason_dev
Oceania2018 Nov 21, 2024
0d95262
httpContext is null
Oceania2018 Nov 21, 2024
11ceb8e
Add EventPriority
Oceania2018 Nov 23, 2024
597e26a
Allow to disable EventPriority
Oceania2018 Nov 23, 2024
e92b72c
Handle exception SubscribeAsync
Oceania2018 Nov 23, 2024
f722781
DragAndDrop
Oceania2018 Nov 24, 2024
0b98fe0
delay 100ms
Oceania2018 Nov 24, 2024
28908d9
disable lock
Oceania2018 Nov 24, 2024
5bf9173
hdong: Fix phone exist check issues.
YouWeiDH Nov 25, 2024
dc07856
feat: add HideMiddleDigits
AnonymousDotNet Nov 25, 2024
effb9d8
Merge branch 'master' into lida_Dev
AnonymousDotNet Nov 25, 2024
9276cce
hdong: use userType menu and add AffiliateCode.
YouWeiDH Nov 25, 2024
1966266
Merge pull request #48 from Qtoss-AI/hdongDev
Oceania2018 Nov 25, 2024
6a21158
Merge pull request #49 from AnonymousDotNet/lida_Dev
Oceania2018 Nov 25, 2024
a336cc9
Fix Ad
Oceania2018 Nov 26, 2024
8056369
hdong:change affiliate code name.
YouWeiDH Nov 26, 2024
c75043d
fix: remove HideMiddleDigits
AnonymousDotNet Nov 26, 2024
b4e0f1d
Merge branch 'master' into lida_Dev
AnonymousDotNet Nov 26, 2024
3f6a63b
perf: Use IsNullOrWhiteSpace
AnonymousDotNet Nov 26, 2024
a187bfb
Merge pull request #52 from AnonymousDotNet/lida_Dev
Oceania2018 Nov 26, 2024
0a1417d
Merge branch 'SciSharp:master' into master
Oceania2018 Nov 26, 2024
961d2b0
Merge pull request #51 from Qtoss-AI/hdongDev
Oceania2018 Nov 26, 2024
65ffe84
fix: update SplitAsTuple
AnonymousDotNet Nov 27, 2024
fcc0885
fix: receive regionCode
AnonymousDotNet Nov 27, 2024
ae2049c
fix: update GetUserByPhone
AnonymousDotNet Nov 27, 2024
8bd5713
Merge pull request #53 from AnonymousDotNet/lida_Dev
Oceania2018 Nov 27, 2024
4841c43
Merge branch 'SciSharp:master' into master
Oceania2018 Nov 27, 2024
da90856
fix: Add regionCode verification
AnonymousDotNet Nov 29, 2024
2556391
Merge pull request #54 from AnonymousDotNet/lida_Dev
Oceania2018 Nov 29, 2024
0ea383f
Merge branch 'SciSharp:master' into master
Oceania2018 Nov 29, 2024
039054a
allow CancellationToken
Oceania2018 Nov 29, 2024
4813c5b
Merge branch 'master' of https://github.com/Qtoss-AI/BotSharp
Oceania2018 Nov 29, 2024
5f31ffe
Allow Event to be removed.
Oceania2018 Nov 30, 2024
4cf3531
Add ExecutionTimeout
Oceania2018 Dec 1, 2024
3dc76fc
Support port for event
Oceania2018 Dec 1, 2024
393acb7
Remove Aspire.MongoDB.Driver
Oceania2018 Dec 1, 2024
5a3478d
ShopInfoFromProductList
Oceania2018 Dec 2, 2024
4012305
Init Core.Rule module
Dec 2, 2024
61c0f91
Merge branch 'master' of https://github.com/hchen2020/BotSharp
Dec 3, 2024
47f6986
add comments
Dec 3, 2024
d6b31c5
Fix duplicate function loaded OnAgentUtilityLoaded
Dec 3, 2024
57e40f0
Merge branch 'SciSharp:master' into master
hchen2020 Dec 3, 2024
b23cd20
Merge pull request #775 from hchen2020/master
Oceania2018 Dec 3, 2024
49a968b
add OnSourceCodeGenerated Hook
Joannall Dec 3, 2024
be687bd
Merge pull request #776 from Joannall/master
Oceania2018 Dec 3, 2024
43b9dd9
Init Crontab
Dec 3, 2024
0c20ae0
Merge branch 'master' of https://github.com/hchen2020/BotSharp
Dec 3, 2024
7f16eae
Merge pull request #769 from Qtoss-AI/master
Oceania2018 Dec 3, 2024
bca3264
Merge branch 'master' of https://github.com/hchen2020/BotSharp
Dec 3, 2024
35e7cd3
Fix Mongo version issue.
Dec 3, 2024
7920969
Merge pull request #777 from hchen2020/master
Oceania2018 Dec 3, 2024
ca99b14
Merge branch 'master' of https://github.com/iceljc/BotSharp
iceljc Dec 4, 2024
e831c81
init roles
iceljc Dec 4, 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 @@ -71,7 +71,14 @@ public virtual void OnAgentUtilityLoaded(Agent agent)

var (functions, templates) = GetUtilityContent(agent);

agent.Functions.AddRange(functions);
foreach (var fn in functions)
{
if (!agent.Functions.Any(x => x.Name.Equals(fn.Name, StringComparison.OrdinalIgnoreCase)))
{
agent.Functions.Add(fn);
}
}

foreach (var prompt in templates)
{
agent.Instruction += $"\r\n\r\n{prompt}\r\n\r\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public class BuiltInAgentId
/// Evaluate prompt and conversation
/// </summary>
public const string Evaluator = "dfd9b46d-d00c-40af-8a75-3fbdc2b89869";

/// <summary>
/// Translates user-defined natural language rules into programmatic code
/// </summary>
public const string RuleEncoder = "6acfb93c-3412-402e-9ba5-c5d3cd8f0161";

/// <summary>
/// Schedule job
/// </summary>
public const string Crontab = "c2o139da-a62a-4355-8605-fdf0ffaca58e";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public enum BroswerActionEnum
Typing = 3,
Hover = 4,
Scroll = 5,
DragAndDrop = 6
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ public class ElementPosition
public float X { get; set; } = default!;

public float Y { get; set; } = default!;

public override string ToString()
{
return $"[{X}, {Y}]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public class ConversationChannel
public const string Phone = "phone";
public const string Messenger = "messenger";
public const string Email = "email";
public const string Cron = "cron";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BotSharp.Abstraction.Infrastructures.Enums;

public enum EventPriority
{
Low = 1,
Medium = 2,
High = 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ public interface IEventPublisher
/// <returns></returns>
Task BroadcastAsync(string channel, string message);

Task PublishAsync(string channel, string message);
Task<string?> PublishAsync(string channel, string message, EventPriority? priority = null);

Task ReDispatchAsync(string channel, int count = 10, string order = "asc");

Task ReDispatchPendingAsync(string channel, string group, int count = 10);

Task RemoveAsync(string channel, int count = 10);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System.Threading;

namespace BotSharp.Abstraction.Infrastructures.Events;

public interface IEventSubscriber
{
Task SubscribeAsync(string channel, Func<string, string, Task> received);

Task SubscribeAsync(string channel, string group, Func<string, string, Task> received);
Task SubscribeAsync(string channel, string group, int? port, bool priorityEnabled,
Func<string, string, Task> received,
CancellationToken? stoppingToken = null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace BotSharp.Abstraction.Infrastructures;

public interface IDistributedLocker
{
bool Lock(string resource, Action action, int timeout = 30);
Task<bool> LockAsync(string resource, Func<Task> action, int timeout = 30);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public override void OnSuccess(MethodContext context)
}

var httpContext = Services.GetRequiredService<IHttpContextAccessor>();
if (httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
if (httpContext != null &&
httpContext.HttpContext != null &&
httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ public interface IPlanningHook
Task<string> GetSummaryAdditionalRequirements(string planner, RoleDialogModel message)
=> Task.FromResult(string.Empty);

Task OnSourceCodeGenerated(string planner, RoleDialogModel msg, string language)
=> Task.CompletedTask;

Task OnPlanningCompleted(string planner, RoleDialogModel msg)
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ namespace BotSharp.Abstraction.Repositories;

public class BotSharpDatabaseSettings : DatabaseBasicSettings
{
public string[] Assemblies { get; set; }
public string FileRepository { get; set; }
public string BotSharpMongoDb { get; set; }
public string TablePrefix { get; set; }
public DbConnectionSetting BotSharp { get; set; }
public string Redis { get; set; }
public string[] Assemblies { get; set; } = [];
public string FileRepository { get; set; } = string.Empty;
public string BotSharpMongoDb { get; set; } = string.Empty;
public string TablePrefix { get; set; } = string.Empty;
public DbConnectionSetting BotSharp { get; set; } = new();
public string Redis { get; set; } = string.Empty;
public bool EnableReplica { get; set; } = true;
}

public class DatabaseBasicSettings
{
public string Default { get; set; }
public DbConnectionSetting DefaultConnection { get; set; }
public string Default { get; set; } = string.Empty;
public DbConnectionSetting DefaultConnection { get; set; } = new();
public bool EnableSqlLog { get; set; }
public bool EnableSensitiveDataLogging { get; set; }
public bool EnableRetryOnFailure { get; set; }
Expand All @@ -23,9 +24,11 @@ public class DbConnectionSetting
{
public string Master { get; set; }
public string[] Slavers { get; set; }
public int ConnectionTimeout { get; set; } = 30;
public int ExecutionTimeout { get; set; } = 30;

public DbConnectionSetting()
{
Slavers = new string[0];
Slavers = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public static RoleFilter Empty()
{
return new RoleFilter();
}

public bool IsInit()
{
return Names.IsNullOrEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using BotSharp.Abstraction.Shared;
using BotSharp.Abstraction.Tasks.Models;
using BotSharp.Abstraction.Translation.Models;
using BotSharp.Abstraction.Users.Enums;
using BotSharp.Abstraction.Users.Models;
using BotSharp.Abstraction.VectorStorage.Models;

Expand All @@ -26,7 +27,7 @@ public interface IBotSharpRepository : IHaveServiceProvider

#region User
User? GetUserByEmail(string email) => throw new NotImplementedException();
User? GetUserByPhone(string phone, string role = null, string regionCode = "CN") => throw new NotImplementedException();
User? GetUserByPhone(string phone, string type = UserType.Client, string regionCode = "CN") => 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class User
public bool Verified { get; set; }
public string RegionCode { get; set; } = "CN";
public string? AffiliateId { get; set; }
public string? ReferralCode { get; set; }
public string? EmployeeId { get; set; }
public bool IsDisabled { get; set; }
public IEnumerable<string> Permissions { get; set; } = [];
Expand Down
14 changes: 14 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Utilities/MathExt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BotSharp.Abstraction.Utilities;

public static class MathExt
{
public static int Max(int a, int b, int c)
{
return Math.Max(Math.Max(a, b), c);
}

public static long Max(long a, long b, long c)
{
return Math.Max(Math.Max(a, b), c);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using BotSharp.Abstraction.Infrastructures;
using System.Diagnostics;

namespace BotSharp.Abstraction.Utilities;

[DebuggerStepThrough]
public class Pagination : ICacheKey
{
private int _page;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using BotSharp.Core.Crontab.Models;

namespace BotSharp.Core.Crontab.Abstraction;

public interface ICrontabHook
{
Task OnCronTriggered(CrontabItem item);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using BotSharp.Core.Crontab.Models;

namespace BotSharp.Core.Crontab.Abstraction;

public interface ICrontabService
{
Task<List<CrontabItem>> GetCrontable();
Task ScheduledTimeArrived(CrontabItem item);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Remove="data\agents\c2o139da-a62a-4355-8605-fdf0ffaca58e\agent.json" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\c2o139da-a62a-4355-8605-fdf0ffaca58e\agent.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BotSharp.Abstraction\BotSharp.Abstraction.csproj" />
<ProjectReference Include="..\BotSharp.Core\BotSharp.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NCrontab" Version="3.3.3" />
</ItemGroup>

</Project>
40 changes: 40 additions & 0 deletions src/Infrastructure/BotSharp.Core.Crontab/CrontabPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*****************************************************************************
Copyright 2024 Written by Haiping Chen. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/

namespace BotSharp.Core.Crontab;

/// <summary>
/// Crontab plugin is a time-based job scheduler in agent framework.
/// The cron system is used for automating repetitive tasks, such as trigger AI Agent to do specific task periodically.
/// </summary>
public class CrontabPlugin : IBotSharpPlugin
{
public string Id => "3155c15e-28d3-43f7-8ead-fc43324ec21a";
public string Name => "BotSharp Crontab";
public string Description => "Crontab plugin is a time-based job scheduler in agent framework. The cron system is used to trigger AI Agent to do specific task periodically.";
public string IconUrl => "https://icon-library.com/images/stop-watch-icon/stop-watch-icon-10.jpg";

public string[] AgentIds =
[
BuiltInAgentId.Crontab
];

public void RegisterDI(IServiceCollection services, IConfiguration config)
{
services.AddScoped<ICrontabService, CrontabService>();
services.AddHostedService<CrontabWatcher>();
}
}
14 changes: 14 additions & 0 deletions src/Infrastructure/BotSharp.Core.Crontab/Models/CrontabItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BotSharp.Core.Crontab.Models;

public class CrontabItem
{
public string UserId { get; set; } = null!;
public string AgentId { get; set; } = null!;
public string Topic { get; set; } = null!;
public string Cron { get; set; } = null!;

public override string ToString()
{
return $"AgentId: {AgentId}, UserId: {UserId}, Topic: {Topic}";
}
}
Loading