Code Monkey home page Code Monkey logo

skill-default-contract-demo's Introduction

skill-default-contract-demo

Demonstrates how to implement a contract provided by leftshift one.

All default contracts are open source and can be found here

Default contracts specify how a skill solving a specific kind of business problem can be used by a client. Since some parts of AIOS are using default skill implementations provided by leftshift one this implementations may be replaced by implementations provided by the users of AIOS if the implementation adheres to the said default contract.

This example implements a very simple tokenizer that fulfils the leftshiftone/tokenizer default contract:

namespace incoming {
    class Request {
        text: string
    }
}

namespace outgoing {
    class Response {
      tokens: [string]
    }
}

Implementing a default contract

In order to implement a default contract the contract to be implemented must be defined within the skill.yml file in the format leftshiftone/CONTRACT where all available contracts can be found here. So to implement the tokenizer default contract the skill.yml file must be adapted as following:

...
contract: ["leftshiftone/tokenizer"]
...

This means that that skill implements the default leftshiftone/tokenizer (Definition) contract. It is possible to implement more than one contract (default and/or custom).

Using custom contracts

Of course we can not anticipate every business problem so custom contracts may be defined by the skill developer. Custom contracts are defined by creating one (or more) contracts using the Dynabuffers IDL. Default contracts must be placed at a well defined location within the skills project structure.

Python: src/contract/

WARN: Using incoming and outgoing namespaces is a convention that must be followed!

A contract for a rather trivial addition only calculator could look like this:

namespace incoming {
    class CalculatorRequest {
        x: int
        y: int
    }
}

namespace outgoing {
    class CalculatorResponse {
      result: int
    }
}

If only a single contract is implemented a root level namespace can be omitted.

skill-default-contract-demo's People

Contributors

fridayy 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.