forked from microsoft/semanticworkbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade .NET connector in the examples (microsoft#212)
- Loading branch information
Showing
13 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
examples/dotnet/dotnet-02-message-types-demo/ConnectorExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Text; | ||
using Microsoft.SemanticWorkbench.Connector; | ||
|
||
namespace AgentExample; | ||
|
||
public static class ConnectorExtensions | ||
{ | ||
public static string GetParticipantName(this Conversation conversation, string id) | ||
{ | ||
if (conversation.Participants.TryGetValue(id, out Participant? participant)) | ||
{ | ||
return participant.Name; | ||
} | ||
|
||
return "Unknown"; | ||
} | ||
|
||
public static string ToHtmlString( | ||
this Conversation conversation, | ||
string assistantId) | ||
{ | ||
var result = new StringBuilder(); | ||
result.AppendLine("<style>"); | ||
result.AppendLine("DIV.conversationHistory { padding: 0 20px 60px 20px; }"); | ||
result.AppendLine("DIV.conversationHistory P { margin: 0 0 8px 0; }"); | ||
result.AppendLine("</style>"); | ||
result.AppendLine("<div class='conversationHistory'>"); | ||
|
||
foreach (var msg in conversation.Messages) | ||
{ | ||
result.AppendLine("<p>"); | ||
if (msg.Sender.Id == assistantId) | ||
{ | ||
result.AppendLine("<b>Assistant</b><br/>"); | ||
} | ||
else | ||
{ | ||
result | ||
.Append("<b>") | ||
.Append(conversation.GetParticipantName(msg.Sender.Id)) | ||
.AppendLine("</b><br/>"); | ||
} | ||
|
||
result.AppendLine(msg.Content).AppendLine("</p>"); | ||
} | ||
|
||
result.Append("</div>"); | ||
|
||
return result.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters