Skip to content

Commit

Permalink
cohere: support command-nightly, command-light
Browse files Browse the repository at this point in the history
  • Loading branch information
lofcz committed Jun 15, 2024
1 parent 30890f5 commit 513b7d4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 49 deletions.
17 changes: 10 additions & 7 deletions LlmTornado.Demo/ChatDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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
]))
Expand Down Expand Up @@ -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?");
Expand All @@ -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?")
Expand All @@ -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.");
Expand Down
2 changes: 1 addition & 1 deletion LlmTornado/Chat/Models/ChatModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ChatModel : ModelBase
/// <summary>
/// Models from Cohere.
/// </summary>
public static readonly ChatModelCohereCoral Cohere = new ChatModelCohereCoral();
public static readonly ChatModelCohere Cohere = new ChatModelCohere();

/// <summary>
/// Models from Google.
Expand Down
4 changes: 2 additions & 2 deletions LlmTornado/Chat/Models/Cohere/ChatModelCohere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public class ChatModelCohere: IVendorModelProvider
/// <summary>
/// Coral models.
/// </summary>
public readonly ChatModelCohereCoral Coral = new ChatModelCohereCoral();
public readonly ChatModelCohereClaude3 Claude3 = new ChatModelCohereClaude3();

/// <summary>
/// All known chat models from Cohere.
/// </summary>
public List<IModel> AllModels { get; } = [
..ChatModelCohereCoral.ModelsAll
..ChatModelCohereClaude3.ModelsAll
];

internal ChatModelCohere()
Expand Down
83 changes: 83 additions & 0 deletions LlmTornado/Chat/Models/Cohere/ChatModelCohereClaude3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System.Collections.Generic;
using LlmTornado.Code;
using LlmTornado.Code.Models;

namespace LlmTornado.Chat.Models;

/// <summary>
/// Claude 3 class models from Anthropic.
/// </summary>
public class ChatModelCohereClaude3 : IVendorModelClassProvider
{
/// <summary>
/// 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.
/// </summary>
public static readonly ChatModel ModelCommandRPlus = new ChatModel("command-r-plus", LLmProviders.Cohere, 128_000);

/// <summary>
/// <inheritdoc cref="ModelCommandRPlus"/>
/// </summary>
public readonly ChatModel CommandRPlus = ModelCommandRPlus;

/// <summary>
/// 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.
/// </summary>
public static readonly ChatModel ModelCommandNightly = new ChatModel("command-nightly", LLmProviders.Cohere, 128_000);

/// <summary>
/// <inheritdoc cref="ModelCommandNightly"/>
/// </summary>
public readonly ChatModel CommandNightly = ModelCommandNightly;

/// <summary>
/// An instruction-following conversational model that performs language tasks with high quality, more reliably and with a longer context than our base generative models.
/// </summary>
public static readonly ChatModel ModelCommand = new ChatModel("command", LLmProviders.Cohere, 4_000);

/// <summary>
/// <inheritdoc cref="ModelCommand"/>
/// </summary>
public readonly ChatModel Command = ModelCommand;

/// <summary>
/// A smaller, faster version of command. Almost as capable, but a lot faster.
/// </summary>
public static readonly ChatModel ModelCommandLight = new ChatModel("command-light", LLmProviders.Cohere, 4_000);

/// <summary>
/// <inheritdoc cref="ModelCommandLight"/>
/// </summary>
public readonly ChatModel CommandLight = ModelCommandLight;

/// <summary>
/// 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.
/// </summary>
public static readonly ChatModel ModelCommandLightNightly = new ChatModel("command-light-nightly", LLmProviders.Cohere, 4_000);

/// <summary>
/// <inheritdoc cref="ModelCommandLightNightly"/>
/// </summary>
public readonly ChatModel CommandLightNightly = ModelCommandLightNightly;

/// <summary>
/// All known Coral models from Cohere.
/// </summary>
public static readonly List<IModel> ModelsAll =
[
ModelCommandRPlus,
ModelCommandNightly,
ModelCommand,
ModelCommandLight,
ModelCommandLightNightly
];

/// <summary>
/// <inheritdoc cref="ModelsAll"/>
/// </summary>
public List<IModel> AllModels => ModelsAll;

internal ChatModelCohereClaude3()
{

}
}
39 changes: 0 additions & 39 deletions LlmTornado/Chat/Models/Cohere/ChatModelCohereCoral.cs

This file was deleted.

0 comments on commit 513b7d4

Please sign in to comment.