npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@upliftai/assistants-react

v0.0.4

Published

React components and hooks for building real-time AI assistants with UpliftAI and LiveKit

Readme

@upliftai/assistants-react

React components and hooks for building real-time AI assistants with UpliftAI and LiveKit.

A thin wrapper around LiveKit room, it allows you to easily connect to an UpliftAI assistant session, manage tools, and update instructions dynamically.

Installation

npm install @upliftai/assistants-react

Peer Dependencies

This package requires the following peer dependencies (you have to install as well):

{
  "@livekit/components-react": "^2.8.0",
  "livekit-client": "^2.7.0",
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
}

Full Example

See the examples/react-assistant-demo directory for a complete working example.

Quick Start

1. Get Session Credentials

First, create a session with your UpliftAI assistant. You'll need to call the UpliftAI API from your backend:

// Backend code
const response = await fetch(
  `https://api.upliftai.org/v1/realtime-assistants/${assistantId}/createSession`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${YOUR_API_KEY}`,
    },
    body: JSON.stringify({
      participantName: 'User Name',
    }),
  }
);

const { token, wsUrl, roomName } = await response.json();

For public assistants, you can use the public endpoint:

// Can be called from frontend for public assistants
const response = await fetch(
  `https://api.upliftai.org/v1/realtime-assistants/${assistantId}/createPublicSession`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      participantName: 'User Name',
    }),
  }
);

const { token, wsUrl, roomName } = await response.json();

2. Create Your Assistant Component

import React from 'react';
import {
  UpliftAIRoom,
  useUpliftAIRoom,
  useVoiceAssistant,
  AudioTrack,
  BarVisualizer,
  TrackToggle,
  DisconnectButton,
} from '@upliftai/assistants-react';
import { Track } from 'livekit-client';

function AssistantView() {
  const { updateInstruction, isConnected, agentParticipant } = useUpliftAIRoom();
  const { state } = useVoiceAssistant();

  return (
    <div>
      <h2>AI Assistant</h2>
      
      {/* Show connection status */}
      <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
      {agentParticipant && <p>Agent: {agentParticipant.identity}</p>}
      
      {/* Voice visualization */}
      <BarVisualizer state={state} />
      
      {/* Assistant state */}
      <p>
        {state === 'speaking' && 'Assistant is speaking...'}
        {state === 'thinking' && 'Assistant is thinking...'}
        {state === 'listening' && 'Listening...'}
      </p>
      
      {/* Audio controls */}
      <TrackToggle source={Track.Source.Microphone} />
      <DisconnectButton />
    </div>
  );
}

function App({ token, wsUrl }) {
  return (
    <UpliftAIRoom
      token={token}
      serverUrl={wsUrl}
      connect={true}
      audio={true}
      video={false}
    >
      <AssistantView />
    </UpliftAIRoom>
  );
}

Adding Custom Tools

You can extend your assistant's capabilities by adding custom tools:

import { UpliftAIRoom, useUpliftAIRoom, ToolConfig } from '@upliftai/assistants-react';

// Define your tools
const tools: ToolConfig[] = [
  {
    name: 'get_weather',
    description: 'Get the current weather for a location',
    parameters: {
      type: 'object',
      properties: {
        location: {
          type: 'string',
          description: 'The city and state, e.g. San Francisco, CA',
        },
      },
      required: ['location'],
    },
    timeout: 10, // seconds
    handler: async (data) => {
      const payload = JSON.parse(data.payload);
      const { location } = payload.arguments.raw_arguments;
      
      // Your weather API call here
      const weather = await fetchWeather(location);
      
      return JSON.stringify({
        result: weather,
        presentationInstructions: `The weather in ${location} is ${weather.temperature}°F`,
      });
    },
  },
];

function App({ token, wsUrl }) {
  return (
    <UpliftAIRoom
      token={token}
      serverUrl={wsUrl}
      connect={true}
      audio={true}
      video={false}
      tools={tools} // Pass tools here
    >
      <AssistantView />
    </UpliftAIRoom>
  );
}

Dynamic Tool Management

You can also add, update, or remove tools dynamically:

function ToolManager() {
  const { addTool, removeTool, updateTool } = useUpliftAIRoom();
  
  const handleAddTool = async () => {
    await addTool({
      name: 'calculator',
      description: 'Perform calculations',
      parameters: {
        type: 'object',
        properties: {
          expression: {
            type: 'string',
            description: 'Math expression to evaluate',
          },
        },
        required: ['expression'],
      },
      timeout: 5,
      handler: async (data) => {
        const { expression } = JSON.parse(data.payload).arguments.raw_arguments;
        const result = eval(expression); // Note: Use a safe math parser in production
        return JSON.stringify({ result });
      },
    });
  };
  
  return (
    <button onClick={handleAddTool}>Add Calculator Tool</button>
  );
}

Updating Assistant Instructions

You can update the assistant's instructions in real-time:

function InstructionManager() {
  const { updateInstruction } = useUpliftAIRoom();
  const [instructions, setInstructions] = useState('');
  
  const handleUpdate = async () => {
    await updateInstruction(instructions);
  };
  
  return (
    <div>
      <textarea
        value={instructions}
        onChange={(e) => setInstructions(e.target.value)}
        placeholder="Enter custom instructions..."
      />
      <button onClick={handleUpdate}>Update Instructions</button>
    </div>
  );
}

API Reference

<UpliftAIRoom>

The main component that wraps your application and provides the UpliftAI context.

Props

All props from @livekit/components-react's LiveKitRoom component, plus:

  • tools?: ToolConfig[] - Array of tools to register with the assistant
  • onToolsChange?: (tools: ToolConfig[]) => void - Callback when tools change
  • onConnectionChange?: (connected: boolean, agentIdentity?: string) => void - Callback when connection status changes

useUpliftAIRoom()

Hook to access UpliftAI room functionality.

Returns

  • addTool(config: ToolConfig): Promise<void> - Add a new tool
  • updateTool(config: ToolConfig): Promise<void> - Update an existing tool
  • removeTool(name: string): Promise<void> - Remove a tool
  • upsertTools(configs: ToolConfig[]): Promise<void> - Replace all tools
  • updateInstruction(instruction: string): Promise<void> - Update assistant instructions
  • isConnected: boolean - Connection status
  • agentParticipant: Participant | null - The agent participant object

Tool Configuration

Interfaces already exported from this package.

interface ToolInvocationData {
  requestId: string;
  callerIdentity: string;
  payload: string; // You will have to parse this JSON string
  responseTimeout: number;
}

interface ParameterConfig {
  type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
  description?: string;
  enum?: any[];
  items?: ParameterConfig;
  properties?: Record<string, ParameterConfig>;
  required?: string[];
}

interface ToolConfig {
  name: string;
  description: string;
  parameters: {
    type: 'object';
    properties: Record<string, ParameterConfig>;
    required?: string[];
  };
  timeout: number; // in seconds
  handler: (data: ToolInvocationData) => Promise<string>;
}

LiveKit Components

This package re-exports all components from @livekit/components-react, so you can use LiveKit components directly:

import {
  AudioTrack,
  VideoTrack,
  ControlBar,
  Chat,
  RoomAudioRenderer,
  // ... and more
} from '@upliftai/assistants-react';

License

MIT