From ab826da2613a465f880dbd4aff6aaa7bf1486bd3 Mon Sep 17 00:00:00 2001 From: Rainer Date: Mon, 9 Sep 2024 07:27:35 +0200 Subject: [PATCH] Update deps --- labs/035-assistants-dotnet/Functions.cs | 1 + .../035-assistants-dotnet/OpenAIExtensions.cs | 12 +++--- labs/Directory.Packages.props | 6 +-- labs/HandsOnLabs.sln | 38 +++++++++---------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/labs/035-assistants-dotnet/Functions.cs b/labs/035-assistants-dotnet/Functions.cs index e388142..1d9fe52 100644 --- a/labs/035-assistants-dotnet/Functions.cs +++ b/labs/035-assistants-dotnet/Functions.cs @@ -4,6 +4,7 @@ using Microsoft.Data.SqlClient; using OpenAI.Assistants; using OpenAI.Chat; +#pragma warning disable OPENAI001 namespace AssistantsDotNet; diff --git a/labs/035-assistants-dotnet/OpenAIExtensions.cs b/labs/035-assistants-dotnet/OpenAIExtensions.cs index f312cf1..f5a51bc 100644 --- a/labs/035-assistants-dotnet/OpenAIExtensions.cs +++ b/labs/035-assistants-dotnet/OpenAIExtensions.cs @@ -10,9 +10,11 @@ static class OpenAIExtensions { public static async Task FindAssistantByName(this AssistantClient client, string name) { - await foreach (var assistant in client.GetAssistantsAsync()) + await foreach (var assistants in client.GetAssistantsAsync()) { - if (assistant.Name == name) { return assistant; } + foreach (var assistant in assistants.Values) { + if (assistant.Name == name) { return assistant; } + } } return null; @@ -41,7 +43,7 @@ public static async Task CreateOrUpdate(this AssistantClient client, public static async IAsyncEnumerable AddMessageAndRunToCompletion(this AssistantClient client, string threadId, string assistantId, string message, Func>? functionCallback = null) { - await client.CreateMessageAsync(threadId, [message]); + await client.CreateMessageAsync(threadId, MessageRole.User, [message]); var asyncUpdate = client.CreateRunStreamingAsync(threadId, assistantId); ThreadRun? currentRun; @@ -98,9 +100,9 @@ public static async IAsyncEnumerable AddMessageAndRunToCompletion(this A public static async Task GetLatestMessage(this AssistantClient client, string threadId) { - await foreach(var msg in client.GetMessagesAsync(threadId, ListOrder.NewestFirst)) + await foreach(var msgs in client.GetMessagesAsync(threadId, new MessageCollectionOptions() { Order = ListOrder.NewestFirst })) { - return msg.Content[0].Text; + return msgs.Values[0]?.Content[0].Text; } return null; diff --git a/labs/Directory.Packages.props b/labs/Directory.Packages.props index c4f8423..cfaab0d 100644 --- a/labs/Directory.Packages.props +++ b/labs/Directory.Packages.props @@ -4,8 +4,8 @@ - - - + + + \ No newline at end of file diff --git a/labs/HandsOnLabs.sln b/labs/HandsOnLabs.sln index db9fb34..c4614bd 100644 --- a/labs/HandsOnLabs.sln +++ b/labs/HandsOnLabs.sln @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "010-basics", "010-basics", "{663030A0-0A93-4565-BEE2-2F356E49FEFA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "010-basics-dotnet", "010-basics-dotnet", "{ECF40993-4AD0-441E-93E7-F80E62465259}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBasicsDotNet", "010-basics-dotnet\ApiBasicsDotNet\ApiBasicsDotNet.csproj", "{99F0BCCA-ED5E-4654-937F-C79E7E2130C4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBasicsDotNet", "010-basics-dotnet\ApiBasicsDotNet\ApiBasicsDotNet.csproj", "{6569C5F1-0230-43E5-9041-1CD4C214F748}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "020-functions", "020-functions", "{468B4675-71B9-4397-8225-4DDEC46DD4B0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "020-functions-dotnet", "020-functions-dotnet", "{FFD3A9CA-B05C-4519-921C-2ECFFC523D74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionCallingDotNet", "020-functions-dotnet\FunctionCallingDotNet\FunctionCallingDotNet.csproj", "{A71026F5-ACF4-49FF-94C4-73006234E737}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionCallingDotNet", "020-functions-dotnet\FunctionCallingDotNet\FunctionCallingDotNet.csproj", "{BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "035-assistants-dotnet", "035-assistants-dotnet\035-assistants-dotnet.csproj", "{4410FBFF-81EE-44E5-82CC-82E619380D87}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "035-assistants-dotnet", "035-assistants-dotnet\035-assistants-dotnet.csproj", "{E3AACF07-5434-4B5C-820D-B5E1A661C6D5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -22,21 +22,21 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {99F0BCCA-ED5E-4654-937F-C79E7E2130C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {99F0BCCA-ED5E-4654-937F-C79E7E2130C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {99F0BCCA-ED5E-4654-937F-C79E7E2130C4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {99F0BCCA-ED5E-4654-937F-C79E7E2130C4}.Release|Any CPU.Build.0 = Release|Any CPU - {A71026F5-ACF4-49FF-94C4-73006234E737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A71026F5-ACF4-49FF-94C4-73006234E737}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A71026F5-ACF4-49FF-94C4-73006234E737}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A71026F5-ACF4-49FF-94C4-73006234E737}.Release|Any CPU.Build.0 = Release|Any CPU - {4410FBFF-81EE-44E5-82CC-82E619380D87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4410FBFF-81EE-44E5-82CC-82E619380D87}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4410FBFF-81EE-44E5-82CC-82E619380D87}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4410FBFF-81EE-44E5-82CC-82E619380D87}.Release|Any CPU.Build.0 = Release|Any CPU + {6569C5F1-0230-43E5-9041-1CD4C214F748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6569C5F1-0230-43E5-9041-1CD4C214F748}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6569C5F1-0230-43E5-9041-1CD4C214F748}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6569C5F1-0230-43E5-9041-1CD4C214F748}.Release|Any CPU.Build.0 = Release|Any CPU + {BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC}.Release|Any CPU.Build.0 = Release|Any CPU + {E3AACF07-5434-4B5C-820D-B5E1A661C6D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3AACF07-5434-4B5C-820D-B5E1A661C6D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3AACF07-5434-4B5C-820D-B5E1A661C6D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3AACF07-5434-4B5C-820D-B5E1A661C6D5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution - {99F0BCCA-ED5E-4654-937F-C79E7E2130C4} = {663030A0-0A93-4565-BEE2-2F356E49FEFA} - {A71026F5-ACF4-49FF-94C4-73006234E737} = {468B4675-71B9-4397-8225-4DDEC46DD4B0} + {6569C5F1-0230-43E5-9041-1CD4C214F748} = {ECF40993-4AD0-441E-93E7-F80E62465259} + {BF6F92A4-E8B9-4DCB-A851-3E67CEAC4DDC} = {FFD3A9CA-B05C-4519-921C-2ECFFC523D74} EndGlobalSection EndGlobal