0.0.6 • Published 10 months ago

@tuneup/client-js v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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

0.0.6

10 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago