Skip to content

Commit

Permalink
3.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
karamem0 committed Dec 11, 2024
1 parent f8a5001 commit 15bb84a
Show file tree
Hide file tree
Showing 36 changed files with 600 additions and 272 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/build-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@ jobs:
shell: pwsh
run: |
$content = Get-Content -Path ${{env.FILE_PATH}}
$content = $content -replace "{{APP_DOMAIN_NAME}}", "${{vars.APP_DOMAIN_NAME}}"
$content = $content -Replace "{{APP_DOMAIN_NAME}}", "${{vars.APP_DOMAIN_NAME}}"
Out-File -FilePath ${{env.FILE_PATH}} -InputObject $content -Encoding UTF8
env:
FILE_PATH: source/server/Karamem0.Commistant.Bot/wwwroot/index.html
- name: Restore source
run: dotnet restore
working-directory: source/server
- name: Test source
shell: pwsh
run: |
dotnet test `
Karamem0.Commistant.Tests/Karamem0.Commistant.Tests.csproj `
--filter TestCategory=Karamem0.Commistant.Bot `
-p:AltCover=true `
-- NUnit.TestOutputXml=${{github.workspace}}/source/server/test
working-directory: source/server
- name: Build source
shell: pwsh
run: |
Expand All @@ -53,16 +44,3 @@ jobs:
name: bot
path: source/server/build
include-hidden-files: true
- name: Upload test results
uses: enricomi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: source/server/test/*.xml
check_name: Bot test results
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: true
token: ${{secrets.CODECOV_TOKEN}}
slug: karamem0/commistant
22 changes: 0 additions & 22 deletions .github/workflows/build-func.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ jobs:
- name: Restore source
run: dotnet restore
working-directory: source/server
- name: Test source
shell: pwsh
run: |
dotnet test `
Karamem0.Commistant.Tests/Karamem0.Commistant.Tests.csproj `
--filter TestCategory=Karamem0.Commistant.Functions `
-p:AltCover=true `
-- NUnit.TestOutputXml=${{github.workspace}}/source/server/test
working-directory: source/server
- name: Build source
shell: pwsh
run: |
Expand All @@ -45,16 +36,3 @@ jobs:
name: func
path: source/server/build
include-hidden-files: true
- name: Upload test results
uses: enricomi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: source/server/test/*.xml
check_name: Func test results
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: true
token: ${{secrets.CODECOV_TOKEN}}
slug: karamem0/commistant
26 changes: 2 additions & 24 deletions .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
shell: pwsh
run: |
$content = Get-Content -Path ${{env.FILE_PATH}}
$content = $content -replace "{{APP_DOMAIN_NAME}}", "${{vars.APP_DOMAIN_NAME}}"
$content = $content -replace "{{TELEMETRY_CONNECTION_STRING}}", "${{vars.TELEMETRY_CONNECTION_STRING}}"
$content = $content -Replace "{{APP_DOMAIN_NAME}}", "${{vars.APP_DOMAIN_NAME}}"
$content = $content -Replace "{{TELEMETRY_CONNECTION_STRING}}", "${{vars.TELEMETRY_CONNECTION_STRING}}"
Out-File -FilePath ${{env.FILE_PATH}} -InputObject $content -Encoding UTF8
env:
FILE_PATH: source/client/.env
Expand All @@ -42,15 +42,6 @@ jobs:
- name: Restore server
run: dotnet restore
working-directory: source/server
- name: Test source
shell: pwsh
run: |
dotnet test `
Karamem0.Commistant.Tests/Karamem0.Commistant.Tests.csproj `
--filter TestCategory=Karamem0.Commistant.Web `
-p:AltCover=true `
-- NUnit.TestOutputXml=${{github.workspace}}/source/server/test
working-directory: source/server
- name: Build source
shell: pwsh
run: |
Expand All @@ -67,16 +58,3 @@ jobs:
name: web
path: source/server/build
include-hidden-files: true
- name: Upload test results
uses: enricomi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: source/server/test/*.xml
check_name: Web test results
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: true
token: ${{secrets.CODECOV_TOKEN}}
slug: karamem0/commistant
7 changes: 7 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ on:
- develop

jobs:
test:
name: Test
uses: ./.github/workflows/test.yml
secrets: inherit
build-bot:
name: Build bot
needs: test
uses: ./.github/workflows/build-bot.yml
secrets: inherit
with:
Expand All @@ -19,6 +24,7 @@ jobs:
environment: dev
build-web:
name: Build web
needs: test
uses: ./.github/workflows/build-web.yml
secrets: inherit
with:
Expand All @@ -32,6 +38,7 @@ jobs:
environment: dev
build-func:
name: Build func
needs: test
uses: ./.github/workflows/build-func.yml
secrets: inherit
with:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on: workflow_call

jobs:
run:
name: Run
runs-on: ubuntu-latest
steps:
- name: Checkout repos
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Test source
shell: pwsh
run: |
dotnet test `
Karamem0.Commistant.Tests/Karamem0.Commistant.Tests.csproj `
-p:AltCover=true `
-- NUnit.TestOutputXml=${{github.workspace}}/source/server/test
working-directory: source/server
- name: Test results
uses: enricomi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: source/server/test/*.xml
check_name: Bot test results
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: true
token: ${{secrets.CODECOV_TOKEN}}
slug: karamem0/commistant
46 changes: 36 additions & 10 deletions source/server/Karamem0.Commistant.Bot/Bots/ActivityBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Karamem0.Commistant.Bots;
public class ActivityBot(
ConversationState conversationState,
DialogSet dialogSet,
OpenAIService openAIService,
IOpenAIService openAIService,
ILogger<ActivityBot> logger
) : TeamsActivityHandler
{
Expand All @@ -37,7 +37,7 @@ ILogger<ActivityBot> logger

private readonly DialogSet dialogSet = dialogSet;

private readonly OpenAIService openAIService = openAIService;
private readonly IOpenAIService openAIService = openAIService;

private readonly ILogger logger = logger;

Expand All @@ -46,7 +46,11 @@ public override async Task OnTurnAsync(ITurnContext turnContext, CancellationTok
await base.OnTurnAsync(turnContext, cancellationToken);
}

protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
protected override async Task OnMembersAddedAsync(
IList<ChannelAccount> membersAdded,
ITurnContext<IConversationUpdateActivity> turnContext,
CancellationToken cancellationToken = default
)
{
foreach (var member in membersAdded)
{
Expand All @@ -68,7 +72,11 @@ protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersA
await base.OnMembersAddedAsync(membersAdded, turnContext, cancellationToken);
}

protected override async Task OnMembersRemovedAsync(IList<ChannelAccount> membersRemoved, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
protected override async Task OnMembersRemovedAsync(
IList<ChannelAccount> membersRemoved,
ITurnContext<IConversationUpdateActivity> turnContext,
CancellationToken cancellationToken = default
)
{
foreach (var member in membersRemoved)
{
Expand All @@ -80,7 +88,10 @@ protected override async Task OnMembersRemovedAsync(IList<ChannelAccount> member
await base.OnMembersRemovedAsync(membersRemoved, turnContext, cancellationToken);
}

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
protected override async Task OnMessageActivityAsync(
ITurnContext<IMessageActivity> turnContext,
CancellationToken cancellationToken = default
)
{
var participant = await TeamsInfo.GetMeetingParticipantAsync(
turnContext,
Expand All @@ -102,13 +113,28 @@ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivi
{
if (dc.ActiveDialog is null)
{
var arguments = await this.openAIService.GetArgumentsAsync(command, cancellationToken: cancellationToken);
var arguments = await this.openAIService.GetConversationPropertyOptionsAsync(command, cancellationToken);
var result = arguments?.Type switch
{
"会議開始後" => await dc.BeginDialogAsync(nameof(StartMeetingDialog), arguments, cancellationToken: cancellationToken),
"会議終了前" => await dc.BeginDialogAsync(nameof(EndMeetingDialog), arguments, cancellationToken: cancellationToken),
"会議中" => await dc.BeginDialogAsync(nameof(InMeetingDialog), arguments, cancellationToken: cancellationToken),
"初期化" => await dc.BeginDialogAsync(nameof(ResetDialog), cancellationToken: cancellationToken),
Constants.StartMeetingCommand => await dc.BeginDialogAsync(
nameof(StartMeetingDialog),
arguments,
cancellationToken: cancellationToken
),
Constants.EndMeetingCommand => await dc.BeginDialogAsync(
nameof(EndMeetingDialog),
arguments,
cancellationToken: cancellationToken
),
Constants.InMeetingCommand => await dc.BeginDialogAsync(
nameof(InMeetingDialog),
arguments,
cancellationToken: cancellationToken
),
Constants.ResetCommand => await dc.BeginDialogAsync(
nameof(ResetDialog),
cancellationToken: cancellationToken
),
_ => null,
};
if (result is null)
Expand Down
16 changes: 9 additions & 7 deletions source/server/Karamem0.Commistant.Bot/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Karamem0.Commistant;
Expand All @@ -33,7 +34,7 @@ public static class ConfigureServices

public static IServiceCollection AddBots(this IServiceCollection services, IConfiguration configuration)
{
var blobContainerUrl = configuration.GetValue<string>("AzureBotStatesStorageUrl") ?? throw new InvalidOperationException();
var blobContainerUrl = configuration["AzureBotStatesStorageUrl"] ?? throw new InvalidOperationException();
_ = services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFrameworkAuthentication>();
_ = services.AddSingleton<IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();
_ = services.AddSingleton<IStorage>(new BlobsStorage(
Expand All @@ -58,24 +59,25 @@ public static IServiceCollection AddDialogs(this IServiceCollection services)
.Add(provider.GetService<StartMeetingDialog>())
.Add(provider.GetService<EndMeetingDialog>())
.Add(provider.GetService<InMeetingDialog>())
.Add(provider.GetService<ResetDialog>()));
.Add(provider.GetService<ResetDialog>())
);
return services;
}

public static IServiceCollection AddServices(this IServiceCollection services, IConfiguration configuration)
{
var openAIEndpointUrl = configuration.GetValue<string>("AzureOpenAIEndpointUrl") ?? throw new InvalidOperationException();
var openAIModelName = configuration.GetValue<string>("AzureOpenAIModelName") ?? throw new InvalidOperationException();
var openAIEndpointUrl = configuration["AzureOpenAIEndpointUrl"] ?? throw new InvalidOperationException();
var openAIModelName = configuration["AzureOpenAIModelName"] ?? throw new InvalidOperationException();
_ = services.AddScoped(provider => new AzureOpenAIClient(
new Uri(openAIEndpointUrl),
new DefaultAzureCredential()
));
_ = services.AddScoped(provider => new OpenAIService(
provider.GetRequiredService<AzureOpenAIClient>() ?? throw new InvalidOperationException(),
_ = services.AddScoped<IOpenAIService>(provider => new OpenAIService(
provider.GetRequiredService<AzureOpenAIClient>(),
openAIModelName
));
_ = services.AddScoped<QRCodeGenerator>();
_ = services.AddScoped<QrCodeService>();
_ = services.AddScoped<QRCodeService>();
return services;
}

Expand Down
Loading

0 comments on commit 15bb84a

Please sign in to comment.