diff --git a/examples/Anthropic.Beta.ClientExample/Anthropic.Beta.ClientExample.csproj b/examples/Anthropic.Beta.ClientExample/Anthropic.Beta.ClientExample.csproj deleted file mode 100644 index 76a262de..00000000 --- a/examples/Anthropic.Beta.ClientExample/Anthropic.Beta.ClientExample.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Exe - net8.0 - Anthropic.Beta.ClientExample - enable - disable - - diff --git a/examples/Anthropic.ClientExample/Anthropic.ClientExample.csproj b/examples/Anthropic.ClientExample/Anthropic.ClientExample.csproj deleted file mode 100644 index b973a978..00000000 --- a/examples/Anthropic.ClientExample/Anthropic.ClientExample.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Exe - net8.0 - Anthropic.ClientExample - enable - disable - - diff --git a/examples/Anthropic.Examples.sln b/examples/Anthropic.Examples.sln index 2362337d..c5f116ad 100644 --- a/examples/Anthropic.Examples.sln +++ b/examples/Anthropic.Examples.sln @@ -5,6 +5,14 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagesExample", "MessagesExample\MessagesExample.csproj", "{FA9BAC30-CC15-4D21-99CF-011D5D082FAF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThinkingStreamingExample", "ThinkingStreamingExample\ThinkingStreamingExample.csproj", "{97BE49BD-B144-4967-8718-C79E4521BA3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThinkingExample", "ThinkingExample\ThinkingExample.csproj", "{79DCA526-628F-413B-83DA-F1B92029C065}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagesStreamingExample", "MessagesStreamingExample\MessagesStreamingExample.csproj", "{8CD54CE9-894F-4636-8CAF-D20914CF4014}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatClientExample", "ChatClientExample\ChatClientExample.csproj", "{AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +35,54 @@ Global {FA9BAC30-CC15-4D21-99CF-011D5D082FAF}.Release|x64.Build.0 = Release|Any CPU {FA9BAC30-CC15-4D21-99CF-011D5D082FAF}.Release|x86.ActiveCfg = Release|Any CPU {FA9BAC30-CC15-4D21-99CF-011D5D082FAF}.Release|x86.Build.0 = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|x64.ActiveCfg = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|x64.Build.0 = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|x86.ActiveCfg = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Debug|x86.Build.0 = Debug|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|Any CPU.Build.0 = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|x64.ActiveCfg = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|x64.Build.0 = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|x86.ActiveCfg = Release|Any CPU + {97BE49BD-B144-4967-8718-C79E4521BA3F}.Release|x86.Build.0 = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|x64.ActiveCfg = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|x64.Build.0 = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|x86.ActiveCfg = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Debug|x86.Build.0 = Debug|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|Any CPU.Build.0 = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|x64.ActiveCfg = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|x64.Build.0 = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|x86.ActiveCfg = Release|Any CPU + {79DCA526-628F-413B-83DA-F1B92029C065}.Release|x86.Build.0 = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|x64.ActiveCfg = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|x64.Build.0 = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|x86.ActiveCfg = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Debug|x86.Build.0 = Debug|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|Any CPU.Build.0 = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|x64.ActiveCfg = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|x64.Build.0 = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|x86.ActiveCfg = Release|Any CPU + {8CD54CE9-894F-4636-8CAF-D20914CF4014}.Release|x86.Build.0 = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|x64.ActiveCfg = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|x64.Build.0 = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|x86.ActiveCfg = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Debug|x86.Build.0 = Debug|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|Any CPU.Build.0 = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|x64.ActiveCfg = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|x64.Build.0 = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|x86.ActiveCfg = Release|Any CPU + {AA6ED2E6-A693-4FD8-AF20-1D339FBFBF96}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/examples/MessagesExample/Program.cs b/examples/MessagesExample/Program.cs index 6c8b0fc2..fa724119 100644 --- a/examples/MessagesExample/Program.cs +++ b/examples/MessagesExample/Program.cs @@ -1,10 +1,8 @@ -using System; -using Anthropic; -using Anthropic.Foundry; +using Anthropic; using Anthropic.Models.Messages; // Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables -IAnthropicClient client = new AnthropicClient(); +var client = new AnthropicClient(); // For using the Foundry client, use this instead // AnthropicFoundryClient client = new(new AnthropicFoundryApiKeyCredentials("API-TOKEN", "RESOURCE-NAME")); @@ -21,7 +19,7 @@ var response = await client.Messages.Create(parameters); -var message = String.Join( +var message = string.Join( "", response .Content.Where(message => message.Value is TextBlock) diff --git a/examples/MessagesStreamingExample/Program.cs b/examples/MessagesStreamingExample/Program.cs index 9c803716..7135a31f 100644 --- a/examples/MessagesStreamingExample/Program.cs +++ b/examples/MessagesStreamingExample/Program.cs @@ -1,8 +1,5 @@ -using System; -using Anthropic; +using Anthropic; using Anthropic.Models.Messages; -using Anthropic.Models.Messages.ContentBlockVariants; -using Anthropic.Models.Messages.MessageParamProperties; // Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables AnthropicClient client = new(); diff --git a/examples/ThinkingExample/Program.cs b/examples/ThinkingExample/Program.cs index 18ecef7c..888588e1 100644 --- a/examples/ThinkingExample/Program.cs +++ b/examples/ThinkingExample/Program.cs @@ -1,8 +1,5 @@ -using System; -using Anthropic; +using Anthropic; using Anthropic.Models.Messages; -using Anthropic.Models.Messages.MessageParamProperties; -using ContentBlockVariants = Anthropic.Models.Messages.ContentBlockVariants; // Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables AnthropicClient client = new(); @@ -22,21 +19,19 @@ foreach (ContentBlock block in response.Content) { - if (block.TryPickThinking(out ThinkingBlock thinking)) + if (block.TryPickThinking(out ThinkingBlock? thinking)) { Console.WriteLine($"Thinking: {thinking.Thinking}"); } - else if (block.TryPickText(out TextBlock text)) + else if (block.TryPickText(out TextBlock? text)) { Console.WriteLine($"Text: {text.Text}"); } } -var message = String.Join( +var message = string.Join( "", - response - .Content.OfType() - .Select((textBlock) => textBlock.Value.Text) + response.Content.Select(e => e.Value).OfType().Select((textBlock) => textBlock.Text) ); Console.WriteLine(message); diff --git a/examples/ThinkingStreamingExample/Program.cs b/examples/ThinkingStreamingExample/Program.cs index cb15d3fa..f965b96e 100644 --- a/examples/ThinkingStreamingExample/Program.cs +++ b/examples/ThinkingStreamingExample/Program.cs @@ -1,7 +1,5 @@ -using System; -using Anthropic; +using Anthropic; using Anthropic.Models.Messages; -using Anthropic.Models.Messages.MessageParamProperties; // Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables AnthropicClient client = new(); diff --git a/scripts/build b/scripts/build index 3ce1e776..ab5f1179 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,5 @@ set -e cd "$(dirname "$0")/.." echo "==> Running dotnet build" -dotnet build +dotnet build Anthropic.sln +dotnet build examples/Anthropic.Examples.sln