|
| 1 | +# 🧠 GroqCloud Integration with MaIN Framework |
| 2 | + |
| 3 | +This documentation provides a quick guide for integrating GroqCloud into your MaIN-based application. The integration process is simple and ensures that everything in the MaIN framework works seamlessly with GroqCloud as the backend, without requiring any additional modifications to existing functionality. |
| 4 | + |
| 5 | +## 🚀 Quick Start |
| 6 | + |
| 7 | +Integrating GroqCloud with MaIN requires minimal configuration. All you need to do is specify your GroqCloud API key and set the backend type to GroqCloud. 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 GroqCloud in your `appsettings.json`, add the following section: |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "MaIN": { |
| 18 | + "BackendType": "GroqCloud", |
| 19 | + "GroqCloudKey": "<YOUR_GROQ_KEY>" |
| 20 | + } |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +#### Simple Console Initialization |
| 25 | + |
| 26 | +Alternatively, you can set the backend type and GroqCloud key programmatically during initialization using `MaINBootstrapper.Initialize`: |
| 27 | + |
| 28 | +```csharp |
| 29 | +MaINBootstrapper.Initialize(configureSettings: (options) => |
| 30 | +{ |
| 31 | + options.BackendType = BackendType.GroqCloud; |
| 32 | + options.GroqCloudKey = "<YOUR_GROQ_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.GroqCloud; |
| 44 | + options.GroqCloudKey = "<YOUR_GROQ_KEY>"; |
| 45 | +}); |
| 46 | +``` |
| 47 | + |
| 48 | +### 📦 Using Environment Variables |
| 49 | + |
| 50 | +If you prefer not to store your GroqCloud 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 `GROQ_API_KEY` environment variable in different platforms: |
| 53 | + |
| 54 | +- **On Windows (Command Prompt):** |
| 55 | + |
| 56 | + ```bash |
| 57 | + set GROQ_API_KEY=<YOUR_GROQ_KEY> |
| 58 | + ``` |
| 59 | + |
| 60 | +- **On Windows (PowerShell):** |
| 61 | + |
| 62 | + ```bash |
| 63 | + $env:GROQ_API_KEY="<YOUR_GROQ_KEY>" |
| 64 | + ``` |
| 65 | + |
| 66 | +- **On macOS/Linux:** |
| 67 | + |
| 68 | + ```bash |
| 69 | + export GROQ_API_KEY=<YOUR_GROQ_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 GroqCloud Integration |
| 77 | + |
| 78 | +Once you configure GroqCloud 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 GroqCloud 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 GroqCloud, 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 GroqCloud models with the MaIN framework, please note these current limitations: |
| 89 | + |
| 90 | +- Image Generation: GroqCloud models do not support direct image generation. Using features that rely on generating images will throw a `NotSupportedException`. |
| 91 | +- Embeddings: GroqCloud 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 GroqCloud key and set the backend type to GroqCloud, either via `appsettings.json`, environment variables, or programmatically. |
| 100 | +- **Environment Variable Support**: Supports storing your GroqCloud key securely as an environment variable, making it easy to configure on different platforms. |
| 101 | +- **Seamless Operation**: Once GroqCloud is configured, everything within the MaIN framework works identically with GroqCloud, 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 GroqCloud powerful capabilities. |
0 commit comments