Skip to content

Commit 0ef7cf4

Browse files
crickmanglahaye
andauthored
.Net Better repeatability for Agent KernelExample #72 (Example72_AgentCollaboration) (#4314)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> `Example72_AgentCollaboration.RunAsPluginsAsync()` prefered to execute as a non-terminating loop since the instruction to the art-director emphasized finding a critique as the overall goal (as opposed to approving copy). ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Tuned prompt for art-director agent and verified with multiple runs. - Added comment to that either example has an off-chance to not reach agreement - Tracking further improvements: #4313 > Note: `Example72_AgentCollaboration.RunAsPluginsAsync()` tends to be more iterative than `Example72_AgentCollaboration.RunCollaborationAsync()` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] 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 - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Gil LaHaye <[email protected]>
1 parent 65e20a6 commit 0ef7cf4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public static async Task RunAsync()
3434
return;
3535
}
3636

37+
// NOTE: Either of these examples produce a conversation
38+
// whose duration may vary depending on the collaboration dynamics.
39+
// It is sometimes possible that agreement is never achieved.
40+
3741
// Explicit collaboration
3842
await RunCollaborationAsync();
3943

@@ -110,7 +114,7 @@ private static async Task RunAsPluginsAsync()
110114
Track(
111115
await new AgentBuilder()
112116
.WithOpenAIChatCompletion(OpenAIFunctionEnabledModel, TestConfiguration.OpenAI.ApiKey)
113-
.WithInstructions("Reply the provided concept and have the copy-writer generate an marketing idea (copy). Then have the art-director reply to the copy-writer with a review of the copy. Coordinate the repeated replies between the copy-writer and art-director until the art-director approves the copy. Respond with the copy when approved by the art-director and summarize why it is good.")
117+
.WithInstructions("Reply the provided concept and have the copy-writer generate an marketing idea (copy). Then have the art-director reply to the copy-writer with a review of the copy. Always include the source copy in any message. Always include the art-director comments when interacting with the copy-writer. Coordinate the repeated replies between the copy-writer and art-director until the art-director approves the copy.")
114118
.WithPlugin(copyWriter.AsPlugin())
115119
.WithPlugin(artDirector.AsPlugin())
116120
.BuildAsync());
@@ -147,7 +151,7 @@ private async static Task<IAgent> CreateArtDirectorAsync()
147151
Track(
148152
await new AgentBuilder()
149153
.WithOpenAIChatCompletion(OpenAIFunctionEnabledModel, TestConfiguration.OpenAI.ApiKey)
150-
.WithInstructions("You are an art director who has opinions about copywriting born of a love for David Ogilvy. The goal is to provide insight on how to refine suggested copy without example. Always respond to the most recent message by evaluating and providing critique without example. Always repeat the copy at the beginning. If copy is acceptable and meets your criteria, say: PRINT IT.")
154+
.WithInstructions("You are an art director who has opinions about copywriting born of a love for David Ogilvy. The goal is to determine is the given copy is acceptable to print, even if it isn't perfect. If not, provide insight on how to refine suggested copy without example. Always respond to the most recent message by evaluating and providing critique without example. Always repeat the copy at the beginning. If copy is acceptable and meets your criteria, say: PRINT IT.")
151155
.WithName("Art Director")
152156
.WithDescription("Art Director")
153157
.BuildAsync());

0 commit comments

Comments
 (0)