lofcz / LlmTornado

One .NET library to consume OpenAI, Anthropic, Cohere, Google, Azure, Groq, and self-hosed APIs.
https://github.com/lofcz/LlmTornado
MIT License
36 stars 12 forks source link

Announcement - v3 and upcoming rebrand #13

Closed lofcz closed 6 months ago

lofcz commented 7 months ago

Recently, Anthropic released a new "Claude 3" family of models, with competitive pricing to OpenAI and acceptable performance on some of our use cases. However, inferring with the new models would take significant time on our side to get working. For this reason, I've added a first batch of cross-vendor compatibility into OpenAiNg and I am working on further improving this functionality.

*In the full v3 release support for Cohere models is also included!

This will come with breaking changes - so far it seems only minor ones, such as renaming all models with a vendor prefix - but I will see once all the changes are done. A migration guide to v3 will be provided.

So far I've got non-streaming & streaming chat requests to work, ~functions/tools are in progress~ supported as of 3.0-beta4. Anthropic ~uses XML-based functions~ (as of 4/24 the schema is similar) while OpenAI expects JSON schema so it's a bit of work to do correctly. For both vendors, functions/tools will be created via a unified strongly-typed model, which we've been using internally for over a half year.

In 3.0-beta3, which is out today the following is possible:

// stream from Anthropic:
Conversation chat = Program.Connect(LLmProviders.Anthropic).Chat.CreateConversation(new ChatRequest
{
    Model = Models.Model.Claude3Sonnet
});
chat.AppendSystemMessage("Pretend you are a dog. Sound authentic.");
chat.AppendUserInput("Who are you?");

Console.WriteLine("Anthropic:");
await chat.StreamResponseFromChatbotAsync(Console.Write);
Console.WriteLine();

// stream from OpenAI:
Conversation chat2 = Program.Connect().Chat.CreateConversation(new ChatRequest
{
    Model = Models.Model.GPT4_Turbo_Preview
});
chat2.AppendSystemMessage("Pretend you are a dog. Sound authentic.");
chat2.AppendUserInput("Who are you?");

Console.WriteLine("OpenAI:");
await chat2.StreamResponseFromChatbotAsync(Console.Write);
Console.WriteLine();

https://github.com/lofcz/OpenAiNg/assets/10260230/11f38cd0-189b-4d63-acb4-8a8d827e34c3

There are many features, which are vendor specific and have no equivalent cross-vendors. For that reason, I'm planning to annotate all fields with vendor support which will be a lot of work. OpenAI will remain a baseline.

I'm also planning to rebrand the library once version 3 draws near to reflect multi-vendor capabilities. The license will remain the same, as stated in the original OpenAiNg mission, the library will be FOSS forever. This will however require all users to uninstall the old package and install the new one, I understand it's an inconvenience hopefully the new features will make up for it.

Lastly, we are including new tests and working to get more API calls covered, to make sure v3 is production ready.

gameshowcrew commented 6 months ago

Any plans for supporting Stability.ai image generation API? (https://platform.stability.ai/)

lofcz commented 6 months ago

@gameshowcrew Yes, I'm planning to support Stability AI. However, text models have priority, so it's more of a 3.1 goal. I'm open to accepting a PR if you want to contribute.

lofcz commented 6 months ago

V3 released today! 🎉