1.1.92 • Published 2 months ago

@sista/vuic-react v1.1.92

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

Voice UI Assistant

Turn your App into an AI-powered, Voice-controlled interface in less than 10 minutes!

No Code Changes or Intent Definitions! Just add our magic button <AiAssistantButton />.

Sista Logo

Sista AI: 🤖 Your AI Integration Platform. ❤️

Features at a Glance:

  • UI Controller: Performs any action
  • Voice UI: Speaks any language
  • AI Assistant: Answers any question
  • Admin Panel: Customizes any detail

Demo

Try it now!

Visit our Demo click the button, and start talking... Say "turn the light on"!__

Sista Logo

Supported Projects

This package integrates with many React projects.

  • Create React App
  • React Native
  • Next.js
  • Gatsby
  • Electron
  • Meteor
  • Parcel
  • Expo
  • Remix
  • Storybook
  • RedwoodJS
  • Blitz.js

Installation

To use @sista/vuic-react, install it in your React App.

Using npm:
npm install @sista/vuic-react
Using yarn:
yarn add @sista/vuic-react

Setup

1. Import Provider

Import AiAssistantProvider and wrap your App at the root level.

// ...
import { AiAssistantProvider } from "@sista/vuic-react";

ReactDOM.render(
  <React.StrictMode>
    <AiAssistantProvider apiKey="YOUR_API_KEY"> // << Wrap your app with this provider
      <App />
    </AiAssistantProvider>
  </React.StrictMode>,
  // ...
);

Get your free API key from the Admin Panel and replace "YOUR_API_KEY".

2. Import Button

Import AiAssistantButton and add it wherever you want.

// ...
import { AiAssistantButton } from "@sista/vuic-react";

// ...
function MyComponent() {
  return (
    <div>
      // ...
      <AiAssistantButton />  // << Add the magic button anywhere
    </div>
  );
}

🎉 Congrats! Press the button, start talking, and enjoy!


3. Register Voice-Interactive Functions

To make your UI voice-interactive, simply register an array of function signatures to the Sista AI model.

const sayHelloWorld = () => {
  console.log("Hello, World!");
};

// Define the functions to be voice-controlled
const interactiveFunctions = [
  {
    function: {
      handler: sayHelloWorld, // pass a refference to your function
      description: "Greets the user with Hello World :)", // add function description
    },
  },
  // ... register additional functions here
];

For functions that accepts parameters:

const sayHello = (name) => {
  console.log(`Hello ${name}!`);
};

// Define the functions to be voice-controlled
const interactiveFunctions = [
  {
    function: {
      handler: sayHello,
      description: "Greets the user with their name.",
      // In case your function accepts parameters:
      parameters: {
        type: "object",
        properties: {
          name: { 
            type: "string", // set parameter type
            description: "User's name." // add parameter description
          },
        },
        required: ["name"], // list required parameters
      },
    },
  },
];

Register the functions with aiAssistant.registerFunctions(..); inside a useEffect hook.

  const aiAssistant = useAiAssistant();
  useEffect(() => {
    if (aiAssistant) {
      aiAssistant.registerFunctions(interactiveFunctions);
    }
  }, [aiAssistant]);

Just like that, your app is voice-interactive. Magic! :sparkles:

To customize the AI assistant's voice or feed information about your product, visit the Admin Panel.

Full Example: (Todo App)

For a voice-interactive todo app to add or remove tasks, the setup is:

import React, { useEffect } from 'react';
import { useAiAssistant, AiAssistantButton } from '@sista/vuic-react';

function TodoApp() {

  const addTask = (task) => {
    console.log(`Task added: ${task}`);
  };

  const removeTask = (task) => {
    console.log(`Task removed: ${task}`);
  };

  // ...

  // Initialize the aiAssistant instance
  const aiAssistant = useAiAssistant();

  useEffect(() => {
    // Define the voice-controlled functions
    const interactiveFunctions = [
      {
        function: {
          handler: addTask,
          description: 'Adds a new task.',
          parameters: {
            type: 'object',
            properties: {
              task: { 
                type: 'string', 
                description: 'Description of the task.' 
              },
            },
            required: ['task'],
          },
        },
      },
      {
        function: {
          handler: removeTask,
          description: 'Removes an existing task.',
          parameters: {
            type: 'object',
            properties: {
              task: { 
                type: 'string', 
                description: 'Description of the task.' 
              },
            },
            required: ['task'],
          },
        },
      },
    ];

    // Register the AI controlled functions
    if (aiAssistant) {
      aiAssistant.registerFunctions(interactiveFunctions);
    }
  }, [aiAssistant]);

  // ...

  return (
    <div>
      // ...
      <AiAssistantButton />
    </div>
  );
}

