Enhance Your Applications with Hermes-2 Theta Cognitive Actions

24 Apr 2025
Enhance Your Applications with Hermes-2 Theta Cognitive Actions

Integrating advanced AI models into applications can dramatically enhance user experience and functionality. The lucataco/hermes-2-theta-llama-3-8b API provides a powerful Cognitive Action that leverages the Hermes-2 Theta model, an advanced experimental AI combining Nous Research's Hermes 2 Pro and Meta's Llama-3 Instruct model. This model is refined with Reinforcement Learning from Human Feedback (RLHF) for improved performance and dialogue capabilities, making it an excellent choice for developers looking to implement engaging and interactive chatbot experiences.

Prerequisites

Before diving into the integration, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • A basic understanding of JSON structure and API requests.

Authentication typically involves passing the API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Engage Hermes-2 Theta Model

This action utilizes the Hermes-2 Theta model to generate text based on a provided prompt. It is particularly useful for creating chatbots and other applications that benefit from natural language understanding and generation.

Input

The input for this action requires a structured JSON object with several fields, each designed to optimize the output. Here’s a breakdown of the input schema:

  • topK (integer): Specifies the number of top probability tokens to consider in the output generation. Default is 50.
  • topP (number): Sets a probability limit for generating the output. Default is 0.9.
  • prompt (string): The initial text input to guide the model. Default is an empty string.
  • maxTokens (integer): Limits the number of tokens the model may generate. Default is 512.
  • minTokens (integer): Sets the minimum number of tokens the model is required to generate. Default is 0.
  • temperature (number): Controls randomness in output. Default is 0.6.
  • systemPrompt (string): An instruction for the model's behavior. Default is "You are a helpful assistant."
  • stopSequences (string): Specific character sequences that cause the model to stop generating text.
  • presencePenalty (number): Discourages repeating tokens in the input. Default is 0.
  • frequencyPenalty (number): Discourages repetition of tokens in the output. Default is 0.

Example Input:

{
  "topK": 50,
  "topP": 0.9,
  "prompt": "Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.",
  "maxTokens": 512,
  "minTokens": 0,
  "temperature": 0.6,
  "systemPrompt": "You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.",
  "presencePenalty": 0,
  "frequencyPenalty": 0
}

Output

The output of this action is typically a list of strings representing the generated text. The output can contain creative narratives or dialogues based on the input prompt.

Example Output:

[
  "G",
  "oku",
  " was",
  " med",
  "itating",
  " in",
  " his",
  " usual",
  " spot",
  " on",
  " a",
  " rocky",
  " out",
  "cro",
  "pping",
  " overlooking",
  " the",
  " Earth",
  " when",
  " he",
  " sensed",
  " a",
  " sudden",
  " surge",
  " of",
  " energy",
  " unlike",
  " anything",
  " he",
  "'d",
  " ever",
  " felt",
  " before",
  ".",
  ...
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Engage Hermes-2 Theta Model 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 = "8ad62861-ae5f-4d1e-912f-53e86ed29c2d"  # Action ID for Engage Hermes-2 Theta Model

# Construct the input payload based on the action's requirements
payload = {
    "topK": 50,
    "topP": 0.9,
    "prompt": "Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.",
    "maxTokens": 512,
    "minTokens": 0,
    "temperature": 0.6,
    "systemPrompt": "You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.",
    "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 snippet, you will need to replace YOUR_COGNITIVE_ACTIONS_API_KEY and the endpoint URL with your actual API key and endpoint. The payload structure directly reflects the required input fields for the action, ensuring proper API integration.

Conclusion

The Hermes-2 Theta Cognitive Action serves as a powerful tool for developers looking to enrich their applications with advanced AI-driven text generation. By leveraging this action, you can create engaging chatbots, generate creative content, and much more. Consider exploring different prompts and configurations to maximize the capabilities of the Hermes-2 Theta model in your projects. Happy coding!