@rapidaai/react 1.1.34 → 1.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +58 -90
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rapidaai/react",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "description": "An easy to use react client for building generative ai application using Rapida platform.",
5
5
  "repository": {
6
6
  "type": "git",
package/readme.md CHANGED
@@ -1,5 +1,3 @@
1
- # VoiceAgent Library
2
-
3
1
  ## Overview
4
2
 
5
3
  The `VoiceAgent` library provides a set of components, hooks, and utilities for integrating AI-powered voice assistants into applications. It supports real-time messaging, audio device management, and connection handling for seamless interaction.
@@ -9,82 +7,68 @@ The `VoiceAgent` library provides a set of components, hooks, and utilities for
9
7
  To install the package, run:
10
8
 
11
9
  ```sh
12
- npm install rapida-react@latest
10
+ npm install @rapidaai/react@latest
13
11
  ```
14
12
 
15
13
  or using Yarn:
16
14
 
17
15
  ```sh
18
- yarn add rapida-react@latest
19
- ```
20
-
21
- ## Usage
22
-
23
- Import the necessary components and hooks from `rapida-react@latest`:
24
-
25
- ```tsx
26
- import {
27
- Channel,
28
- ConnectionState,
29
- MediaDeviceFailure,
30
- ConnectionConfig,
31
- AgentConfig,
32
- } from "rapida-react";
33
-
34
- import {
35
- BrandIcon,
36
- UserIcon,
37
- MessagingAction,
38
- ConversationMessages,
39
- VoiceAgent,
40
- VoiceAgentContext,
41
- useConnectAgent,
42
- useDisconnectAgent,
43
- useInputModeToggleAgent,
44
- useMicInputToggleAgent,
45
- useSpeakerOuputToggleAgent,
46
- useMultiband3DSpeakerTrackVolume,
47
- useMultibandMicrophoneTrackVolume,
48
- useSelectInputDeviceAgent,
49
- } from "rapida-react";
16
+ yarn add @rapidaai/react@latest
50
17
  ```
51
18
 
52
- ## Example
53
-
54
- Here is an example of how to use `VoiceAgentContext.Provider` to set up a voice agent:
55
-
56
- ```tsx
57
- <VoiceAgentContext.Provider
58
- value={
59
- new VoiceAgent(
60
- new ConnectionConfig({
61
- authorization: YOUR_TOKEN,
62
- }),
63
- new AgentConfig(ASSISTANT_ID).addArgument("key", "val")
19
+ ## Usage Example
20
+
21
+ Here's a minimal setup for initializing and using a `VoiceAgent`:
22
+
23
+ ```ts
24
+ import { VoiceAgent, ConnectionConfig, AgentConfig, Channel, InputOptions } from "@rapidaai/react";
25
+ new VoiceAgent(
26
+ ConnectionConfig.DefaultConnectionConfig(
27
+ ConnectionConfig.WithSDK({
28
+ ApiKey: "{API_KEY}",
29
+ UserId: "random-user / identified-user",
30
+ })
31
+ ).withConnectionCallback({
32
+ onDisconnect: () => {
33
+ // do what you want when finished
34
+ console.log("disconnect");
35
+ },
36
+ onConnect() {
37
+ console.log("connected");
38
+ },
39
+ onError() {
40
+ console.log("error");
41
+ },
42
+ }),
43
+ new AgentConfig(
44
+ // replace this with actual agent id from rapida console
45
+ "{AGENT_ID}",
46
+ // you can select only Audio/ Text
47
+ new InputOptions([Channel.Audio, Channel.Text], Channel.Text)
64
48
  )
65
- }
66
- >
67
- <ConversationMessages
68
- userIcon={UserIcon}
69
- brandIcon={BrandIcon}
70
- className="h-full overflow-auto !pb-40 no-scrollbar"
71
- intialConversations={[
72
- {
73
- role: "system",
74
- messages: [
75
- "I am Yuuki",
76
- "An AI-powered coach to help you master the toughest challenges at your workplace.",
77
- ],
78
- },
79
- ]}
80
- />
81
- <div className="absolute bottom-0 right-0 left-0">
82
- <MessagingAction
83
- className="h-[8rem]"
84
- placeholder="How can I help you overcome a challenge?"
85
- />
86
- </div>
87
- </VoiceAgentContext.Provider>
49
+ .addKeywords([
50
+ "dictionary - which you want the model to speak clearly",
51
+ ])
52
+ .addArgument("name", "<name>")
53
+ .addMetadata("utm_1", StringToAny("utm_X")),
54
+ {
55
+ onAssistantMessage: (msg) => {
56
+ console.log("onStart: ()");
57
+ },
58
+ onUserMessage: (args) => {
59
+ console.log("onComplete:");
60
+ },
61
+ onConfiguration: (args) => {
62
+ console.log("onTranscript");
63
+ },
64
+ onInterrupt: (args) => {
65
+ console.log("onInterrupt");
66
+ },
67
+ onMessage: (args) => {
68
+ console.log("onGeneration");
69
+ },
70
+ }
71
+ )
88
72
  ```
89
73
 
90
74
  ## Available Exports
@@ -94,34 +78,18 @@ The following components, hooks, and utilities are available for import:
94
78
  ### Types & Configurations
95
79
 
96
80
  - `Channel`: Defines communication channels.
97
- - `ConnectionState`: Represents the state of a voice agent connection.
98
- - `MediaDeviceFailure`: Handles media device errors.
99
81
  - `ConnectionConfig`: Configures the connection settings for a voice agent.
100
82
  - `AgentConfig`: Configures the agent settings, including parameters and keywords.
101
83
 
102
- ### Components
103
-
104
- - `BrandIcon`: Displays the brand's representative icon.
105
- - `UserIcon`: Displays the user's representative icon.
106
- - `MessagingAction`: A messaging input component for user interactions.
107
- - `ConversationMessages`: Manages and displays the conversation flow.
108
-
109
- ### Context
84
+ ### Core
110
85
 
111
86
  - `VoiceAgent`: The core AI voice agent instance.
112
- - `VoiceAgentContext`: Provides the voice agent's context for managing interactions.
113
87
 
114
- ### Hooks
88
+ ### Hooks
115
89
 
116
90
  - `useConnectAgent`: Establishes a connection to the voice agent.
117
- - `useDisconnectAgent`: Disconnects the agent from the session.
118
- - `useInputModeToggleAgent`: Toggles between different input modes.
119
- - `useMicInputToggleAgent`: Enables or disables microphone input.
120
- - `useSpeakerOuputToggleAgent`: Enables or disables speaker output.
121
- - `useMultiband3DSpeakerTrackVolume`: Adjusts multiband volume for speaker tracks.
122
- - `useMultibandMicrophoneTrackVolume`: Adjusts multiband volume for microphone tracks.
123
- - `useSelectInputDeviceAgent`: Selects and manages input audio devices.
91
+ - `useAgentMessages`: Retrieves messages exchanged with the voice agent.
124
92
 
125
93
  ## License
126
94
 
127
- This project is licensed under the MIT License.
95
+ This project is licensed under the MIT License.