Skip to content

Commit

Permalink
Revert "refactor: update teamsAdapter (#12902)"
Browse files Browse the repository at this point in the history
This reverts commit f33089c.
  • Loading branch information
xzf0587 authored Dec 12, 2024
1 parent f33089c commit 2460ddb
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();
{{#useOpenAI}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
6 changes: 3 additions & 3 deletions templates/csharp/custom-copilot-assistant-new/Program.cs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
6 changes: 3 additions & 3 deletions templates/csharp/custom-copilot-basic/Program.cs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
6 changes: 3 additions & 3 deletions templates/csharp/custom-copilot-rag-custom-api/Program.cs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.AI;

namespace {{SafeProjectName}}
{
public class AdapterWithErrorHandler : TeamsAdapter
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(IConfiguration auth, ILogger<TeamsAdapter> logger)
: base(auth, null, logger)
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Teams.AI;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace {{SafeProjectName}}.Controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly TeamsAdapter Adapter;
private readonly CloudAdapter Adapter;
private readonly IBot Bot;
public BotController(TeamsAdapter adapter, IBot bot)
public BotController(CloudAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
Expand Down
6 changes: 3 additions & 3 deletions templates/csharp/custom-copilot-rag-customize/Program.cs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFramew
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<TeamsAdapter>());
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<BotAdapter>(sp => sp.GetService<CloudAdapter>());

builder.Services.AddSingleton<IStorage, MemoryStorage>();

Expand Down

0 comments on commit 2460ddb

Please sign in to comment.