export default TodoApp;

Configuration

AiAssistantProvider accepts few props:

<AiAssistantProvider
  apiKey="api-key"   // (required): Your API key.
  debug={true}       // (optional): Enables debug mode.
  apiUrl="api-url"   // (optional): For custom backend or testing purposes.
>
  // ...
</AiAssistantProvider>

Customization

Change Button Color

You can modify the colors of the AiAssistantButton at different states:

    const colors = {
        STATE_IDLE: '#4a6cf6', // Default
        STATE_LISTENING_START: '#F64A7B', // Red
        STATE_THINKING_START: '#4ac2f6', // Blue
        STATE_SPEAKING_START: '#4af67f', // Green
    };

  <AiAssistantButton buttonColors={colors} />

Modify AI Responses

Customize AI assistant behavior via the Admin Panel by providing your custom prompt and training data.

Change Assistant Voice

Change AI assistant's voice via the Admin Panel by selecting your preferred voice in the application settings.

Sista Logo


Unlock the Future with our advacned Voice UI Assistant: Embrace top-tier components:

  • Voice UI Controller
  • Natural Language Understanding Engine
  • Text-to-Executable Translator
  • Audio-to-Text / Text-to-Audio Conversion
  • Intent Recognition and Handling
  • Contextual Response Generator
  • Custom Prompt Configuration
  • Analytics and Logging
  • Privacy and Security

Contributing

Your contributions are warmly welcomed! Let's collaborate 🤝

License

Licensed under CC BY-NC-ND 3.0.

Support

For issues, raise on Github or contact support@sista.ai.

1.1.92

2 months ago

1.1.91

2 months ago

1.1.90

2 months ago

1.1.74

2 months ago

1.1.73

2 months ago

1.1.72

2 months ago

1.1.71

2 months ago

1.1.78

2 months ago

1.1.77

2 months ago

1.1.76

2 months ago

1.1.75

2 months ago

1.1.79

2 months ago

1.1.81

2 months ago

1.1.80

2 months ago

1.1.85

2 months ago

1.1.84

2 months ago

1.1.83

2 months ago

1.1.82

2 months ago

1.1.89

2 months ago

1.1.88

2 months ago

1.1.87

2 months ago

1.1.86

2 months ago

1.1.70

2 months ago

1.1.59

2 months ago

1.1.58

2 months ago

1.1.63

2 months ago

1.1.62

2 months ago

1.1.61

2 months ago

1.1.60

2 months ago

1.1.67

2 months ago

1.1.66

2 months ago

1.1.65

2 months ago

1.1.64

2 months ago

1.1.69

2 months ago

1.1.68

2 months ago

1.1.38

2 months ago

1.1.37

2 months ago

1.1.39

2 months ago

1.1.41

2 months ago

1.1.40

2 months ago

1.1.45

2 months ago

1.1.44

2 months ago

1.1.43

2 months ago

1.1.42

2 months ago

1.1.49

2 months ago

1.1.48

2 months ago

1.1.47

2 months ago

1.1.46

2 months ago

1.1.52

2 months ago

1.1.51

2 months ago

1.1.50

2 months ago

1.1.56

2 months ago

1.1.55

2 months ago

1.1.54

2 months ago

1.1.53

2 months ago

1.1.29

2 months ago

1.1.28

2 months ago

1.1.30

2 months ago

1.1.34

2 months ago

1.1.33

2 months ago

1.1.32

2 months ago

1.1.31

2 months ago

1.1.36

2 months ago

1.1.35

2 months ago

1.1.23

2 months ago

1.1.22

2 months ago

1.1.21

2 months ago

1.1.26

2 months ago

1.1.25

2 months ago

1.1.24

2 months ago

1.1.19

2 months ago

1.1.18

2 months ago

1.1.17

2 months ago

1.1.9

2 months ago

1.1.8

2 months ago

1.1.7

2 months ago

1.1.6

2 months ago

1.1.12

2 months ago

1.1.11

2 months ago

1.1.10

2 months ago

1.1.20

2 months ago

1.1.16

2 months ago

1.1.15

2 months ago

1.1.14

2 months ago

1.1.13

2 months ago

1.1.5

2 months ago

1.1.4

2 months ago

1.1.3

2 months ago

1.1.2

2 months ago

1.1.1

2 months ago

1.0.0

2 months ago