Generate Multilingual Responses with lucataco/ollama-llama3.3 Cognitive Actions

22 Apr 2025
Generate Multilingual Responses with lucataco/ollama-llama3.3 Cognitive Actions

The lucataco/ollama-llama3.3 Cognitive Actions provide developers with powerful tools to generate text outputs across multiple languages using the Meta Llama 3.3 model. This advanced multilingual large language model, equipped with 70 billion parameters, is optimized for multilingual dialogue, ensuring that responses are not only coherent but also aligned with human preferences for helpfulness and safety. The pre-built actions in this spec simplify the process of integrating multilingual capabilities into your applications, saving you time and effort in developing custom solutions.

Prerequisites

To get started with the Cognitive Actions in the lucataco/ollama-llama3.3 spec, you'll need to ensure you have:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON structure for input and output handling.
  • Familiarity with making HTTP requests in your chosen programming language.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Multilingual Responses

The Generate Multilingual Responses action utilizes the Meta Llama 3.3 model to produce text outputs in various languages, making it an essential tool for applications that require multilingual support.

Category: text-generation

Input

The input for this action requires a structured JSON object as defined in the schema below:

{
  "prompt": "Who are you?",
  "topP": 0.95,
  "maxTokens": 512,
  "temperature": 0.7
}
  • prompt (required): The input text provided to the model. This is a required field.
  • topP (optional): Controls the diversity of output, accepting values between 0 and 1. Default is 0.95.
  • maxTokens (optional): The maximum number of tokens to generate in the output. Must be at least 1 (default is 512).
  • temperature (optional): Controls the randomness of the generated output, with values between 0 and 1 (default is 0.7).

Example Input

{
  "topP": 0.95,
  "prompt": "Who are you?",
  "maxTokens": 512,
  "temperature": 0.7
}

Output

The action typically returns a JSON array of strings, representing the generated text. Here’s an example of what you might receive:

[
  "I",
  "'m",
  " an",
  " artificial",
  " intelligence",
  " model",
  " known",
  " as",
  " L",
  "lama",
  ".",
  " L",
  "lama",
  " stands",
  " for",
  " \"",
  "Large",
  " Language",
  " Model",
  " Meta",
  " AI",
  ".\"",
  ""
]

Conceptual Usage Example (Python)

Here's how you might call the Generate Multilingual Responses action using Python:

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 = "55710c57-16f2-4e6c-aa35-cc7e7f9862b6" # Action ID for Generate Multilingual Responses

# Construct the input payload based on the action's requirements
payload = {
    "topP": 0.95,
    "prompt": "Who are you?",
    "maxTokens": 512,
    "temperature": 0.7
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The input JSON payload is constructed based on the action's requirements, and the request is sent to a hypothetical Cognitive Actions execution endpoint.

Conclusion

The Cognitive Actions provided in the lucataco/ollama-llama3.3 spec empower developers to integrate robust multilingual capabilities into their applications seamlessly. By leveraging the Generate Multilingual Responses action, you can enhance user interactions with dynamic text generation that caters to diverse linguistic needs. Explore further use cases, experiment with different input parameters, and unlock the full potential of multilingual dialogue in your projects!