Generate Dynamic Text with the Neuronovo-7B Cognitive Actions

24 Apr 2025
Generate Dynamic Text with the Neuronovo-7B Cognitive Actions

In the world of natural language processing, the ability to generate coherent and contextually relevant text has become increasingly valuable. The Neuronovo-7B model, part of the tomasmcm/neuronovo-7b-v0.3 API, leverages advanced machine learning techniques to produce human-like text responses based on given prompts. This article will guide developers on how to integrate the Cognitive Action for text generation into their applications, enhancing user interactions through intelligent dialogue.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.
  • Familiarity with Python programming for testing and implementation.

To authenticate your API requests, you will typically include your API key in the request headers, allowing secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate Text with Neuronovo Model

The Generate Text with Neuronovo Model action allows developers to harness the power of the Neuronovo-7B model to generate text based on user-defined prompts. This action is particularly useful for applications requiring conversational AI, content creation, and interactive storytelling.

  • Category: text-generation
  • Description: Utilize the Neuronovo/neuronovo-7B-v0.3 model, an advanced, fine-tuned large language model, to generate text. This model is enhanced with diverse datasets for improved dialogue and interactive capabilities, tailored to natural language understanding and response generation.

Input

The input schema for this action requires a prompt and allows for several optional parameters that control the text generation behavior:

  • prompt (required): The initial text to start the model's response generation.
  • maxTokens (optional): The maximum number of tokens allowed in the generated text per output sequence. Default is 128.
  • temperature (optional): A float to adjust randomness in token selection (0.01 to 5). Default is 0.8.
  • topK (optional): Limits the number of top scoring tokens considered during sampling. Default is -1 (consider all).
  • topP (optional): Represents the probability threshold for cumulative tokens to consider (0.01 to 1). Default is 0.95.
  • presencePenalty (optional): Penalizes tokens based on their prior presence (range -5 to 5). Default is 0.
  • frequencyPenalty (optional): Reduces the likelihood of repeating tokens based on their frequency (range -5 to 5). Default is 0.
  • stop (optional): A string that, when generated, will stop the completion process.

Example Input:

{
  "topK": -1,
  "topP": 0.95,
  "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nGive me a tasty recipe for some noodle dish.<|im_end|>\n<|im_start|assistant\n",
  "maxTokens": 256,
  "temperature": 0.8,
  "presencePenalty": 0,
  "frequencyPenalty": 0
}

Output

The output of this action is a coherent text response generated by the model based on the input prompt. It typically returns a string of text that fulfills the request made in the prompt.

Example Output:

Here is a delicious and flavorful recipe for Chicken Pad Thai, a popular Thai noodle dish. It serves 4 people and takes approximately 30 minutes to prepare and cook.
...

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet demonstrating how to call the Generate Text 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 = "90e9da85-ecfc-459f-b2b2-c3c4cca8fb1e" # Action ID for Generate Text with Neuronovo Model

# Construct the input payload based on the action's requirements
payload = {
    "topK": -1,
    "topP": 0.95,
    "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nGive me a tasty recipe for some noodle dish.<|im_end|>\n<|im_start|assistant\n",
    "maxTokens": 256,
    "temperature": 0.8,
    "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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and ensure the endpoint URL is correct. The input payload aligns with the schema required for the Generate Text action.

Conclusion

Integrating the Generate Text with Neuronovo Model action into your application can dramatically enhance user experience by providing intelligent and contextually relevant responses. By configuring the input parameters effectively, you can tailor the text generation to meet your specific needs. As you explore further, consider implementing additional features such as conversation history management or integrating with other APIs to create a rich interactive experience. Happy coding!