Condense Tokens

Condense long text sequences of natural language tokens into soft tokens.


POST/v1/47/compress/text

POST /47/compress/text

Required attributes

  • Name
    text
    Type
    string
    Description

    Text to be compressed

    Default: In machine learning, the perceptron is an algorithm for supervised learning of binary classifiers. A binary classifier is a function which can decide whether or not an input, represented by a vector of numbers, belongs to some specific class. It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based on a linear predictor function combining a set of weights with the feature vector.

Optional attributes

  • Name
    ooc_status_code
    Type
    string
    Description

    Status code to return when user runs out of credits (208 or 402)

  • Name
    top_node_performance
    Type
    number
    Description

    Performance parameter for compression

    Default: 0.1

Request

POST
/v1/47/compress/text
curl -X POST "https://api.bitmind.ai/oracle/v1/47/compress/text" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "ooc_status_code": "\"example-ooc_status_code\"",
    "text": "In machine learning, the perceptron is an algorithm for supervised learning of binary classifiers. A binary classifier is a function which can decide whether or not an input, represented by a vector of numbers, belongs to some specific class. It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based on a linear predictor function combining a set of weights with the feature vector.",
    "top_node_performance": 0.1
  }'

Response

{
  "compressed": "perceptron utilized in machine learning is a supervised learning algorithm designed for binary classification. involves a function that categorizes a numerical input vector to determine its membership in a particular class. As a linear classifier it predicts based on a linear predictor function combines a feature vector with set of weights.",
  "metadata": {
    "original_tkn_count": 80,
    "compressed_tkn_count": 62,
    "credit_cost": 9.000000000000001e-7,
    "condensed_pct": 22.5
  }
}

POST/v1/47/compress/messages

POST /47/compress/messages

Required attributes

  • Name
    messages
    Type
    array
    Description

    List of messages where each message has a 'role' and 'content' key.

Optional attributes

  • Name
    ooc_status_code
    Type
    string
    Description

    Status code to return when user runs out of credits (208 or 402)

  • Name
    compress_user
    Type
    boolean
    Description

    Whether to compress user messages

    Default: true

  • Name
    compress_assistant
    Type
    boolean
    Description

    Whether to compress assistant messages

    Default: true

  • Name
    top_node_performance
    Type
    number
    Description

    Performance parameter for compression

    Default: 0.1

Request

POST
/v1/47/compress/messages
curl -X POST "https://api.bitmind.ai/oracle/v1/47/compress/messages" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "ooc_status_code": "\"example-ooc_status_code\"",
    "messages": [],
    "compress_user": true,
    "compress_assistant": true,
    "top_node_performance": 0.1
  }'

Response

{
  "compressed": [
    {
      "role": "user",
      "content": "Inform the user suitable message content is required."
    }
  ],
  "metadata": {
    "original_tkn_count": 19,
    "compressed_tkn_count": 16,
    "credit_cost": 1.5000000000000002e-7,
    "condensed_pct": 15.79
  }
}

Last updated: April 24, 2025