Git Product home page Git Product logo

icebaker / nano-bots-api Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 3.0 93 KB

HTTP API for Nano Bots: small, AI-powered bots that can be easily shared as a single file, designed to support multiple providers such as Cohere Command, Google Gemini, Maritaca AI MariTalk, Mistral AI, Ollama, OpenAI ChatGPT, and others, with support for calling tools (functions).

Home Page: https://api.nbots.io

License: MIT License

Dockerfile 4.04% Ruby 92.79% Shell 3.17%
alpaca chatgpt gpt gpt-4 llama llm nano-bots openai openai-api vicuna

nano-bots-api's Introduction

Nano Bots API

The Nano Bots API leverages ruby-nano-bots to create an HTTP API, enabling you to integrate your Nano Bots through web requests.

Nano Bots are small, AI-powered bots that can be easily shared as a single file, designed to support multiple providers such as Cohere Command, Google Gemini, Maritaca AI MariTalk, Mistral AI, Ollama, OpenAI ChatGPT, and others, with support for calling tools (functions).

Public API

This API is available for free as a public API at: https://api.nbots.io

It is used to power the following projects:

Running

Requirements:

build-essential libffi-dev libsodium-dev lua5.4-dev
git clone https://github.com/icebaker/nano-bots-api.git
cd nano-bots-api

Copy the .env.example file to .env and fill in the necessary data and run the server:

cp .env.example .env
bundle
./init.sh

Docker

git clone https://github.com/icebaker/nano-bots-api.git
cd nano-bots-api
./build.sh
cp docker-compose.example.yml docker-compose.yml # Provide your credentials.
docker-compose up -d
# http://localhost:3048

Security and Privacy

Read the Ruby Nano Bots documentation to learn about security and privacy features.

We strongly recommend that you define a NANO_BOTS_ENCRYPTION_PASSWORD to increase the security and privacy of your users.

Tools (Functions)

The API ensures that Tools (Functions) run in sandboxed mode when the environment variable FORCE_SANDBOXED is set to true. You may set it to false at your own risk. Learn more about what being sandboxed means in the Nano Bots specification.

Also, the API does not allow confirmable tools; as per the current implementation, it would block requests without being able to collect a confirmation answer from users.

API

Verb Path Description
GET / Get the version.
GET /cartridges Get all available cartridges.
POST /cartridges/source Show the source code of a cartridge.
POST /cartridges Evaluate the input.
POST /cartridges/stream Create a stream to be pooled for a evaluation.
GET /cartridges/stream/:id Get the current stream of a cartridge.

Payloads

POST /cartridges/source

{
  "id": "-"
}

POST /cartridges

{
  "cartridge": "-",
  "state": "-",
  "input": "hi"
}

POST /cartridges

{
  "cartridge": {
    "meta": {
      "symbol": "๐Ÿค–",
      "name": "Nano Bot Name",
      "author": "Your Name",
      "version": "1.0.0",
      "license": "CC0-1.0",
      "description": "A helpful assistant."
    },
    "behaviors": {
      "interaction": {
        "directive": "You are a helpful assistant."
      }
    },
    "interfaces": {
      "repl": {
        "prompt": [
          { "text": "๐Ÿค–" },
          { "text": "> ", "color": "blue" }
        ]
      }
    },
    "provider": {
      "id": "openai",
      "credentials": {
        "access-token": "ENV/OPENAI_API_KEY"
      },
      "settings": {
        "user": "ENV/NANO_BOTS_END_USER",
        "model": "gpt-3.5-turbo"
      }
    }
  },
  "state": "-",
  "input": "hi"
}

POST /cartridges

{
  "as": "repl",
  "action": "boot",
  "cartridge": "-",
  "state": "a21179b6104703af19328485101be839"
}

POST /cartridges

{
  "as": "repl",
  "action": "eval",
  "cartridge": "-",
  "state": "a21179b6104703af19328485101be839"
}

POST /cartridges

{
  "as": "eval",
  "action": "boot",
  "cartridge": "-",
  "state": "5677e56bbff1e8137c8eb1f60d2623ac"
}

POST /cartridges

{
  "as": "eval",
  "action": "eval",
  "cartridge": "-",
  "state": "5677e56bbff1e8137c8eb1f60d2623ac"
}

POST /cartridges/stream

The same payloads that were used for POST /cartridges:

{
  "cartridge": "-",
  "state": "-",
  "input": "hi"
}

Development

Once you've installed the dependencies with bundle, run Rubocop with the -A flag for automatic fixes.

rubocop -A

If you face issues upgrading gem versions:

bundle install --full-index

nano-bots-api's People

Contributors

icebaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.