From bdb74793b6d0d2330c7355f3d6086644f556a3c6 Mon Sep 17 00:00:00 2001 From: Magdalena Majta Date: Thu, 28 Aug 2025 13:22:04 +0200 Subject: [PATCH] Update 0.5.1 --- src/assets/docs/cli.md | 4 +- src/assets/docs/docs-index.json | 13 +++ .../examples/example-chat-basic-anthropic.md | 27 +++++ src/assets/docs/integrations/anthropy.md | 103 ++++++++++++++++++ 4 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 src/assets/docs/examples/example-chat-basic-anthropic.md create mode 100644 src/assets/docs/integrations/anthropy.md diff --git a/src/assets/docs/cli.md b/src/assets/docs/cli.md index 7c6ac91..caebbdb 100644 --- a/src/assets/docs/cli.md +++ b/src/assets/docs/cli.md @@ -14,14 +14,14 @@ The MaIN CLI (`mcli`) is your companion tool for managing AI workflows and servi > - Set execution policies > - Create uninstaller -Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1tAAAAAAABD0eIFVX7HhjwDubuEr1T9w?e=63TNH0) +Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1tAAAAAAABD0eIFVX7HhjwDubuEr1T9w?e=EwVACO) ```bash .\install-mcli.ps1 ``` ### (Linux/Mac) -Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1zAAAAAAABMMmdRp0OgzMEwBFB4Gftvg?e=vz96CR) +Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1zAAAAAAABMMmdRp0OgzMEwBFB4Gftvg?e=GdfloG) > - You might need some sudo permissions to set default model path or run api scripts ```bash diff --git a/src/assets/docs/docs-index.json b/src/assets/docs/docs-index.json index 78accfb..5b4c855 100644 --- a/src/assets/docs/docs-index.json +++ b/src/assets/docs/docs-index.json @@ -199,6 +199,15 @@ "path":"examples/example-chat-basic-groqcloud" } ] + }, + { + "title":"Anthropic Integration", + "children":[ + { + "title":"Basic chat", + "path":"examples/example-chat-basic-anthropic" + } + ] } ] }, @@ -254,6 +263,10 @@ { "title":"GroqCloud", "path":"integrations/groqcloud" + }, + { + "title":"Anthropy", + "path":"integrations/anthropy" } ] } diff --git a/src/assets/docs/examples/example-chat-basic-anthropic.md b/src/assets/docs/examples/example-chat-basic-anthropic.md new file mode 100644 index 0000000..c2bf756 --- /dev/null +++ b/src/assets/docs/examples/example-chat-basic-anthropic.md @@ -0,0 +1,27 @@ +# ๐Ÿ’ฌ Anthropic Chat Example + +The **AnthropicChatExample** demonstrates how to integrate Anthropic's claude-sonnet-4 model into the framework with minimal setup, showcasing how easy it is to leverage Anthropic's capabilities for interactive chat. + +### ๐Ÿ“ Code Example + +```csharp +public async Task Start() +{ + AnthropicExample.Setup(); //We need to provide Anthropic API key + Console.WriteLine("(Anthropic) ChatExample is running!"); + + await AIHub.Chat() + .WithModel("claude-sonnet-4-20250514") + .WithMessage("Write a haiku about programming on Monday morning.") + .CompleteAsync(interactive: true); +} +``` + +## ๐Ÿ”น How It Works +1. **Set up Anthropic API** โ†’ `AnthropicExample.Setup()` (API key is required) +2. **Initialize a chat session** โ†’ `AIHub.Chat()` +3. **Choose a model** โ†’ `.WithModel("claude-sonnet-4-20250514")` +4. **Send a message** โ†’ `.WithMessage("Write a haiku about programming on Monday morning.")` +5. **Run the chat** โ†’ `.CompleteAsync(interactive: true);` + +This example shows how Anthropic's claude-sonnet-4 model can be effortlessly integrated into the framework. With just a few lines of code, developers can enable powerful AI capabilities, thanks to the model's simple setup and ease of use. This makes it an ideal solution for anyone looking to add advanced AI features with minimal effort. \ No newline at end of file diff --git a/src/assets/docs/integrations/anthropy.md b/src/assets/docs/integrations/anthropy.md new file mode 100644 index 0000000..9f68011 --- /dev/null +++ b/src/assets/docs/integrations/anthropy.md @@ -0,0 +1,103 @@ +# ๐Ÿง  Anthropic Integration with MaIN Framework + +This documentation provides a quick guide for integrating Anthropic into your MaIN-based application. The integration process is simple and ensures that everything in the MaIN framework works seamlessly with Anthropic as the backend, without requiring any additional modifications to existing functionality. + +## ๐Ÿš€ Quick Start + +Integrating Anthropic with MaIN requires minimal configuration. All you need to do is specify your Anthropic API key and set the backend type to Anthropic. Once this is done, you can use the full functionality of the MaIN framework, and everything will work as expected, without the need for further adjustments. + +### ๐Ÿ“ Code Example + +#### Using `appsettings.json` + +To configure Anthropic in your `appsettings.json`, add the following section: + +```json +{ + "MaIN": { + "BackendType": "Anthropic", + "AnthropicKey": "" + } +} +``` + +#### Simple Console Initialization + +Alternatively, you can set the backend type and Anthropic key programmatically during initialization using `MaINBootstrapper.Initialize`: + +```csharp +MaINBootstrapper.Initialize(configureSettings: (options) => +{ + options.BackendType = BackendType.Anthropic; + options.AnthropicKey = ""; +}); +``` + +#### Using ServiceBuilder for API-based Use Cases + +If you're setting up MaIN in an API or web-based application (e.g., ASP.NET Core), you can configure it using `ServiceBuilder`: + +```csharp +services.AddMaIN(configuration, (options) => +{ + options.BackendType = BackendType.Anthropic; + options.AnthropicKey = ""; +}); +``` + +### ๐Ÿ“ฆ Using Environment Variables + +If you prefer not to store your Anthropic key in your `appsettings.json` or directly in the code, you can set it using an environment variable. This will automatically be detected by the MaIN framework. + +For example, you can set the `ANTHROPIC_API_KEY` environment variable in different platforms: + +- **On Windows (Command Prompt):** + + ```bash + set ANTHROPIC_API_KEY= + ``` + +- **On Windows (PowerShell):** + + ```bash + $env:ANTHROPIC_API_KEY="" + ``` + +- **On macOS/Linux:** + + ```bash + export ANTHROPIC_API_KEY= + ``` + +This way, you can securely store your API key in the environment without the need for hardcoding it. + +--- + +## ๐Ÿ”น Whatโ€™s Included with Anthropic Integration + +Once you configure Anthropic as the backend, **everything in the MaIN framework works the same way**. This includes all the core functionality such as chat, agents, and data retrieval tasks, which continue to operate without needing any special changes to the logic or structure. + +- **No additional configuration is required** to use Anthropic with any MaIN-based feature. +- Whether you're interacting with chat models, agents, or external data sources, the behavior remains consistent. +- The integration allows MaIN to work seamlessly with Anthropic, enabling you to use the full power of the framework without worrying about backend-specific configurations. + +--- + +## โš ๏ธ Important Considerations + +When using Anthropic models with the MaIN framework, please note these current limitations: + +- Image Generation: Anthropic models do not support direct image generation. Using features that rely on generating images will throw a `NotSupportedException`. +- Embeddings: Anthropic models do not support generating embeddings (e.g., for file processing that requires text vectorization). Any MaIN functionality dependent on embeddings will result in a `NotSupportedException`. + +Please ensure your application's design accounts for these limitations to prevent errors. If these functionalities are crucial for your application, you might want to consider using a different backend, such as OpenAI or Gemini. + +--- + +## ๐Ÿ”ง Features + +- **Simple Setup**: All you need to do is specify your Anthropic key and set the backend type to Anthropic, either via `appsettings.json`, environment variables, or programmatically. +- **Environment Variable Support**: Supports storing your Anthropic key securely as an environment variable, making it easy to configure on different platforms. +- **Seamless Operation**: Once Anthropic is configured, everything within the MaIN framework works identically with Anthropic, with no need for adjustments or special handling for different tasks. + +This integration ensures that your application remains flexible and easy to manage, allowing you to focus on using the features of MaIN while leveraging Anthropicโ€™s powerful capabilities.