Assistant SDK for Ada Motion
npm install @ada-core/assistant-sdk@ada-core/assistant-sdkThis package provides a set of tools to help you build your own ADA Assistant.
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.
``bash`
npmp add @ada-core/assistant-sdk
* Basic Usage
* Step 1: Initialize the provider
* Step 2: Use the assistant components
* Components
* AssistantProvider
* Chat
* Welcome
* Messages
* Prompt
* Widgets
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.
`jsx
import { AssistantProvider } from '@ada-core/assistant-sdk';
const App = () => {
return (
);
};
`
`jsx
import { Assistant, Chat, Message } from '@ada-core/assistant-sdk';
const MyChat = () => {
return (
>
);
};
`
The AssistantProvider component is used to initialize the assistant. It accepts the assistant ID and ADA API key as props.
`jsx
import { AssistantProvider } from '@ada-core/assistant-sdk';
const App = () => {
return (
);
};
`
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.
`jsx
import { Chat } from '@ada-core/assistant-sdk';
const MyChat = () => {
return (
>
...
);
};
`
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.
`jsx
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 = () => { Welcome to my assistant
return (

);
};
`
The Messages component is used to render the messages exchanged with the assistant. Is has to be used inside the Chat component.
`jsx
import { Messages } from '@ada-core/assistant-sdk';
const MyMessages = () => {
return (
);
};
`
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.
`jsx
import { Prompt } from '@ada-core/assistant-sdk';
const MyPrompt = () => {
return (
);
};
`
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.
`jsx
"use client";
import { makeWidgetUI } from "@ada-core/assistant-sdk";
export const ExerciseWidgetUI = makeWidgetUI
toolName: "exercise_program",
render: ({ args, result, status }: any) => {
return (
Exercise Program
{result.exercises.map((exercise: any) => (
))}
);
},
});
`
Then, you can use the widget in the Chat component.
`jsx
import { Chat } from '@ada-core/assistant-sdk';
const MyChat = () => {
return (
widgets={[ExerciseWidgetUI]}
>
...
);
};
`
| Action | Description |
| --- | --- |
| exercise_program` | Returns a set of exercises, if the user asks for it |