Skip to content

Commit eb4e0b0

Browse files
author
Yanan Wang
committed
Merge from master into add_richCoontent Branch
2 parents 35cbc90 + 58051e2 commit eb4e0b0

42 files changed

Lines changed: 251 additions & 236 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/channels/components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Messaging Components
22

3-
Conversations are a lot more than simple text messages when you are building a AI chatbot. In addition to text, the `BotSharp`` allows you to send rich-media, like audio, video, and images, and provides a set of structured messaging options in the form of message templates, quick replies, buttons and more. The UI rendering program can render components according to the returned data format.
3+
Conversations are a lot more than simple text messages when you are building a AI chatbot. In addition to text, the `BotSharp` allows you to send rich-media, like audio, video, and images, and provides a set of structured messaging options in the form of message templates, quick replies, buttons and more. The UI rendering program can render components according to the returned data format.
44

55

66
## Text Messages
@@ -75,7 +75,7 @@ Message templates are structured message formats used for various purposes to pr
7575
...
7676
}
7777
]
78-
}
78+
}
7979
}
8080
}
8181
}
Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
1+
using BotSharp.Abstraction.Models;
2+
13
namespace BotSharp.Abstraction.Conversations.Models;
24

3-
public class IncomingMessageModel
5+
public class IncomingMessageModel : MessageConfig
46
{
57
public string Text { get; set; } = string.Empty;
6-
7-
public virtual string Channel { get; set; } = string.Empty;
8-
9-
/// <summary>
10-
/// Completion Provider
11-
/// </summary>
12-
[JsonPropertyName("provider")]
13-
public virtual string? Provider { get; set; } = null;
14-
15-
/// <summary>
16-
/// Model name
17-
/// </summary>
18-
[JsonPropertyName("model")]
19-
public virtual string? Model { get; set; } = null;
20-
21-
/// <summary>
22-
/// The sampling temperature to use that controls the apparent creativity of generated completions.
23-
/// </summary>
24-
public float Temperature { get; set; } = 0.5f;
25-
26-
/// <summary>
27-
/// An alternative value to Temperature, called nucleus sampling, that causes
28-
/// the model to consider the results of the tokens with probability mass.
29-
/// </summary>
30-
public float SamplingFactor { get; set; } = 0.5f;
31-
32-
/// <summary>
33-
/// Conversation states from input
34-
/// </summary>
35-
public List<string> States { get; set; } = new List<string>();
8+
public virtual string Channel { get; set; }
369
}

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
using BotSharp.Abstraction.Functions.Models;
2+
using BotSharp.Abstraction.Models;
3+
14
namespace BotSharp.Abstraction.Conversations.Models;
25

3-
public class RoleDialogModel
6+
public class RoleDialogModel : ITrackableMessage
47
{
8+
public string MessageId { get; set; }
9+
510
/// <summary>
611
/// user, system, assistant, function
712
/// </summary>
@@ -36,10 +41,17 @@ public class RoleDialogModel
3641
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
3742
public bool StopCompletion { get; set; }
3843

44+
public FunctionCallFromLlm Instruction { get; set; }
45+
46+
private RoleDialogModel()
47+
{
48+
}
49+
3950
public RoleDialogModel(string role, string text)
4051
{
4152
Role = role;
4253
Content = text;
54+
MessageId = Guid.NewGuid().ToString();
4355
}
4456

4557
public override string ToString()

src/Infrastructure/BotSharp.Abstraction/Functions/Models/FunctionDef.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class FunctionDef
44
{
55
public string Name { get; set; }
66
public string Description { get; set; }
7+
public string? Impact { get; set; }
78
public FunctionParametersDef Parameters { get; set; } = new FunctionParametersDef();
89

910
public override string ToString()

src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResult.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
using BotSharp.Abstraction.Models;
2+
13
namespace BotSharp.Abstraction.Instructs.Models;
24

3-
public class InstructResult
5+
public class InstructResult : ITrackableMessage
46
{
7+
public string MessageId { get; set; }
58
public string Text { get; set; }
69
public object Data { get; set; }
710
public ConversationState States { get; set; }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace BotSharp.Abstraction.Models;
2+
3+
/// <summary>
4+
/// Define a message ID to extend message-level applications, such as model fees, token usage, and data collection
5+
/// </summary>
6+
public interface ITrackableMessage
7+
{
8+
string MessageId { get; set; }
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace BotSharp.Abstraction.Models;
2+
3+
public class MessageConfig
4+
{
5+
/// <summary>
6+
/// Completion Provider
7+
/// </summary>
8+
[JsonPropertyName("provider")]
9+
public virtual string? Provider { get; set; } = null;
10+
11+
/// <summary>
12+
/// Model name
13+
/// </summary>
14+
[JsonPropertyName("model")]
15+
public virtual string? Model { get; set; } = null;
16+
17+
/// <summary>
18+
/// The sampling temperature to use that controls the apparent creativity of generated completions.
19+
/// </summary>
20+
public float Temperature { get; set; } = 0.5f;
21+
22+
/// <summary>
23+
/// An alternative value to Temperature, called nucleus sampling, that causes
24+
/// the model to consider the results of the tokens with probability mass.
25+
/// </summary>
26+
public float SamplingFactor { get; set; } = 0.5f;
27+
28+
/// <summary>
29+
/// Conversation states from input
30+
/// </summary>
31+
public List<string> States { get; set; } = new List<string>();
32+
}

src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using BotSharp.Abstraction.Functions.Models;
2-
using BotSharp.Abstraction.Models;
32

43
namespace BotSharp.Abstraction.Routing;
54

@@ -19,5 +18,5 @@ void SetRouter(Agent router) { }
1918

2019
void SetDialogs(List<RoleDialogModel> dialogs) { }
2120

22-
Task<RoleDialogModel> Handle(IRoutingService routing, FunctionCallFromLlm inst);
21+
Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message);
2322
}

src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface IRoutingService
88
void ResetRecursiveCounter();
99
void RefreshDialogs();
1010
Task<FunctionCallFromLlm> GetNextInstruction();
11-
Task<RoleDialogModel> InvokeAgent(string agentId);
12-
Task<RoleDialogModel> InstructLoop();
13-
Task<RoleDialogModel> ExecuteOnce(Agent agent);
11+
Task<bool> InvokeAgent(string agentId, RoleDialogModel message);
12+
Task<bool> InstructLoop(RoleDialogModel message);
13+
Task<bool> ExecuteOnce(Agent agent, RoleDialogModel message);
1414
}

src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ public RoutingContext(RoutingSettings setting)
1818
/// </summary>
1919
public string IntentName { get; set; }
2020

21+
/// <summary>
22+
/// Agent that can handl user original goal.
23+
/// </summary>
2124
public string OriginAgentId
22-
=> _stack.Last();
25+
=> _stack.Where(x => x != _setting.RouterId).Last();
2326

2427
public string GetCurrentAgentId()
2528
{

0 commit comments

Comments
 (0)