JSPM

  • Created
  • Published
  • Downloads 572
  • Score
    100M100P100Q86595F
  • License MIT

Library for Developing and Managing AI Functions (including OpenAI GPT4 / GPT3.5)

Package Exports

  • ai-functions
  • ai-functions/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ai-functions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

AI Functions

Library for Developing and Managing AI Functions (including OpenAI GPT4 / GPT3.5)

Key Features:

  • Enables easy development of AI functions
import { AI } from 'ai-functions'

const { ai, gpt, list } = AI({ apiKey: OPENAI_API_KEY })

Then you can use magic ai functions:

const product = await ai.categorizeProduct({ domain: name }, { 
  productType: 'App | API | Marketplace | Platform | Packaged Service | Professional Service | Website',
  customer: 'ideal customer profile in 3-5 words',
  solution: 'describe the offer in 4-10 words',
  description: 'website meta description',
})

you can also use list tagged template as a convienence function:

const things = await list`fun things to do in Miami`
console.log(things)

or with Async iterators:

for await (const thing of list`fun things to do in Miami`) {
  console.log(thing)
}

Or in a more complex example:

const listBlogPosts = (count, topic) => list`${count} blog post titles about ${topic}`
const writeBlogPost = title => gpt`write a blog post in markdown starting with "# ${title}"`

async function* writeBlog(count, topic) {
  for await (const title of listBlogPosts(count, topic)) {
    const content = await writeBlogPost(title)
    yield { title, content }
  }
}

for await (const post of writeBlog(25, 'future of car sales')) {
  console.log({ post })
}