From 1453452889416beb4f94e380119757e222481d88 Mon Sep 17 00:00:00 2001 From: Zhaofeng Xu Date: Wed, 11 Dec 2024 20:39:39 +0800 Subject: [PATCH] refactor: update teamsAdapter --- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- .../Program.cs.tpl | 6 +++--- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- .../custom-copilot-assistant-new/Program.cs.tpl | 6 +++--- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- templates/csharp/custom-copilot-basic/Program.cs.tpl | 6 +++--- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- .../custom-copilot-rag-azure-ai-search/Program.cs.tpl | 6 +++--- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- .../custom-copilot-rag-custom-api/Program.cs.tpl | 6 +++--- .../AdapterWithErrorHandler.cs.tpl | 11 +++++------ .../Controllers/BotController.cs.tpl | 6 +++--- .../custom-copilot-rag-customize/Program.cs.tpl | 6 +++--- 18 files changed, 66 insertions(+), 72 deletions(-) diff --git a/templates/csharp/custom-copilot-assistant-assistants-api/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-assistant-assistants-api/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-assistant-assistants-api/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-assistants-api/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-assistant-assistants-api/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-assistant-assistants-api/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-assistant-assistants-api/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-assistants-api/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-assistant-assistants-api/Program.cs.tpl b/templates/csharp/custom-copilot-assistant-assistants-api/Program.cs.tpl index d81f9b4e5a..bfee97297a 100644 --- a/templates/csharp/custom-copilot-assistant-assistants-api/Program.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-assistants-api/Program.cs.tpl @@ -25,9 +25,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton(); {{#useOpenAI}} diff --git a/templates/csharp/custom-copilot-assistant-new/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-assistant-new/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-assistant-new/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-new/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-assistant-new/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-assistant-new/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-assistant-new/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-new/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-assistant-new/Program.cs.tpl b/templates/csharp/custom-copilot-assistant-new/Program.cs.tpl index c227326b87..7e4b6263dc 100644 --- a/templates/csharp/custom-copilot-assistant-new/Program.cs.tpl +++ b/templates/csharp/custom-copilot-assistant-new/Program.cs.tpl @@ -27,9 +27,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton(); diff --git a/templates/csharp/custom-copilot-basic/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-basic/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-basic/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-basic/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-basic/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-basic/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-basic/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-basic/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-basic/Program.cs.tpl b/templates/csharp/custom-copilot-basic/Program.cs.tpl index f063175448..6e59b52a18 100644 --- a/templates/csharp/custom-copilot-basic/Program.cs.tpl +++ b/templates/csharp/custom-copilot-basic/Program.cs.tpl @@ -27,9 +27,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton(); diff --git a/templates/csharp/custom-copilot-rag-azure-ai-search/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-rag-azure-ai-search/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-rag-azure-ai-search/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-rag-azure-ai-search/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-rag-azure-ai-search/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-rag-azure-ai-search/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-rag-azure-ai-search/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-rag-azure-ai-search/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-rag-azure-ai-search/Program.cs.tpl b/templates/csharp/custom-copilot-rag-azure-ai-search/Program.cs.tpl index 28dedbb168..3f7ca4fe25 100644 --- a/templates/csharp/custom-copilot-rag-azure-ai-search/Program.cs.tpl +++ b/templates/csharp/custom-copilot-rag-azure-ai-search/Program.cs.tpl @@ -27,9 +27,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton(); diff --git a/templates/csharp/custom-copilot-rag-custom-api/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-rag-custom-api/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-rag-custom-api/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-rag-custom-api/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-rag-custom-api/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-rag-custom-api/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-rag-custom-api/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-rag-custom-api/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-rag-custom-api/Program.cs.tpl b/templates/csharp/custom-copilot-rag-custom-api/Program.cs.tpl index 92d1e94a20..f4bdbf08ee 100644 --- a/templates/csharp/custom-copilot-rag-custom-api/Program.cs.tpl +++ b/templates/csharp/custom-copilot-rag-custom-api/Program.cs.tpl @@ -28,9 +28,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton(); diff --git a/templates/csharp/custom-copilot-rag-customize/AdapterWithErrorHandler.cs.tpl b/templates/csharp/custom-copilot-rag-customize/AdapterWithErrorHandler.cs.tpl index 6456467fef..8d9aceb592 100644 --- a/templates/csharp/custom-copilot-rag-customize/AdapterWithErrorHandler.cs.tpl +++ b/templates/csharp/custom-copilot-rag-customize/AdapterWithErrorHandler.cs.tpl @@ -1,14 +1,13 @@ -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Builder.TraceExtensions; using Microsoft.Bot.Schema; +using Microsoft.Teams.AI; namespace {{SafeProjectName}} { - public class AdapterWithErrorHandler : CloudAdapter + public class AdapterWithErrorHandler : TeamsAdapter { - public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) - : base(auth, logger) + public AdapterWithErrorHandler(IConfiguration auth, ILogger logger) + : base(auth, null, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/templates/csharp/custom-copilot-rag-customize/Controllers/BotController.cs.tpl b/templates/csharp/custom-copilot-rag-customize/Controllers/BotController.cs.tpl index 3a737fffc7..d64474b006 100644 --- a/templates/csharp/custom-copilot-rag-customize/Controllers/BotController.cs.tpl +++ b/templates/csharp/custom-copilot-rag-customize/Controllers/BotController.cs.tpl @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Teams.AI; namespace {{SafeProjectName}}.Controllers { @@ -8,10 +8,10 @@ namespace {{SafeProjectName}}.Controllers [ApiController] public class BotController : ControllerBase { - private readonly CloudAdapter Adapter; + private readonly TeamsAdapter Adapter; private readonly IBot Bot; - public BotController(CloudAdapter adapter, IBot bot) + public BotController(TeamsAdapter adapter, IBot bot) { Adapter = adapter; Bot = bot; diff --git a/templates/csharp/custom-copilot-rag-customize/Program.cs.tpl b/templates/csharp/custom-copilot-rag-customize/Program.cs.tpl index d44d271bba..fcb7ad4c78 100644 --- a/templates/csharp/custom-copilot-rag-customize/Program.cs.tpl +++ b/templates/csharp/custom-copilot-rag-customize/Program.cs.tpl @@ -27,9 +27,9 @@ builder.Services.AddSingleton(); -builder.Services.AddSingleton(sp => sp.GetService()); -builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(sp => sp.GetService()); +builder.Services.AddSingleton(sp => sp.GetService()); builder.Services.AddSingleton();