Skip to content

Commit

Permalink
Sample prompt tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
crickman committed Oct 14, 2024
1 parent 28193bc commit 7d0d83c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions dotnet/samples/Concepts/Agents/MixedChat_Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ public class MixedChat_Serialization(ITestOutputHelper output) : BaseAgentsTest(
private const string TranslatorName = "Translator";
private const string TranslatorInstructions =
"""
Spell the very last number in chat as a word in english and spanish
Spell the last number in chat as a word in english and spanish on a single line without any line breaks.
""";

private const string CounterName = "Counter";
private const string CounterInstructions =
"""
Add 1 to the very last number in the chat.
Increment the last number from your most recent response.
Never repeat the same number.
Only respond with a single number that is the result of your calculation without explanation.
""";
Expand Down Expand Up @@ -51,13 +52,19 @@ await OpenAIAssistantAgent.CreateAsync(
AgentGroupChat chat = CreateGroupChat();

// Invoke chat and display messages.
string input = "1";
chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input));
Console.WriteLine($"# {AuthorRole.User}: '{input}'");
ChatMessageContent input = new(AuthorRole.User, "1");
chat.AddChatMessage(input);
this.WriteAgentChatMessage(input);

Console.WriteLine("============= Source Chat ==============");
await InvokeAgents(chat);

Console.WriteLine("============= Counter Thread ==============");
await foreach (ChatMessageContent content in chat.GetChatMessagesAsync(agentCounter))
{
this.WriteAgentChatMessage(content);
}

AgentGroupChat copy = CreateGroupChat();
Console.WriteLine("\n=========== Serialized Chat ============");
await CloneChatAsync(chat, copy);
Expand All @@ -68,14 +75,14 @@ await OpenAIAssistantAgent.CreateAsync(
Console.WriteLine("\n============ Full History ==============");
await foreach (ChatMessageContent content in copy.GetChatMessagesAsync())
{
Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'");
this.WriteAgentChatMessage(content);
}

async Task InvokeAgents(AgentGroupChat chat)
{
await foreach (ChatMessageContent content in chat.InvokeAsync())
{
Console.WriteLine($"# {content.Role} - {content.AuthorName ?? "*"}: '{content.Content}'");
this.WriteAgentChatMessage(content);
}
}

Expand Down

0 comments on commit 7d0d83c

Please sign in to comment.