1.0.3 • Published 5 months ago

@hodfords/caigent v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Hodfords AI Web SDK

Welcome to the Hodfords AI Web SDK! This SDK enables you to integrate Hodfords AI's voice agent capabilities directly into your web applications and browser extensions.

Installation

Install the SDK with npm:

npm install @hodfords/caigent

Usage

Here’s how to quickly set up a voice agent in your web application:

1. Import the SDK:

import HodfordsVoiceAI from '@hodfords/caigent';

2. Initialize the Client:

const caigentClient = HodfordsVoiceAI.createClient({
  endPoint: 'your websocket url',
});

3. Start a Conversation:

Using a Predefined Agent

Start a conversation with your temperature using the following code:

caigentClient.start({
  temperature: 0.7
});

Replace 'temperature' with the temperature setting of your obtained from the Playground.

4. Stop a Conversation:

caigentClient.stop();

5. Mute / Unmute microphone

caigentClient.mute();
caigentClient.unmute();

5. Setup event listener:

    caigentClient.on("onopen", () => {
      // When the client connected to the server
    });

    caigentClient.on("onready", () => {
      // When the conversation is ready
    });

    caigentClient.on("onaudio", (audio: Uint8Array) => {
      // Incoming audio chunk
    });

    caigentClient.on("analyzer", (analyzer: AnalyserNode) => {
      // AnalyserNode that you can use for audio animation
    });

    caigentClient.on("onclose", (event) => {
      // When the connection is closed
    });

    caigentClient.on("onerror", (error) => {
      // An error occurred
    });

Support

If you encounter any issues or have questions, please reach out to us directly at gavin.adam@hodfords.com