From 513b7d47f49e484a3c7ed65fe319d5075799f6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20=C5=A0t=C3=A1gl?= Date: Sat, 15 Jun 2024 23:08:38 +0200 Subject: [PATCH] cohere: support command-nightly, command-light --- LlmTornado.Demo/ChatDemo.cs | 17 ++-- LlmTornado/Chat/Models/ChatModel.cs | 2 +- .../Chat/Models/Cohere/ChatModelCohere.cs | 4 +- .../Models/Cohere/ChatModelCohereClaude3.cs | 83 +++++++++++++++++++ .../Models/Cohere/ChatModelCohereCoral.cs | 39 --------- 5 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 LlmTornado/Chat/Models/Cohere/ChatModelCohereClaude3.cs delete mode 100644 LlmTornado/Chat/Models/Cohere/ChatModelCohereCoral.cs diff --git a/LlmTornado.Demo/ChatDemo.cs b/LlmTornado.Demo/ChatDemo.cs index 04585b7..f519fd8 100644 --- a/LlmTornado.Demo/ChatDemo.cs +++ b/LlmTornado.Demo/ChatDemo.cs @@ -60,7 +60,7 @@ public static async Task CohereWebSearch() { Conversation chat = Program.Connect(LLmProviders.Cohere).Chat.CreateConversation(new ChatRequest { - Model = ChatModel.Cohere.CommandRPlus, + Model = ChatModel.Cohere.Claude3.CommandRPlus, VendorExtensions = new ChatRequestVendorExtensions(new ChatRequestVendorCohereExtensions([ ChatVendorCohereExtensionConnector.WebConnector ])) @@ -104,7 +104,7 @@ public static async Task AnthropicFunctionsStreamingInteractive() public static async Task CohereFunctionsStreamingInteractive() { - await InternalFunctionsStreamingInteractive(LLmProviders.Cohere, ChatModel.Cohere.CommandRPlus); + await InternalFunctionsStreamingInteractive(LLmProviders.Cohere, ChatModel.Cohere.Claude3.CommandRPlus); } private static async Task InternalFunctionsStreamingInteractive(LLmProviders provider, ChatModel model) @@ -248,7 +248,7 @@ public static async Task CrossVendorFunctionsStreamingInteractive() Console.WriteLine($"Switched to model: {chat.Model.Name}"); continue; case "cohere": - chat.Model = ChatModel.Cohere.CommandRPlus; + chat.Model = ChatModel.Cohere.Claude3.CommandRPlus; Console.WriteLine($"Switched to model: {chat.Model.Name}"); continue; case "anthropic": @@ -320,7 +320,7 @@ public static async Task CohereWebSearchStreaming() { Conversation chat = Program.Connect(LLmProviders.Cohere).Chat.CreateConversation(new ChatRequest { - Model = ChatModel.Cohere.CommandRPlus, + Model = ChatModel.Cohere.Claude3.CommandRPlus, VendorExtensions = new ChatRequestVendorExtensions(new ChatRequestVendorCohereExtensions([ ChatVendorCohereExtensionConnector.WebConnector ])) @@ -402,7 +402,7 @@ public static async Task Cohere() { Conversation chat = Program.Connect(LLmProviders.Cohere).Chat.CreateConversation(new ChatRequest { - Model = ChatModel.Cohere.CommandRPlus + Model = ChatModel.Cohere.Claude3.CommandRPlus }); chat.AppendSystemMessage("Pretend you are a dog. Sound authentic."); chat.AppendUserInput("Who are you?"); @@ -426,11 +426,14 @@ public static async Task AllChatVendors() [ ChatModel.OpenAi.Gpt4.Turbo, ChatModel.Anthropic.Claude3.Sonnet, - ChatModel.Cohere.CommandRPlus + ChatModel.Cohere.Claude3.CommandRPlus, + ChatModel.Google.Gemini.Gemini15Flash ]; foreach (ChatModel model in models) { + Console.WriteLine($"{model.Name}:"); + string? response = await api.Chat.CreateConversation(model) .AppendSystemMessage("You are a fortune teller.") .AppendUserInput("What will my future bring?") @@ -444,7 +447,7 @@ public static async Task CohereStreaming() { Conversation chat = Program.Connect(LLmProviders.Cohere).Chat.CreateConversation(new ChatRequest { - Model = ChatModel.Cohere.CommandRPlus + Model = ChatModel.Cohere.Claude3.CommandRPlus }); chat.AppendSystemMessage("Pretend you are a dog. Sound authentic."); diff --git a/LlmTornado/Chat/Models/ChatModel.cs b/LlmTornado/Chat/Models/ChatModel.cs index 5bb3b4a..1485e47 100644 --- a/LlmTornado/Chat/Models/ChatModel.cs +++ b/LlmTornado/Chat/Models/ChatModel.cs @@ -23,7 +23,7 @@ public class ChatModel : ModelBase /// /// Models from Cohere. /// - public static readonly ChatModelCohereCoral Cohere = new ChatModelCohereCoral(); + public static readonly ChatModelCohere Cohere = new ChatModelCohere(); /// /// Models from Google. diff --git a/LlmTornado/Chat/Models/Cohere/ChatModelCohere.cs b/LlmTornado/Chat/Models/Cohere/ChatModelCohere.cs index b8c14d9..6896ddd 100644 --- a/LlmTornado/Chat/Models/Cohere/ChatModelCohere.cs +++ b/LlmTornado/Chat/Models/Cohere/ChatModelCohere.cs @@ -11,13 +11,13 @@ public class ChatModelCohere: IVendorModelProvider /// /// Coral models. /// - public readonly ChatModelCohereCoral Coral = new ChatModelCohereCoral(); + public readonly ChatModelCohereClaude3 Claude3 = new ChatModelCohereClaude3(); /// /// All known chat models from Cohere. /// public List AllModels { get; } = [ - ..ChatModelCohereCoral.ModelsAll + ..ChatModelCohereClaude3.ModelsAll ]; internal ChatModelCohere() diff --git a/LlmTornado/Chat/Models/Cohere/ChatModelCohereClaude3.cs b/LlmTornado/Chat/Models/Cohere/ChatModelCohereClaude3.cs new file mode 100644 index 0000000..5ada69b --- /dev/null +++ b/LlmTornado/Chat/Models/Cohere/ChatModelCohereClaude3.cs @@ -0,0 +1,83 @@ +using System.Collections.Generic; +using LlmTornado.Code; +using LlmTornado.Code.Models; + +namespace LlmTornado.Chat.Models; + +/// +/// Claude 3 class models from Anthropic. +/// +public class ChatModelCohereClaude3 : IVendorModelClassProvider +{ + /// + /// Command R+ is an instruction-following conversational model that performs language tasks at a higher quality, more reliably, and with a longer context than previous models. It is best suited for complex RAG workflows and multi-step tool use. + /// + public static readonly ChatModel ModelCommandRPlus = new ChatModel("command-r-plus", LLmProviders.Cohere, 128_000); + + /// + /// + /// + public readonly ChatModel CommandRPlus = ModelCommandRPlus; + + /// + /// Be advised that command-nightly is the latest, most experimental, and (possibly) unstable version of its default counterpart. Nightly releases are updated regularly, without warning, and are not recommended for production use. + /// + public static readonly ChatModel ModelCommandNightly = new ChatModel("command-nightly", LLmProviders.Cohere, 128_000); + + /// + /// + /// + public readonly ChatModel CommandNightly = ModelCommandNightly; + + /// + /// An instruction-following conversational model that performs language tasks with high quality, more reliably and with a longer context than our base generative models. + /// + public static readonly ChatModel ModelCommand = new ChatModel("command", LLmProviders.Cohere, 4_000); + + /// + /// + /// + public readonly ChatModel Command = ModelCommand; + + /// + /// A smaller, faster version of command. Almost as capable, but a lot faster. + /// + public static readonly ChatModel ModelCommandLight = new ChatModel("command-light", LLmProviders.Cohere, 4_000); + + /// + /// + /// + public readonly ChatModel CommandLight = ModelCommandLight; + + /// + /// Be advised that command-light-nightly is the latest, most experimental, and (possibly) unstable version of its default counterpart. Nightly releases are updated regularly, without warning, and are not recommended for production use. + /// + public static readonly ChatModel ModelCommandLightNightly = new ChatModel("command-light-nightly", LLmProviders.Cohere, 4_000); + + /// + /// + /// + public readonly ChatModel CommandLightNightly = ModelCommandLightNightly; + + /// + /// All known Coral models from Cohere. + /// + public static readonly List ModelsAll = + [ + ModelCommandRPlus, + ModelCommandNightly, + ModelCommand, + ModelCommandLight, + ModelCommandLightNightly + ]; + + /// + /// + /// + public List AllModels => ModelsAll; + + internal ChatModelCohereClaude3() + { + + } +} \ No newline at end of file diff --git a/LlmTornado/Chat/Models/Cohere/ChatModelCohereCoral.cs b/LlmTornado/Chat/Models/Cohere/ChatModelCohereCoral.cs deleted file mode 100644 index 20a9441..0000000 --- a/LlmTornado/Chat/Models/Cohere/ChatModelCohereCoral.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using LlmTornado.Code; -using LlmTornado.Code.Models; - -namespace LlmTornado.Chat.Models; - -/// -/// Claude 3 class models from Anthropic. -/// -public class ChatModelCohereCoral : IVendorModelClassProvider -{ - /// - /// Command R+ is an instruction-following conversational model that performs language tasks at a higher quality, more reliably, and with a longer context than previous models. It is best suited for complex RAG workflows and multi-step tool use. - /// - public static readonly ChatModel ModelCommandRPlus = new ChatModel("command-r-plus", LLmProviders.Cohere, 128_000); - - /// - /// - /// - public readonly ChatModel CommandRPlus = ModelCommandRPlus; - - /// - /// All known Coral models from Cohere. - /// - public static readonly List ModelsAll = - [ - ModelCommandRPlus - ]; - - /// - /// - /// - public List AllModels => ModelsAll; - - internal ChatModelCohereCoral() - { - - } -} \ No newline at end of file