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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ada-core/assistant-sdk

v1.0.16

Published

Assistant SDK for Ada Motion

Downloads

1,096

Readme

@ada-core/assistant-sdk

This package provides a set of tools to help you build your own ADA Assistant.

How it works

  1. This package provides components to build an ADA Assistant.
  2. It also includes server actions to interact with the assistant.
  3. It accepts the assistant ID and ADA API key to interact with the assistant.

Installation

npmp add @ada-core/assistant-sdk

TOC

Basic Usage

The SDK provides a set of components to build an ADA Assistant. Here is an example of how to use the SDK to build an assistant.

Step 1: Initialize the provider

import { AssistantProvider } from '@ada-core/assistant-sdk';

const App = () => {
  return (
    <AssistantProvider assistantId="assistant-id" apiKey="ada-api-key">
      <MyChat />
    </AssistantProvider>
  );
};

Step 2: Use the assistant components

import { Assistant, Chat, Message } from '@ada-core/assistant-sdk';

const MyChat = () => {
  return (
      <Chat
        assistantId="asst_0uRuhfE70R5zIiPQoF7X2hIs"
      >
        <Welcome />
        <Messages />
        <Prompt />
      </Chat>
  );
};

Components

AssistantProvider

The AssistantProvider component is used to initialize the assistant. It accepts the assistant ID and ADA API key as props.

import { AssistantProvider } from '@ada-core/assistant-sdk';

const App = () => {
  return (
    <AssistantProvider assistantId="assistant-id" apiKey="ada-api-key">
      <MyChat />
    </AssistantProvider>
  );
};

Chat

The Chat component is used to render the chat interface. It accepts the assistant ID as a prop.

For the Chat component, you can also provide widgets. The widgets prop is an array of components that will be rendered for specific actions.

import { Chat } from '@ada-core/assistant-sdk';

const MyChat = () => {
  return (
    <Chat
      assistantId="asst_0uRuhfE70R5zIiPQoF7X2hIs"
    >
        ...
    </Chat>
  );
};

Welcome

The Welcome component is used to render the welcome message. You can define suggestions to display to the user and override the content of the welcome message.

import { Welcome, SuggestionItem } from '@ada-core/assistant-sdk';

const suggestions: SuggestionItem[] = [
    {
        title: "Exercises to improve ball reception",
        prompt: "Can you suggest some exercises to improve ball reception?",
    },
    {
        title: "Training program",
        prompt: "Can you suggest a training program for me?",
    }
]

const MyWelcome = () => {
  return (
    <Welcome suggestions={suggestions}>
        <img src="/images/my-logo.png" />
        <p>Welcome to my assistant</p>
    </Welcome>
  );
};

Messages

The Messages component is used to render the messages exchanged with the assistant. Is has to be used inside the Chat component.

import { Messages } from '@ada-core/assistant-sdk';

const MyMessages = () => {
  return (
    <Messages />
  );
};

Prompt

The Prompt component is used to render the prompt to send a message to the assistant. It accepts a placeholder prop to define the placeholder text of the input.

import { Prompt } from '@ada-core/assistant-sdk';

const MyPrompt = () => {
  return (
    <Prompt placeholder="Type your message here" />
  );
};

Widgets

You can create your own widgets to render specific actions. Each assistant provides a set of actions that can be used to create widgets.

To create a widget, you need to create a component that will render the action. The component will receive the action as a prop.

"use client";

import { makeWidgetUI } from "@ada-core/assistant-sdk";

export const ExerciseWidgetUI = makeWidgetUI<any, any>({
    toolName: "exercise_program",
    render: ({ args, result, status }: any) => {
        return (
            <div>
                <h2>Exercise Program</h2>
                <ul>
                    {result.exercises.map((exercise: any) => (
                        <li key={exercise.id}>{exercise.name}</li>
                    ))}
                </ul>
            </div>
        );
    },
});

Then, you can use the widget in the Chat component.

import { Chat } from '@ada-core/assistant-sdk';

const MyChat = () => {
  return (
    <Chat
      assistantId="asst_0uRuhfE70R5zIiPQoF7X2hIs"
      widgets={[ExerciseWidgetUI]}
    >
        ...
    </Chat>
  );
};

| Action | Description | | --- | --- | | exercise_program | Returns a set of exercises, if the user asks for it |