clubmate
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

ClubMate

MIT License npm ci

clubmate

ClubMate is a JavaScript library that enhances JavaScript projects with generative artificial intelligence capabilities.


Installation

npm install clubmate --save

Usage

Import library and initialize client:

import { ClubMate } from 'clubmate'

const clubMate = new ClubMate(process.env.OPENAI_API_KEY)

For primitive data types:

const percentage: number = await clubMate.produce('What percentage is 6 of 40 as number?')
console.log(percentage) // => 15

const capitalOfGermany: string = await clubMate.produce('Capital of Germany?')
console.log(capitalOfGermany) // => 'Berlin'

const isEarthFlat: boolean = await clubMate.produce('Is the Earth flat?')
console.log(isEarthFlat) // => false

Data producers:

type Book = {
  name: string
  author: string
  releaseYear: string
  isbn: string
}

const hpBooks: Book[] = await clubMate.produce(
  'Generate array of objects of all Harry Potter books with name, author, releaseYear and isbn number fields'
)

console.log(hpBooks) // => 
[
  {
      name: "Harry Potter and the Philosopher`s Stone",   
      author: "J.K. Rowling",
      releaseYear: 1997,
      isbn: "9780747532743"
  }, 
  {
      name: "Harry Potter and the Prisoner of Azkaban",
      author: "J.K. Rowling",
      releaseYear: 1999,
      isbn: "9780747542155"
      
  }
  // ...
]

For existing data:

const bookNames = ['Don Quixote', 'Never Let Me Go', '1984']
const booksWithDetails = await clubMate.produce(
  'Return array of objects of books with fields: name, releaseYear, author and isbn',
  bookNames
)
console.log(booksWithDetails) // =>
[
  {
    "name": "Don Quixote",
    "releaseYear": 1605,
    "author": "Miguel de Cervantes",
    "isbn": "9780142437230"
  },
    {
      "name": "Never Let Me Go",
      "releaseYear": 2005,
      "author": "Kazuo Ishiguro",
      "isbn": "9781400078776"
    },
    {
      "name": "1984",
      "releaseYear": 1949,
      "author": "George Orwell",
      "isbn": "9780451524935"
    }
]

Check tests for more examples.

Package Sidebar

Install

npm i clubmate

Weekly Downloads

6

Version

1.0.4

License

ISC

Unpacked Size

87.7 kB

Total Files

29

Last publish

Collaborators

  • kherkeladze