You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.Net: Add invoke overloads for string and no message. (#11219)
### Motivation and Context
Most invocations take a user message as input, so supporting just
passing the string is useful.
Some agents support invoking the agent without any message, so adding
explicit support for this is useful.
### Description
Add invoke overloads for string and no message.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
Copy file name to clipboardExpand all lines: dotnet/samples/Demos/AgentFrameworkWithAspire/ChatWithAgent.ApiService/Controllers/AgentCompletionsController.cs
+2-2
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ private async IAsyncEnumerable<ChatMessageContent> CompleteAsync(ChatHistory cha
Copy file name to clipboardExpand all lines: dotnet/src/Agents/Abstractions/Agent.cs
+97-2
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
usingSystem.Threading.Tasks;
7
7
usingMicrosoft.Extensions.Logging;
8
8
usingMicrosoft.Extensions.Logging.Abstractions;
9
+
usingMicrosoft.SemanticKernel.ChatCompletion;
9
10
10
11
namespaceMicrosoft.SemanticKernel.Agents;
11
12
@@ -43,6 +44,51 @@ public abstract class Agent
43
44
/// </summary>
44
45
publicILoggerFactory?LoggerFactory{get;init;}
45
46
47
+
/// <summary>
48
+
/// Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.
49
+
/// </summary>
50
+
/// <param name="thread">The conversation thread to continue with this invocation. If not provided, creates a new thread.</param>
51
+
/// <param name="options">Optional parameters for agent invocation.</param>
52
+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
53
+
/// <returns>An async list of response items that each contain a <see cref="ChatMessageContent"/> and an <see cref="AgentThread"/>.</returns>
54
+
/// <remarks>
55
+
/// To continue this thread in the future, use an <see cref="AgentThread"/> returned in one of the response items.
/// Invoke the agent with the provided message and arguments.
67
+
/// </summary>
68
+
/// <param name="message">The message to pass to the agent.</param>
69
+
/// <param name="thread">The conversation thread to continue with this invocation. If not provided, creates a new thread.</param>
70
+
/// <param name="options">Optional parameters for agent invocation.</param>
71
+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
72
+
/// <returns>An async list of response items that each contain a <see cref="ChatMessageContent"/> and an <see cref="AgentThread"/>.</returns>
73
+
/// <remarks>
74
+
/// <para>
75
+
/// The provided message string will be treated as a user message.
76
+
/// </para>
77
+
/// <para>
78
+
/// To continue this thread in the future, use an <see cref="AgentThread"/> returned in one of the response items.
@@ -80,6 +128,51 @@ public abstract IAsyncEnumerable<AgentResponseItem<ChatMessageContent>> InvokeAs
80
128
AgentInvokeOptions?options=null,
81
129
CancellationTokencancellationToken=default);
82
130
131
+
/// <summary>
132
+
/// Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread.
133
+
/// </summary>
134
+
/// <param name="thread">The conversation thread to continue with this invocation. If not provided, creates a new thread.</param>
135
+
/// <param name="options">Optional parameters for agent invocation.</param>
136
+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
137
+
/// <returns>An async list of response items that each contain a <see cref="ChatMessageContent"/> and an <see cref="AgentThread"/>.</returns>
138
+
/// <remarks>
139
+
/// To continue this thread in the future, use an <see cref="AgentThread"/> returned in one of the response items.
/// Invoke the agent with the provided message and arguments.
151
+
/// </summary>
152
+
/// <param name="message">The message to pass to the agent.</param>
153
+
/// <param name="thread">The conversation thread to continue with this invocation. If not provided, creates a new thread.</param>
154
+
/// <param name="options">Optional parameters for agent invocation.</param>
155
+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
156
+
/// <returns>An async list of response items that each contain a <see cref="ChatMessageContent"/> and an <see cref="AgentThread"/>.</returns>
157
+
/// <remarks>
158
+
/// <para>
159
+
/// The provided message string will be treated as a user message.
160
+
/// </para>
161
+
/// <para>
162
+
/// To continue this thread in the future, use an <see cref="AgentThread"/> returned in one of the response items.
0 commit comments