Skip to content

Commit 03a58b3

Browse files
authored
Upgrade .NET examples to latest connector nuget (#264)
1 parent e44d525 commit 03a58b3

File tree

10 files changed

+29
-44
lines changed

10 files changed

+29
-44
lines changed

examples/dotnet/dotnet-01-echo-bot/MyWorkbenchConnector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using System.Text.Json;
4+
using Microsoft.AspNetCore.Hosting.Server;
45
using Microsoft.Extensions.Logging.Abstractions;
56
using Microsoft.SemanticWorkbench.Connector;
67

@@ -14,11 +15,13 @@ public MyWorkbenchConnector(
1415
IServiceProvider sp,
1516
IConfiguration appConfig,
1617
IAgentServiceStorage storage,
18+
IServer httpServer,
1719
ILoggerFactory? loggerFactory = null)
1820
: base(
1921
workbenchConfig: appConfig.GetSection("Workbench").Get<WorkbenchConfig>(),
2022
defaultAgentConfig: appConfig.GetSection("Agent").Get<MyAgentConfig>(),
2123
storage,
24+
httpServer: httpServer,
2225
loggerFactory?.CreateLogger<MyWorkbenchConnector>() ?? new NullLogger<MyWorkbenchConnector>())
2326
{
2427
this._sp = sp;

examples/dotnet/dotnet-01-echo-bot/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ internal static async Task Main(string[] args)
3535
app.UseCors(CORSPolicyName);
3636

3737
// Connect to workbench backend, keep alive, and accept incoming requests
38-
var connectorEndpoint = app.Configuration.GetSection("Workbench").Get<WorkbenchConfig>()!.ConnectorEndpoint;
39-
using var agentService = app.UseAgentWebservice<MyAgentConfig>(connectorEndpoint, true);
38+
var connectorApiPrefix = app.Configuration.GetSection("Workbench").Get<WorkbenchConfig>()!.ConnectorApiPrefix;
39+
using var agentService = app.UseAgentWebservice<MyAgentConfig>(connectorApiPrefix, true);
4040
await agentService.ConnectAsync().ConfigureAwait(false);
4141

4242
// Start app and webservice

examples/dotnet/dotnet-01-echo-bot/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ Project Structure
3434
* Extend `AgentBase`.
3535
* Implement essential methods:
3636
* `ReceiveMessageAsync()`: **handles incoming messages using intent detection, plugins, RAG, etc.**
37-
* `GetDefaultConfig()`: provides default settings for new agent instances.
38-
* `ParseConfig()`: deserializes a generic object into MyAgentConfig.
3937
* **You can override default implementation for additional customization.**
4038
4. `MyWorkbenchConnector.cs`:
4139
* Purpose: custom instance of WorkbenchConnector.

examples/dotnet/dotnet-01-echo-bot/appsettings.json

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// Unique ID of the service. Semantic Workbench will store this event to identify the server
55
// so you should keep the value fixed to match the conversations tracked across service restarts.
66
"ConnectorId": "AgentExample01",
7-
// The endpoint of your service, where semantic workbench will send communications too.
8-
// This should match hostname, port, protocol and path of the web service. You can use
9-
// this also to route semantic workbench through a proxy or a gateway if needed.
10-
"ConnectorEndpoint": "http://127.0.0.1:9101/myagents",
7+
// The host where the connector receives requests sent by the workbench.
8+
// Locally, this is usually "http://127.0.0.1:<some port>"
9+
// On Azure, this will be something like "https://contoso.azurewebsites.net"
10+
// Leave this setting empty to use "127.0.0.1" and autodetect the port in use.
11+
// You can use an env var to set this value, e.g. Workbench__ConnectorHost=https://contoso.azurewebsites.net
12+
"ConnectorHost": "",
13+
// This is the prefix of all the endpoints exposed by the connector
14+
"ConnectorApiPrefix": "/myagents",
1115
// Semantic Workbench endpoint.
1216
"WorkbenchEndpoint": "http://127.0.0.1:3000",
1317
// Name of your agent service
@@ -25,18 +29,6 @@
2529
"ReplyToAgents": false,
2630
"CommandsEnabled": true
2731
},
28-
// Web service settings
29-
"AllowedHosts": "*",
30-
"Kestrel": {
31-
"Endpoints": {
32-
"Http": {
33-
"Url": "http://*:9101"
34-
}
35-
// "Https": {
36-
// "Url": "https://*:19101"
37-
// }
38-
}
39-
},
4032
// .NET Logger settings
4133
"Logging": {
4234
"LogLevel": {

examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.SemanticWorkbench.Connector" Version="0.3.241104.1" />
13+
<PackageReference Include="Microsoft.SemanticWorkbench.Connector" Version="0.4.241125.1" />
1414
</ItemGroup>
1515

1616
<PropertyGroup>

examples/dotnet/dotnet-02-message-types-demo/MyWorkbenchConnector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using System.Text.Json;
4+
using Microsoft.AspNetCore.Hosting.Server;
45
using Microsoft.Extensions.Logging.Abstractions;
56
using Microsoft.SemanticWorkbench.Connector;
67

@@ -14,11 +15,13 @@ public MyWorkbenchConnector(
1415
IServiceProvider sp,
1516
IConfiguration appConfig,
1617
IAgentServiceStorage storage,
18+
IServer httpServer,
1719
ILoggerFactory? loggerFactory = null)
1820
: base(
1921
workbenchConfig: appConfig.GetSection("Workbench").Get<WorkbenchConfig>(),
2022
defaultAgentConfig: appConfig.GetSection("Agent").Get<MyAgentConfig>(),
2123
storage,
24+
httpServer: httpServer,
2225
loggerFactory?.CreateLogger<MyWorkbenchConnector>() ?? new NullLogger<MyWorkbenchConnector>())
2326
{
2427
this._sp = sp;

examples/dotnet/dotnet-02-message-types-demo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ internal static async Task Main(string[] args)
4141
app.UseCors(CORSPolicyName);
4242

4343
// Connect to workbench backend, keep alive, and accept incoming requests
44-
var connectorEndpoint = app.Configuration.GetSection("Workbench").Get<WorkbenchConfig>()!.ConnectorEndpoint;
45-
using var agentService = app.UseAgentWebservice<MyAgentConfig>(connectorEndpoint, true);
44+
var connectorApiPrefix = app.Configuration.GetSection("Workbench").Get<WorkbenchConfig>()!.ConnectorApiPrefix;
45+
using var agentService = app.UseAgentWebservice<MyAgentConfig>(connectorApiPrefix, true);
4646
await agentService.ConnectAsync().ConfigureAwait(false);
4747

4848
// Start app and webservice

examples/dotnet/dotnet-02-message-types-demo/appsettings.json

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// Unique ID of the service. Semantic Workbench will store this event to identify the server
55
// so you should keep the value fixed to match the conversations tracked across service restarts.
66
"ConnectorId": "AgentExample02",
7-
// The endpoint of your service, where semantic workbench will send communications too.
8-
// This should match hostname, port, protocol and path of the web service. You can use
9-
// this also to route semantic workbench through a proxy or a gateway if needed.
10-
"ConnectorEndpoint": "http://127.0.0.1:9102/myagents",
7+
// The host where the connector receives requests sent by the workbench.
8+
// Locally, this is usually "http://127.0.0.1:<some port>"
9+
// On Azure, this will be something like "https://contoso.azurewebsites.net"
10+
// Leave this setting empty to use "127.0.0.1" and autodetect the port in use.
11+
// You can use an env var to set this value, e.g. Workbench__ConnectorHost=https://contoso.azurewebsites.net
12+
"ConnectorHost": "",
13+
// This is the prefix of all the endpoints exposed by the connector
14+
"ConnectorApiPrefix": "/myagents",
1115
// Semantic Workbench endpoint.
1216
"WorkbenchEndpoint": "http://127.0.0.1:3000",
1317
// Name of your agent service
@@ -32,18 +36,6 @@
3236
"AuthType": "ApiKey",
3337
"ApiKey": "..."
3438
},
35-
// Web service settings
36-
"AllowedHosts": "*",
37-
"Kestrel": {
38-
"Endpoints": {
39-
"Http": {
40-
"Url": "http://*:9102"
41-
}
42-
// "Https": {
43-
// "Url": "https://*:19102"
44-
// }
45-
}
46-
},
4739
// .NET Logger settings
4840
"Logging": {
4941
"LogLevel": {

examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageReference Include="Azure.AI.ContentSafety" Version="1.0.0" />
1414
<PackageReference Include="Azure.Identity" Version="1.13.1" />
1515
<PackageReference Include="Microsoft.SemanticKernel" Version="1.26.0" />
16-
<PackageReference Include="Microsoft.SemanticWorkbench.Connector" Version="0.3.241104.1" />
16+
<PackageReference Include="Microsoft.SemanticWorkbench.Connector" Version="0.4.241125.1" />
1717
</ItemGroup>
1818

1919
<PropertyGroup>

examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<PackageReference Include="Azure.AI.ContentSafety" Version="1.0.0" />
1414
<PackageReference Include="Azure.Identity" Version="1.13.1" />
1515
<PackageReference Include="Microsoft.SemanticKernel" Version="1.26.0" />
16+
<PackageReference Include="Microsoft.SemanticWorkbench.Connector" Version="0.4.241125.1" />
1617
</ItemGroup>
1718

1819
<PropertyGroup>
@@ -56,8 +57,4 @@
5657
</PackageReference>
5758
</ItemGroup>
5859

59-
<ItemGroup>
60-
<ProjectReference Include="..\..\..\libraries\dotnet\WorkbenchConnector\WorkbenchConnector.csproj" />
61-
</ItemGroup>
62-
6360
</Project>

0 commit comments

Comments
 (0)