You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -19,19 +19,19 @@ Introducing the NestJS library, designed to harness the power of OpenAI's Assist
19
19
20
20
#### AI Assistant library features
21
21
22
-
-**WebSockets**: The library provides a WebSocket server for real-time communication between the client and the assistant.
23
-
-**REST API**: The library provides a REST API for communication with the assistant.
24
22
-**Function calling**: The library provides a way to create functions, which allows you to extend the assistant's capabilities with custom logic.
25
-
-**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.
26
23
-**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.
27
24
-**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.
25
+
-**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.
26
+
-**WebSockets**: The library provides a WebSocket server for real-time communication between the client and the assistant.
27
+
-**REST API**: The library provides a REST API for communication with the assistant.
28
28
29
29
#### Additional features in the repository
30
30
31
31
-**Embedded chatbot**: The library provides a way to embed the chatbot on various websites through JavaScript scripts.
32
32
-**Chatbot client application**: The repository includes an example client application (SPA) with a chatbot.
33
33
34
-
## Getting started
34
+
## 🏆 Getting started
35
35
36
36
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.
37
37
@@ -55,10 +55,10 @@ npm i @boldare/openai-assistant --save
55
55
56
56
### Step 2: Env variables
57
57
58
-
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. You will need to add the OpenAI API Key and the Assistant ID. The Assistant ID is optional, and you can leave it empty if you don't have an assistant yet.
58
+
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.
59
59
60
60
Create a `.env` file in the root directory of your project and populate it with the necessary secrets:
61
-
61
+
62
62
```bash
63
63
touch .env
64
64
```
@@ -73,54 +73,14 @@ OPENAI_API_KEY=
73
73
ASSISTANT_ID=
74
74
```
75
75
76
-
### Step 3: Configuration
77
-
78
-
Configure the settings for your assistant. For more information about assistant parameters, you can refer to the [OpenAI documentation](https://platform.openai.com/docs/assistants/how-it-works/creating-assistants). A sample configuration can be found in ([chat.config.ts](apps%2Fapi%2Fsrc%2Fapp%2Fchat%2Fchat.config.ts)).
Automatically, the library will add WebSockets ([chat.gateway.ts](libs/openai-assistant/src/lib/chat/chat.gateway.ts)) and a [REST API](https://assistant.ai.boldare.dev/api/docs) for the assistant. The WebSocket server will be available at the `/` endpoint, and the [REST API](https://assistant.ai.boldare.dev/api/docs) will be available at the `/api` endpoint (depending on the API prefix).
78
+
### Step 3: Configuration
115
79
116
-
#### Websockets events
80
+
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)](apps%2Fapi%2Fsrc%2Fapp%2Fchat%2Fchat.config.ts) and fill it with the necessary configuration.
117
81
118
-
Currently, the library provides the following WebSocket events:
82
+
More details about the configuration with code examples can be found in the [wiki](https://github.com/boldare/openai-assistant/wiki/%F0%9F%A4%96-AI-Assistant#step-3-configuration).
|`send_message`| The event is emitted when the user sends a message. |
123
-
|`message_received`| The event is emitted when the assistant sends a message. |
124
84
125
85
### Step 4: Function calling
126
86
@@ -130,117 +90,16 @@ Create a new service that extends the `AgentBase` class, fill the definition and
130
90
- The `definition` property is an object that describes the function and its parameters.
131
91
132
92
For more information about function calling, you can refer to the [OpenAI documentation](https://platform.openai.com/docs/assistants/tools/defining-functions).
133
-
Below is an example of a service that extends the `AgentBase` class:
The instructions for creating a function can be found in the [wiki](https://github.com/boldare/openai-assistant/wiki/%F0%9F%A4%96-AI-Assistant#step-4-function-calling), while examples can be found in the [agents](apps/api/src/app/chat/agents) directory.
191
95
192
96
---
193
97
194
98
# 👨💻 Repository
195
99
196
-
The repository includes a library with an AI assistant as well as other useful parts:
100
+
The complete documentation on how to run the demo with all applications and libraries from the repository can be found in the [wiki](https://github.com/boldare/openai-assistant/wiki/%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-Repository).
|`@boldare/openai-assistant`| A NestJS library based on the OpenAI Assistant for building efficient, scalable, and quick solutions for AI assistants/chatbots |[Documentation](https://github.com/boldare/openai-assistant/wiki/%F0%9F%A4%96-AI-Assistant)|
201
-
|`@boldare/ai-embedded`| The code enables embedding the chatbot on various websites through JavaScript scripts. |[Documentation](https://github.com/boldare/openai-assistant/wiki/%F0%9F%96%87-Integrating-Chatbot-into-Your-Website)|
202
-
|`api`| Example usage of the `@boldare/openai-assistant` library. |[Documentation](https://github.com/boldare/openai-assistant/wiki/%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-Repository)|
203
-
|`spa`| Example client application (SPA) with a chatbot. |[Documenation](https://github.com/boldare/openai-assistant/wiki/%F0%9F%92%AC-Chatbot-%E2%80%90-Client-application)|
204
-
205
-
## Getting started
206
-
207
-
### Step 1: Install dependencies
208
-
209
-
```bash
210
-
npm install
211
-
```
212
-
213
-
### Step 2: Env variables
214
-
215
-
Set up your environment variables, copy the `.env.dist` file to `.env` file in the root directory of the project, and populate it with the necessary secrets.
0 commit comments