Skip to content

Commit

Permalink
Rename RoomThread to GroupThread (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand authored Jan 31, 2024
1 parent 311f946 commit 11fcc3d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
9 changes: 9 additions & 0 deletions SemanticKernel.Assistants.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,32 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Publish|Any CPU = Publish|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Publish|Any CPU.Build.0 = Publish|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Release|Any CPU.Build.0 = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Publish|Any CPU.ActiveCfg = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Publish|Any CPU.Build.0 = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Release|Any CPU.Build.0 = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Publish|Any CPU.ActiveCfg = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Publish|Any CPU.Build.0 = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Release|Any CPU.Build.0 = Release|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Publish|Any CPU.Build.0 = Publish|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEAC598F-3763-467A-904D-C0C098DF7B9E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion src/Assistants.Tests/HarnessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public async Task RoomMeetingSampleTestAsync(string prompt)

var logger = this._loggerFactory.CreateLogger("Tests");

var thread = Assistant.CreateRoomThread(butler, mathematician);
var thread = Assistant.CreateGroupThread(butler, mathematician);

thread.OnMessageReceived += (object? sender, ChatMessageContent message) =>
{
Expand Down
9 changes: 3 additions & 6 deletions src/Assistants/Assistant.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Copyright (c) Kevin BEAUGRAND. All rights reserved.

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using SemanticKernel.Assistants.GroupThread;
using SemanticKernel.Assistants.Models;
using SemanticKernel.Assistants.RoomThread;
using System.Collections.Generic;
using System.IO;
using YamlDotNet.Serialization;

namespace SemanticKernel.Assistants;

Expand Down Expand Up @@ -89,9 +86,9 @@ internal Assistant(AssistantModel model,
/// </summary>
/// <param name="agents">The collaborative agents.</param>
/// <returns></returns>
public static IRoomThread CreateRoomThread(params IAssistant[] agents)
public static IGroupThread CreateGroupThread(params IAssistant[] agents)
{
return new RoomThread.RoomThread(agents);
return new GroupThread.GroupThread(agents);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
using System.Reflection;
using System.Threading.Tasks;

namespace SemanticKernel.Assistants.RoomThread;
namespace SemanticKernel.Assistants.GroupThread;

internal class RoomThread : IRoomThread
internal class GroupThread : IGroupThread
{
public IReadOnlyList<ChatMessageContent> ChatMessages => throw new NotImplementedException();

private readonly Dictionary<IAssistant, IThread> _assistantThreads = new();

public event EventHandler<ChatMessageContent>? OnMessageReceived;

internal RoomThread(IEnumerable<IAssistant> agents)
internal GroupThread(IEnumerable<IAssistant> agents)
{
this._assistantThreads = agents.ToDictionary(agent => agent, agent =>
{
var thread = agent.CreateThread();
thread.AddSystemMessage(this.GetRoomInstructions()(new
thread.AddSystemMessage(this.GetInstructions()(new
{
agent,
participants = agents
Expand Down Expand Up @@ -71,9 +71,9 @@ await Task.WhenAll(this._assistantThreads
})).ConfigureAwait(false);
}

private HandlebarsTemplate<object, object> GetRoomInstructions()
private HandlebarsTemplate<object, object> GetInstructions()
{
var roomInstructionTemplate = this.ReadManifestResource("RoomMeetingInstructions.handlebars");
var roomInstructionTemplate = this.ReadManifestResource("GroupThreadInstructions.handlebars");

IHandlebars handlebarsInstance = Handlebars.Create(
new HandlebarsConfiguration
Expand All @@ -88,7 +88,7 @@ private HandlebarsTemplate<object, object> GetRoomInstructions()

private string ReadManifestResource(string resourceName)
{
var promptStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{typeof(RoomThread).Namespace}.{resourceName}")!;
var promptStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{typeof(GroupThread).Namespace}.{resourceName}")!;

using var reader = new StreamReader(promptStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
using System;
using System.Threading.Tasks;

namespace SemanticKernel.Assistants.RoomThread;
namespace SemanticKernel.Assistants.GroupThread;

/// <summary>
/// Interface representing a room thread.
/// </summary>
public interface IRoomThread
public interface IGroupThread
{
/// <summary>
/// Adds the user message to the discussion.
Expand Down
10 changes: 0 additions & 10 deletions src/Assistants/RoomThread/SpectatorAgent.yaml

This file was deleted.

16 changes: 8 additions & 8 deletions src/Assistants/SemanticKernel.Assistants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@

<ItemGroup>
<PackageReference Include="Handlebars.Net" />
<PackageReference Include="Microsoft.Extensions.Configuration"/>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.SemanticKernel" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" />
<PackageReference Include="Microsoft.SemanticKernel.Core" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.Handlebars" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.OpenAI" />
<PackageReference Include="Microsoft.SemanticKernel" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" />
<PackageReference Include="Microsoft.SemanticKernel.Core" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.Handlebars" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.OpenAI" />
<PackageReference Include="xunit.extensibility.execution" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="YamlDotNet" />
</ItemGroup>

<ItemGroup>
<None Remove="RoomMeetingInstructions.handlebars" />
<EmbeddedResource Include="RoomThread\RoomMeetingInstructions.handlebars" />
<EmbeddedResource Include="GroupThread\GroupThreadInstructions.handlebars" />
</ItemGroup>

</Project>
Expand Down

0 comments on commit 11fcc3d

Please sign in to comment.