Enhance Your Applications with Dolphin-2.9 Cognitive Actions

24 Apr 2025
Enhance Your Applications with Dolphin-2.9 Cognitive Actions

Integrating AI capabilities into your applications has never been easier with the Dolphin-2.9 Cognitive Actions. Built on the powerful Llama-3-8b framework, these actions provide advanced instruction, conversational, and coding functionalities, enabling developers to create intelligent applications that can interact naturally and perform complex tasks. In this article, we will explore how to utilize the Execute Dolphin-2.9 Tasks action to enhance your applications.

Prerequisites

Before diving into the implementation, you will need to prepare the following:

  1. API Key: You will need an API key to access the Cognitive Actions platform. This key should be included in the request headers for authentication.
  2. Setup: Ensure you have the required libraries installed to make HTTP requests; for Python, the requests library is commonly used.

Authentication can be handled by including your API key in the request headers. Here’s how you can structure the headers:

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

Cognitive Actions Overview

Execute Dolphin-2.9 Tasks

The Execute Dolphin-2.9 Tasks action offers advanced capabilities for generating content through natural language processing. It allows for task execution that is compliant and fast, leveraging the model's conversational abilities and function calling support.

Input

The input for this action consists of several configurable parameters that guide the content generation process. Here’s the schema for the input:

  • topK (integer): Specifies the number of tokens with the highest probabilities to consider when generating output. Default is 50.
  • topP (number): Sets a cumulative probability threshold for token generation. Default is 0.9.
  • prompt (string): The initial text prompt used to guide the model's output generation.
  • maxTokens (integer): The maximum number of tokens to be generated. Default is 512.
  • minTokens (integer): The minimum number of tokens to generate. Default is 0.
  • temperature (number): Controls randomness in the output. Default is 0.6.
  • systemPrompt (string): A predefined text that influences the model's behavior and tone.
  • stopSequences (string): Comma-separated strings that signify termination points for generation.
  • presencePenalty (number): Applies a penalty for token presence to prevent repetition. Default is 0.
  • frequencyPenalty (number): Applies a penalty to reduce token frequency, promoting diverse word choices. Default is 0.

Example Input:

{
  "topK": 50,
  "topP": 0.9,
  "prompt": "Who are you?",
  "maxTokens": 512,
  "minTokens": 0,
  "temperature": 0.6,
  "systemPrompt": "The assistant is named Dolphin. A helpful and friendly AI assistant.",
  "presencePenalty": 0,
  "frequencyPenalty": 0
}

Output

The output of this action is a sequence of tokens (strings) generated based on the provided prompt. The example output might look like this:

[
  "I",
  " am",
  " Dolphin",
  ",",
  " a",
  " helpful",
  " and",
  " friendly",
  " AI",
  " assistant",
  ".",
  " How",
  " can",
  " I",
  " assist",
  " you",
  " today",
  "?",
  ""
]

Conceptual Usage Example (Python)

Here is a conceptual Python code snippet demonstrating how to call the Execute Dolphin-2.9 Tasks action using the input schema discussed above:

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 = "1edd7f7e-8e44-4875-9ec9-409227e5f137"  # Action ID for Execute Dolphin-2.9 Tasks

# Construct the input payload based on the action's requirements
payload = {
    "topK": 50,
    "topP": 0.9,
    "prompt": "Who are you?",
    "maxTokens": 512,
    "minTokens": 0,
    "temperature": 0.6,
    "systemPrompt": "The assistant is named Dolphin. A helpful and friendly AI assistant.",
    "presencePenalty": 0,
    "frequencyPenalty": 0
}

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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the Execute Dolphin-2.9 Tasks action, and the payload is structured according to the specified input schema.

Conclusion

The Dolphin-2.9 Cognitive Actions provide developers with robust tools for integrating AI-driven functionalities into applications. By leveraging the Execute Dolphin-2.9 Tasks action, you can create sophisticated interactions that enhance user experience and streamline task execution. Explore these capabilities further, experiment with different parameters, and unlock the full potential of your applications!