Skip to content

Commit

Permalink
Update to SK 1.0 beta 8 (#638)
Browse files Browse the repository at this point in the history
### Motivation and Context
Keeping up with the latest and greatest

### Description
Update NuGets

### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
  • Loading branch information
glahaye authored Nov 20, 2023
1 parent 6403cc6 commit addea43
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 80 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ By default, Chat Copilot runs locally without authentication, using a guest user

2. **_Issue:_**: Challenges using text completion models, such as `text-davinci-003`

_Solution_: For OpenAI, see [model endpoint compatibility](https://platform.openai.com/docs/models/) for
_Solution_: For OpenAI, see [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) for
the complete list of current models supporting chat completions. For Azure OpenAI, see [model summary table and region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability).

3. **_Issue:_** Localhost SSL certificate errors / CORS errors
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/ChatCopilotIntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions memorypipeline/CopilotChatMemoryPipeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231116.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231117.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta8" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Read more about plugin authentication here: [Plugin authentication](https://plat
### Prerequisites

1. The name of your plugin. This should be identical to the `NameForHuman` in your plugin manifest.
> Please refer to OpenAI for the [manifest requirements](https://platform.openai.com/docs/plugins/getting-started/).
> Please refer to OpenAI for the [manifest requirements](https://platform.openai.com/docs/plugins/getting-started/plugin-manifest).
2. Url of your plugin.
> This should be the root url to your API. Not the manifest url nor the OpenAPI spec url.
3. (Optional) Key of the plugin if it requires one.
Expand Down
2 changes: 1 addition & 1 deletion plugins/shared/PluginManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Plugins.PluginShared;

/// <summary>
/// This class represents the OpenAI plugin manifest:
/// https://platform.openai.com/docs/plugins/getting-started
/// https://platform.openai.com/docs/plugins/getting-started/plugin-manifest
/// </summary>
public class PluginManifest
{
Expand Down
2 changes: 1 addition & 1 deletion shared/CopilotChatShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231116.1-preview" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231117.1-preview" />
<PackageReference Include="Tesseract" Version="5.2.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion webapi/Controllers/ChatArchiveController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private async Task<List<Citation>> GetMemoryRecordsAndAppendToEmbeddingsAsync(
/// </summary>
/// <param name="chatId">The chat id</param>
/// <returns>The list of chat messages in descending order of the timestamp</returns>
private async Task<List<ChatMessage>> GetAllChatMessagesAsync(string chatId)
private async Task<List<CopilotChatMessage>> GetAllChatMessagesAsync(string chatId)
{
return (await this._chatMessageRepository.FindByChatIdAsync(chatId))
.OrderByDescending(m => m.Timestamp).ToList();
Expand Down
2 changes: 1 addition & 1 deletion webapi/Controllers/ChatHistoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task<IActionResult> CreateChatSessionAsync(
await this._sessionRepository.CreateAsync(newChat);

// Create initial bot message
var chatMessage = ChatMessage.CreateBotResponseMessage(
var chatMessage = CopilotChatMessage.CreateBotResponseMessage(
newChat.Id,
this._promptOptions.InitialBotMessage,
string.Empty, // The initial bot message doesn't need a prompt.
Expand Down
4 changes: 2 additions & 2 deletions webapi/Controllers/DocumentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ private async Task<bool> TryStoreMemoryAsync(MemorySource memorySource)
/// <param name="chatId">The target chat-id</param>
/// <param name="documentMessageContent">The document message content</param>
/// <returns>A ChatMessage object if successful, null otherwise</returns>
private async Task<ChatMessage?> TryCreateDocumentUploadMessage(
private async Task<CopilotChatMessage?> TryCreateDocumentUploadMessage(
Guid chatId,
DocumentMessageContent documentMessageContent)
{
var chatMessage = ChatMessage.CreateDocumentMessage(
var chatMessage = CopilotChatMessage.CreateDocumentMessage(
this._authInfo.UserId,
this._authInfo.Name, // User name
chatId.ToString(),
Expand Down
26 changes: 13 additions & 13 deletions webapi/CopilotChatWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.36.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.15.3" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231116.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.AzureCognitiveSearch" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.Qdrant" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Functions.OpenAPI" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.Core" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.MsGraph" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Web" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.SemanticKernel.TemplateEngine.Basic" Version="1.0.0-beta7" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.10.231117.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.AzureCognitiveSearch" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.Qdrant" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Functions.OpenAPI" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.Core" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.MsGraph" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Web" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.SemanticKernel.TemplateEngine.Basic" Version="1.0.0-beta8" />
<PackageReference Include="SharpToken" Version="1.2.12" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
Expand All @@ -42,7 +42,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview1.23165.1">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion webapi/Extensions/ISemanticMemoryClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static async Task StoreDocumentAsync(
new DocumentUploadRequest
{
DocumentId = documentId,
Files = new List<DocumentUploadRequest.UploadedFile> { new DocumentUploadRequest.UploadedFile(fileName, fileContent) },
Files = new List<DocumentUploadRequest.UploadedFile> { new(fileName, fileContent) },
Index = indexName,
Steps = pipelineSteps,
};
Expand Down
8 changes: 4 additions & 4 deletions webapi/Extensions/ServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ internal static IServiceCollection AddCorsPolicy(this IServiceCollection service
public static IServiceCollection AddPersistentChatStore(this IServiceCollection services)
{
IStorageContext<ChatSession> chatSessionStorageContext;
IStorageContext<ChatMessage> chatMessageStorageContext;
IStorageContext<CopilotChatMessage> chatMessageStorageContext;
IStorageContext<MemorySource> chatMemorySourceStorageContext;
IStorageContext<ChatParticipant> chatParticipantStorageContext;

Expand All @@ -193,7 +193,7 @@ public static IServiceCollection AddPersistentChatStore(this IServiceCollection
case ChatStoreOptions.ChatStoreType.Volatile:
{
chatSessionStorageContext = new VolatileContext<ChatSession>();
chatMessageStorageContext = new VolatileContext<ChatMessage>();
chatMessageStorageContext = new VolatileContext<CopilotChatMessage>();
chatMemorySourceStorageContext = new VolatileContext<MemorySource>();
chatParticipantStorageContext = new VolatileContext<ChatParticipant>();
break;
Expand All @@ -210,7 +210,7 @@ public static IServiceCollection AddPersistentChatStore(this IServiceCollection
string directory = Path.GetDirectoryName(fullPath) ?? string.Empty;
chatSessionStorageContext = new FileSystemContext<ChatSession>(
new FileInfo(Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(fullPath)}_sessions{Path.GetExtension(fullPath)}")));
chatMessageStorageContext = new FileSystemContext<ChatMessage>(
chatMessageStorageContext = new FileSystemContext<CopilotChatMessage>(
new FileInfo(Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(fullPath)}_messages{Path.GetExtension(fullPath)}")));
chatMemorySourceStorageContext = new FileSystemContext<MemorySource>(
new FileInfo(Path.Combine(directory, $"{Path.GetFileNameWithoutExtension(fullPath)}_memorysources{Path.GetExtension(fullPath)}")));
Expand All @@ -228,7 +228,7 @@ public static IServiceCollection AddPersistentChatStore(this IServiceCollection
#pragma warning disable CA2000 // Dispose objects before losing scope - objects are singletons for the duration of the process and disposed when the process exits.
chatSessionStorageContext = new CosmosDbContext<ChatSession>(
chatStoreConfig.Cosmos.ConnectionString, chatStoreConfig.Cosmos.Database, chatStoreConfig.Cosmos.ChatSessionsContainer);
chatMessageStorageContext = new CosmosDbContext<ChatMessage>(
chatMessageStorageContext = new CosmosDbContext<CopilotChatMessage>(
chatStoreConfig.Cosmos.ConnectionString, chatStoreConfig.Cosmos.Database, chatStoreConfig.Cosmos.ChatMessagesContainer);
chatMemorySourceStorageContext = new CosmosDbContext<MemorySource>(
chatStoreConfig.Cosmos.ConnectionString, chatStoreConfig.Cosmos.Database, chatStoreConfig.Cosmos.ChatMemorySourcesContainer);
Expand Down
2 changes: 1 addition & 1 deletion webapi/Models/Response/ChatArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ChatArchive
/// <summary>
/// The chat history. It contains all the messages in the conversation with the bot.
/// </summary>
public List<ChatMessage> ChatHistory { get; set; } = new List<ChatMessage>();
public List<CopilotChatMessage> ChatHistory { get; set; } = new List<CopilotChatMessage>();

/// <summary>
/// Chat archive's embeddings.
Expand Down
4 changes: 2 additions & 2 deletions webapi/Models/Response/CreateChatResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class CreateChatResponse
/// Initial bot message.
/// </summary>
[JsonPropertyName("initialBotMessage")]
public ChatMessage InitialBotMessage { get; set; }
public CopilotChatMessage InitialBotMessage { get; set; }

public CreateChatResponse(ChatSession chatSession, ChatMessage initialBotMessage)
public CreateChatResponse(ChatSession chatSession, CopilotChatMessage initialBotMessage)
{
this.ChatSession = chatSession;
this.InitialBotMessage = initialBotMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace CopilotChat.WebApi.Models.Storage;
/// <summary>
/// Information about a single chat message.
/// </summary>
public class ChatMessage : IStorageEntity
public class CopilotChatMessage : IStorageEntity
{
private static readonly JsonSerializerOptions SerializerSettings = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };

Expand All @@ -31,12 +31,7 @@ public enum AuthorRoles
/// <summary>
/// The bot.
/// </summary>
Bot,

/// <summary>
/// The participant who is not the current user nor the bot of the chat.
/// </summary>
Participant
Bot
}

/// <summary>
Expand Down Expand Up @@ -133,7 +128,7 @@ public enum ChatMessageType
/// <param name="authorRole">Role of the author</param>
/// <param name="type">Type of the message</param>
/// <param name="tokenUsage">Total token usages used to generate bot response</param>
public ChatMessage(
public CopilotChatMessage(
string userId,
string userName,
string chatId,
Expand Down Expand Up @@ -164,9 +159,9 @@ public ChatMessage(
/// <param name="content">The message</param>
/// <param name="prompt">The prompt used to generate the message</param>
/// <param name="tokenUsage">Total token usage of response completion</param>
public static ChatMessage CreateBotResponseMessage(string chatId, string content, string prompt, IEnumerable<CitationSource>? citations, IDictionary<string, int>? tokenUsage = null)
public static CopilotChatMessage CreateBotResponseMessage(string chatId, string content, string prompt, IEnumerable<CitationSource>? citations, IDictionary<string, int>? tokenUsage = null)
{
return new ChatMessage("Bot", "Bot", chatId, content, prompt, citations, AuthorRoles.Bot, IsPlan(content) ? ChatMessageType.Plan : ChatMessageType.Message, tokenUsage);
return new CopilotChatMessage("Bot", "Bot", chatId, content, prompt, citations, AuthorRoles.Bot, IsPlan(content) ? ChatMessageType.Plan : ChatMessageType.Message, tokenUsage);
}

/// <summary>
Expand All @@ -176,9 +171,9 @@ public static ChatMessage CreateBotResponseMessage(string chatId, string content
/// <param name="userName">The user name that uploaded the document</param>
/// <param name="chatId">The chat ID that this message belongs to</param>
/// <param name="documentMessageContent">The document message content</param>
public static ChatMessage CreateDocumentMessage(string userId, string userName, string chatId, DocumentMessageContent documentMessageContent)
public static CopilotChatMessage CreateDocumentMessage(string userId, string userName, string chatId, DocumentMessageContent documentMessageContent)
{
return new ChatMessage(userId, userName, chatId, documentMessageContent.ToString(), string.Empty, null, AuthorRoles.User, ChatMessageType.Document);
return new CopilotChatMessage(userId, userName, chatId, documentMessageContent.ToString(), string.Empty, null, AuthorRoles.User, ChatMessageType.Document);
}

/// <summary>
Expand Down Expand Up @@ -243,9 +238,9 @@ public override string ToString()
/// </summary>
/// <param name="json">A json string</param>
/// <returns>A ChatMessage object</returns>
public static ChatMessage? FromString(string json)
public static CopilotChatMessage? FromString(string json)
{
return JsonSerializer.Deserialize<ChatMessage>(json, SerializerSettings);
return JsonSerializer.Deserialize<CopilotChatMessage>(json, SerializerSettings);
}

/// <summary>
Expand Down
Loading

0 comments on commit addea43

Please sign in to comment.