Coder Social home page Coder Social logo

boldare / openai-assistant Goto Github PK

View Code? Open in Web Editor NEW
17.0 9.0 3.0 737 KB

A NestJS library for building efficient, scalable, and quick solutions based on the OpenAI Assistant API (chatbots) πŸ€– πŸš€

Home Page: https://assistant.ai.boldare.dev

License: MIT License

JavaScript 1.45% TypeScript 83.51% HTML 5.11% SCSS 9.94%
ai assistant-api assistant-chat-bots chatbot chatgpt gpt nest nestjs node nodejs

openai-assistant's Introduction

Boldare

demo πŸ”Ή api docs πŸ”Ή npm πŸ”Ή github

πŸ€– 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: Prerequiring

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 --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

openai-assistant's People

Contributors

dependabot[bot] avatar sebastianmusial avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openai-assistant's Issues

Assistants API needs updating

Tool rename: The retrieval tool has been renamed to the file_search tool
Files belong to tools: Files are now associated with tools instead of Assistants and Messages. This means that:
AssistantFile and MessageFile objects no longer exist.
Instead of AssistantFile and MessageFile, files are attached to Assistants and Threads using the new tool_resources object.
The tool_resources for the code interpreter tool are a list of file_ids.
The tool_resources for the file_search tool are a new object called a vector_stores.
Messages now have an attachments, rather than a file_ids parameter. Message attachments are helpers that add the files to a Thread’s tool_resources.

https://platform.openai.com/docs/assistants/migration/what-has-changed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.