diff --git a/examples/dotnet/dotnet-01-echo-bot/MyWorkbenchConnector.cs b/examples/dotnet/dotnet-01-echo-bot/MyWorkbenchConnector.cs index 74de7098..16012886 100644 --- a/examples/dotnet/dotnet-01-echo-bot/MyWorkbenchConnector.cs +++ b/examples/dotnet/dotnet-01-echo-bot/MyWorkbenchConnector.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. using System.Text.Json; +using Microsoft.AspNetCore.Hosting.Server; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticWorkbench.Connector; @@ -14,11 +15,13 @@ public MyWorkbenchConnector( IServiceProvider sp, IConfiguration appConfig, IAgentServiceStorage storage, + IServer httpServer, ILoggerFactory? loggerFactory = null) : base( workbenchConfig: appConfig.GetSection("Workbench").Get(), defaultAgentConfig: appConfig.GetSection("Agent").Get(), storage, + httpServer: httpServer, loggerFactory?.CreateLogger() ?? new NullLogger()) { this._sp = sp; diff --git a/examples/dotnet/dotnet-01-echo-bot/Program.cs b/examples/dotnet/dotnet-01-echo-bot/Program.cs index 5610efce..663bf162 100644 --- a/examples/dotnet/dotnet-01-echo-bot/Program.cs +++ b/examples/dotnet/dotnet-01-echo-bot/Program.cs @@ -35,8 +35,8 @@ internal static async Task Main(string[] args) app.UseCors(CORSPolicyName); // Connect to workbench backend, keep alive, and accept incoming requests - var connectorEndpoint = app.Configuration.GetSection("Workbench").Get()!.ConnectorEndpoint; - using var agentService = app.UseAgentWebservice(connectorEndpoint, true); + var connectorApiPrefix = app.Configuration.GetSection("Workbench").Get()!.ConnectorApiPrefix; + using var agentService = app.UseAgentWebservice(connectorApiPrefix, true); await agentService.ConnectAsync().ConfigureAwait(false); // Start app and webservice diff --git a/examples/dotnet/dotnet-01-echo-bot/README.md b/examples/dotnet/dotnet-01-echo-bot/README.md index ae1c9059..5ed4753b 100644 --- a/examples/dotnet/dotnet-01-echo-bot/README.md +++ b/examples/dotnet/dotnet-01-echo-bot/README.md @@ -34,8 +34,6 @@ Project Structure * Extend `AgentBase`. * Implement essential methods: * `ReceiveMessageAsync()`: **handles incoming messages using intent detection, plugins, RAG, etc.** - * `GetDefaultConfig()`: provides default settings for new agent instances. - * `ParseConfig()`: deserializes a generic object into MyAgentConfig. * **You can override default implementation for additional customization.** 4. `MyWorkbenchConnector.cs`: * Purpose: custom instance of WorkbenchConnector. diff --git a/examples/dotnet/dotnet-01-echo-bot/appsettings.json b/examples/dotnet/dotnet-01-echo-bot/appsettings.json index da693d53..7ac6ede7 100644 --- a/examples/dotnet/dotnet-01-echo-bot/appsettings.json +++ b/examples/dotnet/dotnet-01-echo-bot/appsettings.json @@ -4,10 +4,14 @@ // Unique ID of the service. Semantic Workbench will store this event to identify the server // so you should keep the value fixed to match the conversations tracked across service restarts. "ConnectorId": "AgentExample01", - // The endpoint of your service, where semantic workbench will send communications too. - // This should match hostname, port, protocol and path of the web service. You can use - // this also to route semantic workbench through a proxy or a gateway if needed. - "ConnectorEndpoint": "http://127.0.0.1:9101/myagents", + // The host where the connector receives requests sent by the workbench. + // Locally, this is usually "http://127.0.0.1:" + // On Azure, this will be something like "https://contoso.azurewebsites.net" + // Leave this setting empty to use "127.0.0.1" and autodetect the port in use. + // You can use an env var to set this value, e.g. Workbench__ConnectorHost=https://contoso.azurewebsites.net + "ConnectorHost": "", + // This is the prefix of all the endpoints exposed by the connector + "ConnectorApiPrefix": "/myagents", // Semantic Workbench endpoint. "WorkbenchEndpoint": "http://127.0.0.1:3000", // Name of your agent service @@ -25,18 +29,6 @@ "ReplyToAgents": false, "CommandsEnabled": true }, - // Web service settings - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://*:9101" - } - // "Https": { - // "Url": "https://*:19101" - // } - } - }, // .NET Logger settings "Logging": { "LogLevel": { diff --git a/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj b/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj index aba6760c..e6271195 100644 --- a/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj +++ b/examples/dotnet/dotnet-01-echo-bot/dotnet-01-echo-bot.csproj @@ -10,7 +10,7 @@ - + diff --git a/examples/dotnet/dotnet-02-message-types-demo/MyWorkbenchConnector.cs b/examples/dotnet/dotnet-02-message-types-demo/MyWorkbenchConnector.cs index 74de7098..16012886 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/MyWorkbenchConnector.cs +++ b/examples/dotnet/dotnet-02-message-types-demo/MyWorkbenchConnector.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. using System.Text.Json; +using Microsoft.AspNetCore.Hosting.Server; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticWorkbench.Connector; @@ -14,11 +15,13 @@ public MyWorkbenchConnector( IServiceProvider sp, IConfiguration appConfig, IAgentServiceStorage storage, + IServer httpServer, ILoggerFactory? loggerFactory = null) : base( workbenchConfig: appConfig.GetSection("Workbench").Get(), defaultAgentConfig: appConfig.GetSection("Agent").Get(), storage, + httpServer: httpServer, loggerFactory?.CreateLogger() ?? new NullLogger()) { this._sp = sp; diff --git a/examples/dotnet/dotnet-02-message-types-demo/Program.cs b/examples/dotnet/dotnet-02-message-types-demo/Program.cs index a1f0fe69..e8cd8ff7 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/Program.cs +++ b/examples/dotnet/dotnet-02-message-types-demo/Program.cs @@ -41,8 +41,8 @@ internal static async Task Main(string[] args) app.UseCors(CORSPolicyName); // Connect to workbench backend, keep alive, and accept incoming requests - var connectorEndpoint = app.Configuration.GetSection("Workbench").Get()!.ConnectorEndpoint; - using var agentService = app.UseAgentWebservice(connectorEndpoint, true); + var connectorApiPrefix = app.Configuration.GetSection("Workbench").Get()!.ConnectorApiPrefix; + using var agentService = app.UseAgentWebservice(connectorApiPrefix, true); await agentService.ConnectAsync().ConfigureAwait(false); // Start app and webservice diff --git a/examples/dotnet/dotnet-02-message-types-demo/appsettings.json b/examples/dotnet/dotnet-02-message-types-demo/appsettings.json index 856e0913..51e79a01 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/appsettings.json +++ b/examples/dotnet/dotnet-02-message-types-demo/appsettings.json @@ -4,10 +4,14 @@ // Unique ID of the service. Semantic Workbench will store this event to identify the server // so you should keep the value fixed to match the conversations tracked across service restarts. "ConnectorId": "AgentExample02", - // The endpoint of your service, where semantic workbench will send communications too. - // This should match hostname, port, protocol and path of the web service. You can use - // this also to route semantic workbench through a proxy or a gateway if needed. - "ConnectorEndpoint": "http://127.0.0.1:9102/myagents", + // The host where the connector receives requests sent by the workbench. + // Locally, this is usually "http://127.0.0.1:" + // On Azure, this will be something like "https://contoso.azurewebsites.net" + // Leave this setting empty to use "127.0.0.1" and autodetect the port in use. + // You can use an env var to set this value, e.g. Workbench__ConnectorHost=https://contoso.azurewebsites.net + "ConnectorHost": "", + // This is the prefix of all the endpoints exposed by the connector + "ConnectorApiPrefix": "/myagents", // Semantic Workbench endpoint. "WorkbenchEndpoint": "http://127.0.0.1:3000", // Name of your agent service @@ -32,18 +36,6 @@ "AuthType": "ApiKey", "ApiKey": "..." }, - // Web service settings - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://*:9102" - } - // "Https": { - // "Url": "https://*:19102" - // } - } - }, // .NET Logger settings "Logging": { "LogLevel": { diff --git a/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj b/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj index 558bb740..ac2abaae 100644 --- a/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj +++ b/examples/dotnet/dotnet-02-message-types-demo/dotnet-02-message-types-demo.csproj @@ -13,7 +13,7 @@ - + diff --git a/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj b/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj index 76de73c4..83dd6ccc 100644 --- a/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj +++ b/examples/dotnet/dotnet-03-simple-chatbot/dotnet-03-simple-chatbot.csproj @@ -13,6 +13,7 @@ + @@ -56,8 +57,4 @@ - - - - \ No newline at end of file