Skip to content

Commit aacc2d8

Browse files
authored
Update 0.5.1 (#11)
1 parent c066ee8 commit aacc2d8

4 files changed

Lines changed: 145 additions & 2 deletions

File tree

src/assets/docs/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ The MaIN CLI (`mcli`) is your companion tool for managing AI workflows and servi
1414
> - Set execution policies
1515
> - Create uninstaller
1616
17-
Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1tAAAAAAABD0eIFVX7HhjwDubuEr1T9w?e=63TNH0)
17+
Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1tAAAAAAABD0eIFVX7HhjwDubuEr1T9w?e=EwVACO)
1818

1919
```bash
2020
.\install-mcli.ps1
2121
```
2222

2323
### (Linux/Mac)
24-
Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1zAAAAAAABMMmdRp0OgzMEwBFB4Gftvg?e=vz96CR)
24+
Download and unpack content from this link [Download](https://1drv.ms/u/c/8dd72529df58a475/EXWkWN8pJdcggI1zAAAAAAABMMmdRp0OgzMEwBFB4Gftvg?e=GdfloG)
2525
> - You might need some sudo permissions to set default model path or run api scripts
2626
2727
```bash

src/assets/docs/docs-index.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@
199199
"path":"examples/example-chat-basic-groqcloud"
200200
}
201201
]
202+
},
203+
{
204+
"title":"Anthropic Integration",
205+
"children":[
206+
{
207+
"title":"Basic chat",
208+
"path":"examples/example-chat-basic-anthropic"
209+
}
210+
]
202211
}
203212
]
204213
},
@@ -254,6 +263,10 @@
254263
{
255264
"title":"GroqCloud",
256265
"path":"integrations/groqcloud"
266+
},
267+
{
268+
"title":"Anthropy",
269+
"path":"integrations/anthropy"
257270
}
258271
]
259272
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 💬 Anthropic Chat Example
2+
3+
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.
4+
5+
### 📝 Code Example
6+
7+
```csharp
8+
public async Task Start()
9+
{
10+
AnthropicExample.Setup(); //We need to provide Anthropic API key
11+
Console.WriteLine("(Anthropic) ChatExample is running!");
12+
13+
await AIHub.Chat()
14+
.WithModel("claude-sonnet-4-20250514")
15+
.WithMessage("Write a haiku about programming on Monday morning.")
16+
.CompleteAsync(interactive: true);
17+
}
18+
```
19+
20+
## 🔹 How It Works
21+
1. **Set up Anthropic API**`AnthropicExample.Setup()` (API key is required)
22+
2. **Initialize a chat session**`AIHub.Chat()`
23+
3. **Choose a model**`.WithModel("claude-sonnet-4-20250514")`
24+
4. **Send a message**`.WithMessage("Write a haiku about programming on Monday morning.")`
25+
5. **Run the chat**`.CompleteAsync(interactive: true);`
26+
27+
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.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# 🧠 Anthropic Integration with MaIN Framework
2+
3+
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.
4+
5+
## 🚀 Quick Start
6+
7+
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.
8+
9+
### 📝 Code Example
10+
11+
#### Using `appsettings.json`
12+
13+
To configure Anthropic in your `appsettings.json`, add the following section:
14+
15+
```json
16+
{
17+
"MaIN": {
18+
"BackendType": "Anthropic",
19+
"AnthropicKey": "<YOUR_ANTHROPIC_KEY>"
20+
}
21+
}
22+
```
23+
24+
#### Simple Console Initialization
25+
26+
Alternatively, you can set the backend type and Anthropic key programmatically during initialization using `MaINBootstrapper.Initialize`:
27+
28+
```csharp
29+
MaINBootstrapper.Initialize(configureSettings: (options) =>
30+
{
31+
options.BackendType = BackendType.Anthropic;
32+
options.AnthropicKey = "<YOUR_ANTHROPIC_KEY>";
33+
});
34+
```
35+
36+
#### Using ServiceBuilder for API-based Use Cases
37+
38+
If you're setting up MaIN in an API or web-based application (e.g., ASP.NET Core), you can configure it using `ServiceBuilder`:
39+
40+
```csharp
41+
services.AddMaIN(configuration, (options) =>
42+
{
43+
options.BackendType = BackendType.Anthropic;
44+
options.AnthropicKey = "<YOUR_ANTHROPIC_KEY>";
45+
});
46+
```
47+
48+
### 📦 Using Environment Variables
49+
50+
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.
51+
52+
For example, you can set the `ANTHROPIC_API_KEY` environment variable in different platforms:
53+
54+
- **On Windows (Command Prompt):**
55+
56+
```bash
57+
set ANTHROPIC_API_KEY=<YOUR_ANTHROPIC_KEY>
58+
```
59+
60+
- **On Windows (PowerShell):**
61+
62+
```bash
63+
$env:ANTHROPIC_API_KEY="<YOUR_ANTHROPIC_KEY>"
64+
```
65+
66+
- **On macOS/Linux:**
67+
68+
```bash
69+
export ANTHROPIC_API_KEY=<YOUR_ANTHROPIC_KEY>
70+
```
71+
72+
This way, you can securely store your API key in the environment without the need for hardcoding it.
73+
74+
---
75+
76+
## 🔹 What’s Included with Anthropic Integration
77+
78+
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.
79+
80+
- **No additional configuration is required** to use Anthropic with any MaIN-based feature.
81+
- Whether you're interacting with chat models, agents, or external data sources, the behavior remains consistent.
82+
- 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.
83+
84+
---
85+
86+
## ⚠️ Important Considerations
87+
88+
When using Anthropic models with the MaIN framework, please note these current limitations:
89+
90+
- Image Generation: Anthropic models do not support direct image generation. Using features that rely on generating images will throw a `NotSupportedException`.
91+
- 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`.
92+
93+
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.
94+
95+
---
96+
97+
## 🔧 Features
98+
99+
- **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.
100+
- **Environment Variable Support**: Supports storing your Anthropic key securely as an environment variable, making it easy to configure on different platforms.
101+
- **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.
102+
103+
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.

0 commit comments

Comments
 (0)