{"id":19857970,"url":"https://github.com/boldare/openai-assistant","last_synced_at":"2025-10-19T02:04:11.938Z","repository":{"id":227819724,"uuid":"722543277","full_name":"boldare/openai-assistant","owner":"boldare","description":"A NestJS library for building efficient, scalable, and quick solutions based on the OpenAI Assistant API (chatbots) 🤖 🚀  Chatbot, Ready API and UI, OpenAI Functions, GPT-4 Vision, GPT-4o","archived":false,"fork":false,"pushed_at":"2025-03-10T23:08:54.000Z","size":2303,"stargazers_count":87,"open_issues_count":6,"forks_count":18,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-29T01:04:28.083Z","etag":null,"topics":["ai","assistant-api","assistant-chat-bots","chatbot","chatgpt","gpt","javascript","nest","nestjs","node","nodejs","openai","openai-assistant-api","openai-assistant-api-chatbot","openai-assistants","openai-function-call","openai-template","opensource","typescript","websockets"],"latest_commit_sha":null,"homepage":"https://assistant.ai.boldare.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boldare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-23T11:26:51.000Z","updated_at":"2025-03-28T09:08:20.000Z","dependencies_parsed_at":"2024-05-07T12:33:54.064Z","dependency_job_id":null,"html_url":"https://github.com/boldare/openai-assistant","commit_stats":null,"previous_names":["boldare/ai-assistant","boldare/openai-assistant"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fopenai-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fopenai-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fopenai-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fopenai-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boldare","download_url":"https://codeload.github.com/boldare/openai-assistant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276162,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","assistant-api","assistant-chat-bots","chatbot","chatgpt","gpt","javascript","nest","nestjs","node","nodejs","openai","openai-assistant-api","openai-assistant-api-chatbot","openai-assistants","openai-function-call","openai-template","opensource","typescript","websockets"],"created_at":"2024-11-12T14:20:33.760Z","updated_at":"2025-10-19T02:04:11.858Z","avatar_url":"https://github.com/boldare.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\" style=\"text-align: center;\"\u003e\n  \u003ca href=\"https://www.boldare.com/services/ai-software-development-consulting/\" target=\"blank\"\u003e\n    \u003cimg src=\"https://assistant.ai.boldare.dev/assets/ai-assistant.jpg\" width=\"280\" alt=\"Boldare\" /\u003e\n  \u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n\n  A NestJS library for building efficient, scalable, and fast solutions using the OpenAI Assistant API (chatbots). \u003cbr\u003e Kickstart your AI Assistant development in under 15 minutes 🚀\n\n  \u003ca href=\"https://assistant.ai.boldare.dev/\" target=\"_blank\"\u003e\u003cimg alt=\"demo\" src=\"https://img.shields.io/badge/demo-👀-green\"\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca href=\"https://assistant.ai.boldare.dev/api/docs\" target=\"_blank\"\u003e\u003cimg alt=\"docs\" src=\"https://img.shields.io/badge/api docs-📚-orange\"\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca href=\"https://www.npmjs.com/package/@boldare/openai-assistant\" target=\"_blank\"\u003e\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/%40boldare%2Fopenai-assistant\"\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca href=\"https://www.boldare.com/services/ai-software-development-consulting/\" target=\"_blank\"\u003e\u003cimg alt=\"docs\" src=\"https://img.shields.io/badge/How we can help you-💡-brown\"\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca href=\"https://github.com/boldare/openai-assistant\" target=\"_blank\"\u003e\u003cimg alt=\"Github\" src=\"https://img.shields.io/github/stars/boldare/openai-assistant\"\u003e\u003c/a\u003e\n   \n  [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/boldare/openai-assistant)\n\n\u003c/div\u003e\n\n# AI Assistant\n\nIntroducing the NestJS library. Whether you're building a virtual assistant, or an interactive chatbot for engaging user experiences, our library empowers you to leverage cutting-edge AI capabilities with minimal effort.\n\n**The library provides ready-to-use API endpoints** handling your assistant and WebSocket server for real-time communication between the client and the assistant. Install the library and paste the config to get it running.\n\n## 📚 Watch the tutorial\n\n\u003cdiv align=\"center\" style=\"text-align: center;\"\u003e\n\n[![Watch the tutorial](https://img.youtube.com/vi/rxPdFat90qY/0.jpg)](https://www.youtube.com/watch?v=rxPdFat90qY)\n\n[Video - AI Assistant in 15 min](https://www.youtube.com/watch?v=rxPdFat90qY)\n\n\u003c/div\u003e\n\n## 🚀 Features\n\n### AI Assistant library features\n\n- **Function calling**: create functions, so assistant can execute your custom logic!\n- **TTS (Text-to-Speech)**: convert text to speech, so you can hear your assistant!\n- **STT (Speech-to-Text)**: convert speech to text, so you can make conversation easier!\n- **File support**: add files to the assistant, so you can extend assistant's knowledge base with custom data!\n- **WebSockets**: establish WebSocket server for real-time communication between the client and the assistant!\n- **REST API**: Just use ready REST API for communication with the assistant!\n- **Vision with GPT-4o** - use the GPT-4o and make your assistant understand images and generate text based on them!\n\n#### Additional features in the repository\n\nThe repository contains a library but also provides additional features. You can just clone the repository and use it instantly to gain from all features:\n\n- **Embedded chatbot**: embed the chatbot on various websites through JavaScript scripts!\n- **Chatbot client application**: use ready client application (SPA) with a chatbot!\n\n## 🏆 Getting started\n\nIn 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.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 0:\u003c/b\u003e Prerequisites\u003c/summary\u003e\u003cbr\u003e\n\n- Node.js (`^20.0.0` version)\n- npm (`^10.0.0` version)\n- NestJS (`^10.0.0` version)\n- OpenAI (`^4.51.0` version)\n- OpenAI API key\n\nOpen or create your NestJS application where you would like to integrate the AI Assistant. To create a new NestJS application, use the following command:\n\n```bash\nnest new project-name\n```\n\nNow you have to install the packages. Go to the next step.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 1:\u003c/b\u003e Installation\u003c/summary\u003e\u003cbr\u003e\n\nMake sure you are in the root directory of your project.\nInstall the library and `openai` package using npm:\n\n```bash\nnpm i @boldare/openai-assistant openai --save\n```\n\nThe library is installed but we have to configure it. Go to the next step.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 2:\u003c/b\u003e Env variables\u003c/summary\u003e\u003cbr\u003e\n\nSet 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.\n\nCreate a `.env` file in the root directory of your project and populate it with the necessary secrets:\n \n```bash\ntouch .env\n```\n\nAdd the following content to the `.env` file:\n\n```dotenv\n# OpenAI API Key\nOPENAI_API_KEY=\n\n# Assistant ID - leave it empty if you don't have an assistant to reuse\nASSISTANT_ID=\n```\n\nPlease note that the `.env` file should not be committed to the repository. *Add the `.env` file to the `.gitignore`* file to prevent it from being committed.\n\nThis was the first step needed to run the library. The next step is to configure the assistant.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 3:\u003c/b\u003e Configuration\u003c/summary\u003e\u003cbr\u003e\n\nThe 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. \n\n```typescript\n// chat.config.ts file\nimport { AssistantConfigParams } from '@boldare/openai-assistant';\nimport { AssistantCreateParams } from 'openai/resources/beta';\n\n// Default OpenAI configuration\nexport const assistantParams: AssistantCreateParams = {\n  name: 'Your assistant name',\n  instructions: `You are a chatbot assistant. Speak briefly and clearly.`,\n  tools: [{ type: 'file_search'}],\n  model: 'gpt-4-turbo',\n  temperature: 0.05,\n};\n\n// Additional configuration for our assistant\nexport const assistantConfig: AssistantConfigParams = {\n  id: process.env['ASSISTANT_ID'],\n  params: assistantParams,\n  filesDir: './apps/api/src/app/knowledge',\n  toolResources: {\n    file_search: {\n      // Provide files if you use file_search tool\n      fileNames: ['example1.txt', 'example2.txt'],\n    },\n  },\n};\n```\n\n\nMore details about the configuration can be found in the [wiki](https://github.com/boldare/openai-assistant/wiki/%F0%9F%A4%96-AI-Assistant#step-3-configuration).\n\n#### What is this step for?\nFrom now you can run your application and call the assistant.\n\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 4:\u003c/b\u003e Function calling\u003c/summary\u003e\u003cbr\u003e\n\n\nFunction calling allows you to extend the assistant's capabilities with custom logic. **If you are not going to use function calling you can jump to: [Step 5: Testing](#step-5-running-the-application-and-testing).**\n\nCreate a new service that extends the `AgentBase` class, fill the definition and implement the `output` method.\n\n- The `output` method is the main method that will be called when the function is invoked by the assistant.\n- The `definition` property is an object that describes the function and its parameters so the assistant can understand how to call it.\n\nFor more information about function calling, you can refer to the [OpenAI documentation](https://platform.openai.com/docs/assistants/tools/defining-functions).\n\nThe 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.\n\n#### What is this step for?\n\nIf you've defined a function and the output method, you can now call it from the assistant just by asking him to do the action described in the function definition.\n\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eStep 5:\u003c/b\u003e Running the application and testing\u003c/summary\u003e\u003cbr\u003e\n\nRun your application and this will allow you to test the assistant. \n  \n  ```bash\n  # use this if you are using the repository:\n  npm run start:dev\n\n  # if you are using your own NestJS application, please check the npm scripts in the package.json file\n  # defualt command for NestJS is:\n  npm run start\n  ```\n\n  Then you can test the assistant.\n  1. First, you need to create a thread. You can create one\n  by sending a POST request to the `/assistant/threads` endpoint with the **empty object in the body**.\n  2. Then you can send a message to the assistant by sending a POST request to the `/assistant/chat` endpoint with the following body:\n  ```json\n  {\n    \"threadId\": \"your-thread-id\",\n    \"content\": \"Hello, how are you?\"\n  }\n  ```\n  3. The assistant will respond with a message. You can send more messages to the assistant by sending a POST request to the `/assistant/chat` endpoint with the same body as in step 2.\n\n  Congrats! You have successfully integrated the AI Assistant library into your NestJS application. 🎉\n\n\u003c/details\u003e\n\n## 🤔 Are you stuck?\n\nThe 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).\n\nBoldare's engineers are here to help you. If you have any questions or need help with the implementation, feel free to [book a call](https://calendly.com/olivier-halupczok/30min) with one of our engineers.\n\nLearn more how **[Boldare can help you with AI development](https://www.boldare.com/services/ai-software-development-consulting/)**.\n\nYou can also ask questions in the [GitHub Discussions](https://github.com/boldare/openai-assistant/discussions) section.\n\n\n## Contributions\n\nWould you like to see new features in the library? \n- You can freely contribute to the project! Just create a pull request with your changes.\n- [Talk your idea over with one of our engineers.](https://calendly.com/olivier-halupczok/30min)\n- You can also [post your idea here](https://github.com/boldare/openai-assistant/discussions).\n\n## License\n\n`@boldare/openai-assistant` and this repository is MIT licensed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboldare%2Fopenai-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboldare%2Fopenai-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboldare%2Fopenai-assistant/lists"}