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

@boldare/openai-assistant

v1.2.0

Published

NestJS library for building chatbot solutions based on the OpenAI Assistant API

Downloads

44

Readme

🤖 AI Assistant

Introducing the NestJS library, designed to harness the power of OpenAI's Assistant, enabling developers to create highly efficient, scalable, and rapid AI assistants and chatbots. This library is tailored for seamless integration into the NestJS ecosystem, offering an intuitive API, WebSockets, and tools that streamline the development of AI-driven interactions. Whether you're building a customer service bot, a virtual assistant, or an interactive chatbot for engaging user experiences, our library empowers you to leverage cutting-edge AI capabilities with minimal effort.

🚀 Features

AI Assistant library features

  • Function calling: The library provides a way to create functions, which allows you to extend the assistant's capabilities with custom logic.
  • TTS (Text-to-Speech): The library provides a way to convert text to speech, which allows you to create voice-based interactions with the assistant.
  • STT (Speech-to-Text): The library provides a way to convert speech to text, which allows you to create voice-based interactions with the assistant.
  • File support: The library provides a way to add files to the assistant, which allows you to extend the assistant's knowledge base with custom data.
  • WebSockets: The library provides a WebSocket server for real-time communication between the client and the assistant.
  • REST API: The library provides a REST API for communication with the assistant.

Additional features in the repository

  • Embedded chatbot: The library provides a way to embed the chatbot on various websites through JavaScript scripts.
  • Chatbot client application: The repository includes an example client application (SPA) with a chatbot.

🏆 Getting started

In this section, you will learn how to integrate the AI Assistant library into your NestJS application. The following steps will guide you through the process of setting up the library and creating simple functionalities.

Step 0: Prerequisites

Install Node.js which includes Node Package Manager (^20.0.0 version).

Before you start, you will need to have an account on the OpenAI platform and an API key. You can create an account here.

Open or create your NestJS application where you would like to integrate the AI Assistant. If you don't have a NestJS application yet, you can create one using the following command:

nest new project-name

Step 1: Installation

Install the library using npm:

npm i @boldare/openai-assistant openai --save

Step 2: Env variables

Set up your environment variables, create environment variables in the .env file in the root directory of the project, and populate it with the necessary secrets. The assistant ID is optional and serves as a unique identifier for your assistant. When the environment variable is not set, the assistant will be created automatically. You can use the assistant ID to connect to an existing assistant, which can be found in the OpenAI platform after creating an assistant.

Create a .env file in the root directory of your project and populate it with the necessary secrets:

touch .env

Add the following content to the .env file:

# OpenAI API Key
OPENAI_API_KEY=

# Assistant ID - leave it empty if you don't have an assistant yet
ASSISTANT_ID=

Please note that the .env file should not be committed to the repository. Add it to the .gitignore file to prevent it from being committed.

Step 3: Configuration

The library provides a way to configure the assistant with the AssistantModule.forRoot method. The method takes a configuration object as an argument. Create a new configuration file like in a sample configuration file (chat.config.ts) and fill it with the necessary configuration.

More details about the configuration with code examples can be found in the wiki.

Step 4: Function calling

Create a new service that extends the AgentBase class, fill the definition and implement the output method.

  • The output method is the main method that will be called when the function is invoked.
  • The definition property is an object that describes the function and its parameters.

For more information about function calling, you can refer to the OpenAI documentation.

The instructions for creating a function can be found in the wiki, while examples can be found in the agents directory.


👨‍💻 Repository

The complete documentation on how to run the demo with all applications and libraries from the repository can be found in the wiki.


License

@boldare/openai-assistant is MIT licensed