Call by Meaning (CBM)

website·Indexed 30 days ago

https://cbm.js.org

A platform designed to make function discovery and usage easier. CBM provides a knowledge base of functions and concepts, featuring an API with main and helper functions such as cbm.lookup(uri[, type]) and cbm.getURI(text). The project is licensed under AGPL-3.0.

Tokens
4K
Snippets
21
Records
33
Agent score
44%

What's inside CBM

  1. Call a CBM function using Node.js

    Example of using the request library to call the CBM API to determine a star sign based on a birth date. The request specifies the input concept as 'date' and the output concept as 'star_sign'.
    const request = require('request');
    const uri = 'https://call-by-meaning.onrender.com/cbm/call';
    
    let bday = new Date(1993, 2, 24);
    let params = {
      'inputConcepts': 'date',
      'inputUnits': 'date',
      'inputVars': bday,
      'outputConcepts': 'star_sign',
      'outputUnits': 'word'
    };
    
    request.post(uri, {form: params}, function (err, response, body) {
      console.log('I was born on 23rd of March and that makes me an %s!', body);
    });
  2. Understand the Concept data model

    A Concept document represents a measurable or identifiable entity in the database. It is defined by the following parameters:

    • name (String): The unique identifier for the concept.
    • desc (String): A short description of the concept.
    • units (Array): Supported units of measurement. If no specific unit is applicable, the unit defaults to the concept's name (e.g., date is measured in date).
    • func_arg (Array): References to functions that accept this concept as an input.
    • func_res (Array): References to functions that produce this concept as an output.
  3. CBM v1.4.0 Breaking Changes and Features

    Version 1.4.0 introduced the following changes:

    • Breaking Change: Renamed Node to Concept.
    • Added Docker support.
    • Added support for adding APIs.
  4. Project Status: CBM is officially archived

    As of October 25, 2025, the CBM project has been officially archived. There will be no further updates or maintenance for the project.
  5. Retrieve entity information using the Get By Name (GBN) API

    The Get By Name (GBN) endpoint allows you to retrieve all available information for a specific concept, function, or relation via a RESTful GET request. The server returns data in JSON format. If a requested object does not exist but a similar one is available, the server returns the similar object. If no match is found, the server returns a 418 status code.
    GET /gbn/{type}/{name}/

    URL Patterns:

    • Concepts: /gbn/c/{name}/
    • Functions: /gbn/f/{name}/
    • Relations: /gbn/r/{name}/

    Examples:

    • https://call-by-meaning.com/gbn/c/time (Concept "time")
    • https://call-by-meaning.com/gbn/f/getTime (Function "getTime")
    • https://call-by-meaning.com/gbn/r/unitConversion (Relation "unitConversion")
  6. Create or modify server documents using cbm.create

    The cbm.create(params[, type]) method creates a new document on the server or modifies an existing one. It takes a params object and an optional type string. Valid types are concept (default), function, or relation. It returns a promise that resolves to a boolean indicating success.
    // Create a concept (default type)
    let conceptParams = {
      name: 'aConcept',
      desc: 'aDescription',
    };
    cbm.create(conceptParams);
    
    // Create a function
    let funcParams = {
      name: 'aFunction',
      desc: 'aDescription',
      argsNames: 'someArg',
      argsUnits: 'someUnit',
      returnsNames: 'someReturn',
      returnsUnits: 'someUnit',
      codeFile: __dirname.concat('/someFile.js')
    };
    cbm.create(funcParams, 'function');
    
    // Create a relation
    let relParams = {
      name: 'unitConversion',
      start: 'meters',
      end: 'feet',
      mathRelation: '0.3 * start'
    };
    cbm.create(relParams, 'relation');
  7. Requirements for conveying verbatim copies of the software

    To convey verbatim copies of the Program's source code, you must:

    1. Publish an appropriate copyright notice on each copy.
    2. Keep all notices intact that state the License and any non-permissive terms (added under section 7) apply to the code.
    3. Keep all notices regarding the absence of warranty intact.
    4. Provide all recipients with a copy of the License along with the Program.

    You are permitted to charge a fee for each copy or offer paid support and warranty protection.

  8. Apply the GNU AGPL v3 license to a new program

    To license a new program under the GNU Affero General Public License (AGPL) v3, attach a copyright notice and license pointer to the start of each source file. If the software interacts with users remotely via a network (e.g., a web application), you must provide a way for users to access the source code, such as a 'Source' link in the user interface.
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
    
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  9. Run unit tests for cbm-engine

    Execute the unit test suite for the cbm-engine using the npm test command.
    npm test
  10. Configure the params object for CBM requests

    The params object defines the conceptual requirements for the function call. Any field that is not applicable (e.g., a function with no inputs) can be omitted. This object must be included in the body of the POST request.
    {
      "inputConcepts": ["concept1", "concept2"],
      "inputUnits": ["unit1", "unit2"],
      "inputVars": ["var1", "var2"],
      "outputConcepts": ["concept1", "concept2"],
      "outputUnits": ["unit1", "unit2"]
    }
  11. Run cbm-engine locally

    To run the cbm-engine server locally, clone the repository, install dependencies, and start the server with the required MongoDB connection string. By default, the server runs on http://localhost:3000. You can override the port using the PORT environment variable. If MongoDB is running locally, you can use the DB environment variable to specify the database name instead of DB_HOST.
    git clone https://github.com/cbmjs/cbm-engine.git cbm-engine
    cd cbm-engine
    npm install
    DB_HOST=mongodb://user:pass@host:port/callbymeaning npm start
  12. Execute a function using the Call By Meaning (CBM) API

    The Call By Meaning API allows you to run a function by specifying desired conceptual inputs and outputs rather than a specific function name. The server automatically handles unit conversions (e.g., converting seconds to hours) to match the requested output format. If the requested function does not exist or a unit conversion is impossible, the server returns a 418 status code.

    To execute a function, send a POST request to the /cbm/call endpoint with a JSON object in the request body containing the params configuration.

    # Example endpoint
    POST https://call-by-meaning.onrender.com/cbm/call