@11labs/react
Advanced tools
Comparing version 0.0.2 to 0.0.3-beta.1
@@ -1,5 +0,5 @@ | ||
import { SessionConfig, Callbacks, Status } from "@11labs/client"; | ||
import { SessionConfig, Callbacks, Status, ClientToolsConfig } from "@11labs/client"; | ||
export type { Role, Mode, Status } from "@11labs/client"; | ||
export type HookOptions = Partial<SessionConfig & HookCallbacks>; | ||
export type HookCallbacks = Pick<Callbacks, "onConnect" | "onDisconnect" | "onError" | "onMessage" | "onDebug">; | ||
export type HookOptions = Partial<SessionConfig & HookCallbacks & ClientToolsConfig>; | ||
export type HookCallbacks = Pick<Callbacks, "onConnect" | "onDisconnect" | "onError" | "onMessage" | "onDebug" | "onUnhandledClientToolCall">; | ||
export declare function useConversation<T extends HookOptions>(defaultOptions?: T): { | ||
@@ -6,0 +6,0 @@ startSession: T extends SessionConfig ? (options?: HookOptions) => Promise<string> : (options: SessionConfig & HookOptions) => Promise<string>; |
{ | ||
"name": "@11labs/react", | ||
"version": "0.0.2", | ||
"version": "0.0.3-beta.1", | ||
"description": "ElevenLabs React Library", | ||
@@ -22,3 +22,3 @@ "main": "./dist/lib.umd.js", | ||
"dependencies": { | ||
"@11labs/client": "0.0.2" | ||
"@11labs/client": "0.0.3-beta.1" | ||
}, | ||
@@ -25,0 +25,0 @@ "peerDependencies": { |
@@ -53,2 +53,3 @@ # ElevenLabs React Library | ||
* **clientTools** - object definition for client tools that can be invoked by agent. [See below](#client-tools) for details. | ||
* **onConnect** - handler called when the conversation websocket connection is established. | ||
@@ -59,2 +60,24 @@ * **onDisconnect** - handler called when the conversation websocket connection is ended. | ||
##### Client Tools | ||
Client tools are a way to enabled agent to invoke client-side functionality. This can be used to trigger actions in the client, such as opening a modal or doing an API call on behalf of the user. | ||
Client tools definition is an object of functions, and needs to be identical with your configuration within the [ElevenLabs UI](https://elevenlabs.io/app/conversational-ai), where you can name and describe different tools, as well as set up the parameters passed by the agent. | ||
```ts | ||
const conversation = useConversation({ | ||
clientTools: { | ||
displayMessage: (parameters: {text: string}) => { | ||
alert(text); | ||
return "Message displayed"; | ||
} | ||
} | ||
}); | ||
``` | ||
In case function returns a value, it will be passed back to the agent as a response. | ||
Note that the tool needs to be explicitly set to be blocking conversation in ElevenLabs UI for the agent to await and react to the response, otherwise agent assumes success and continues the conversation. | ||
#### Methods | ||
@@ -61,0 +84,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37557
167
+ Added@11labs/client@0.0.3-beta.1(transitive)
- Removed@11labs/client@0.0.2(transitive)
Updated@11labs/client@0.0.3-beta.1