@plucky-ai/react
v0.5.0
Published
A React hook for using the Plucky Chat SDK. Access the full docs [here](https://docs.plucky.ai).
Readme
@plucky-ai/react
A React hook for using the Plucky Chat SDK. Access the full docs here.
Installation
npm install @plucky-ai/react
# or
yarn add @plucky-ai/react
# or
pnpm add @plucky-ai/reactUsage
import { useTools } from '@plucky-ai/react'
function MyComponent(props: { temperature: number }) {
useTools({
context: {
temperature,
},
tools: [
{
name: 'get_current_weather',
description: 'Get the current weather',
defaultLoadingText: 'Checking the weather...',
defaultSuccessText: 'Weather retrieved.',
cb: async (_, { temperature }) => {
// Return a string:
return `It's currently ${temperature} degrees.`
// Or return an object with custom success text:
// return {
// content: `It's currently ${temperature} degrees.`,
// successText: `Weather: ${temperature}°`,
// }
},
},
],
})
return <div>My component content here</div>
}