Generate Engaging Text with Adirik/Mamba 2.8B Cognitive Actions

21 Apr 2025
Generate Engaging Text with Adirik/Mamba 2.8B Cognitive Actions

In the ever-evolving landscape of AI-driven applications, the ability to generate coherent and contextually relevant text is invaluable. The Adirik/Mamba 2.8B provides developers with a robust API for text generation, leveraging a state-of-the-art language model optimized for handling information-dense data. With a configuration of 2.8 billion parameters, it enables customizable outputs that can enhance user engagement and content creation. In this article, we will explore how to seamlessly integrate the Generate Text with Mamba 2.8B action into your applications for high-quality text generation.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • API Key: You'll need a valid API key to authenticate your requests to the Mamba 2.8B API.
  • Setup: Familiarity with making HTTP requests in your preferred programming language (in this case, we will use Python).

For authentication, you will typically pass your API key in the request headers, allowing the API to verify your identity and grant access to its functionalities.

Cognitive Actions Overview

Generate Text with Mamba 2.8B

Description: This action generates text based on a given prompt using the Mamba 2.8B model. It allows for adjustable parameters to control the output's randomness, length, and coherence. This flexibility makes it suitable for various applications, from chatbots to content creation tools.

Category: Text Generation

Input

The input schema for this action requires several parameters, of which the prompt is mandatory:

  • prompt (string): The input text to the model. (Example: "How have you been doing lately?")
  • seed (integer, optional): Sets the initial value for the random number generator for reproducibility.
  • topK (integer, optional): The number of top scoring tokens considered during sampling. (Defaults to 1)
  • topP (number, optional): A threshold for cumulative token probability used in nucleus sampling. (Defaults to 1)
  • temperature (number, optional): Controls the diversity of generated text. (Defaults to 1)
  • maximumLength (integer, optional): Specifies the maximum number of tokens to generate, ranging from 1 to 5000. (Defaults to 100)
  • repetitionPenalty (number, optional): Adjusts the likelihood of token repetition. (Defaults to 1.2)

Example Input:

{
  "topK": 1,
  "topP": 1,
  "prompt": "How have you been doing lately?",
  "temperature": 1,
  "maximumLength": 100,
  "repetitionPenalty": 1.2
}

Output

The action typically returns an array of strings, which represent the generated tokens. Here’s an example of the output you might receive:

Example Output:

[
  "\n",
  "",
  "",
  "I'm ",
  "",
  "fine. ",
  "",
  "I've ",
  "had ",
  "a ",
  "lot ",
  "of ",
  "work ",
  "to ",
  "",
  "do, ",
  "but ",
  "",
  "it's ",
  "all ",
  "done ",
  "now ",
  "and ",
  "that ",
  "makes ",
  "me ",
  "",
  "happy! ",
  ":) ",
  "\n",
  "",
  "What ",
  "are ",
  "your ",
  "plans ",
  "for ",
  "the ",
  "future ",
  "",
  "(in ",
  "terms ",
  "",
  "",
  "",
  "career-wise)? ",
  "Do ",
  "plan ",
  "on ",
  "staying ",
  "in ",
  "",
  "academia ",
  "or ",
  "moving ",
  "into ",
  "",
  "",
  "industry/government ",
  "",
  "etc.? \n",
  "  ",
  "",
  "My ",
  "current ",
  "job ",
  "is ",
  "ending ",
  "soon ",
  "so ",
  "my ",
  "next ",
  "step ",
  "will ",
  "be ",
  "looking ",
  "at ",
  "other ",
  "opportunities ",
  "within ",
  "",
  "Academia ",
  "as ",
  "well ",
  "outside ",
  "academics ",
  "- ",
  "maybe ",
  "government ",
  "research ",
  "",
  "institutes ",
  "like ",
  "",
  "",
  "CSIRO ",
  "Australia ",
  "where ",
  "",
  "they're ",
  "trying ",
  "out"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how you might call the Generate Text with Mamba 2.8B action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "bfabd9a1-6f54-474d-9fdf-32d344022379" # Action ID for Generate Text with Mamba 2.8B

# Construct the input payload based on the action's requirements
payload = {
    "topK": 1,
    "topP": 1,
    "prompt": "How have you been doing lately?",
    "temperature": 1,
    "maximumLength": 100,
    "repetitionPenalty": 1.2
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code, replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and modify the endpoint URL as necessary. The action_id should match the ID for the Generate Text with Mamba 2.8B action. The payload is structured according to the input schema we discussed, and the output will provide the generated text tokens.

Conclusion

Integrating the Generate Text with Mamba 2.8B action into your applications enables you to harness the power of advanced text generation. With customizable parameters, you can produce high-quality, contextually relevant content that enhances user engagement in your applications. Start experimenting with different prompts and configurations to see how you can leverage this powerful tool in your projects!