@tuneup/client-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

@tuneup/client-js

The Tuneup client library provides convenient access to the Tuneup API.

See API Documentaion for more access.

Installation

npm install @tuneup/client-js
# or
yarn add @tuneup/client-js

Usage

The library must be configured with your API key, which is available in the Tuneup Developer Menu. Be sure to set domain restriction if you are using it in a browser.

Example Usage. It should work with react, vue, etc.

import { createClient } from '@tuneup/client-js'

const apiKey = 'xxxxxxxxx'
const tuneup = createClient(apiKey)
// the collection you want to use as data source.
const collectionId = 'collection-uuid'

const TuneupInput = () => {

  const [question, setQuestion] = useState('')
  const [answer, setAnswer] = useState('')

  const submit = async () => {
    if(!question) return

    await tuneup.ask({
      question,
      // it will be fired every 1000ms (default) with the latest content.
      onUpdate: (latest) => setAnsert(latest),
      onComplete: (last)=> {
        // maybe set only once
      },
      collectionId,
    })
  }

  return (
    <>
      <TextInput
        label='Ask AI'
        value={question}
        onChangeText={setQuestion}
        onSubmitEditing={submit}
      />
      <Text>{answer}</Text>
    </>
  )

}

Currently we only have client.ask, client.fragments.create, client.fragments.read, client.fragments.polling,

Support

If you need more options, functionality or have a question, please visit the github repository and submit an issue.

Package Sidebar

Install

npm i @tuneup/client-js

Weekly Downloads

86

Version

0.0.6

License

MIT

Unpacked Size

27.2 MB

Total Files

525

Last publish

Collaborators

  • foloinfo
  • tuneup