The OpenAI Connect Node App is an open-source project designed to serve as a simple interface for interacting with OpenAI's GPT (Generative Pre-trained Transformer) models. The app facilitates threaded conversations, allowing users to engage in dynamic and context-aware interactions.
Before running the application, make sure you have the following prerequisites installed:
- Node v20.10.0
- npm (Node Package Manager)
- OpenAI GPT-3.5 API Key
- Assistant ID from OpenAI
-
Clone the repository to your local machine:
git clone https://github.com/uhurutek/openai-connect-nodeapp.git
-
Navigate to the project directory:
cd openai-connect-nodeapp
-
Install dependencies:
yarn install
-
Create a .env file in the project root and add the following configuration:
PORT=8000 GPT_API_KEY=your_openai_GPT-3.5_api_key GPT_ASSISTANT_ID=your_assistant_id DOMAIN_ALLOW=[http://your-client-domain.com,http://your-client2-domain.com] GPT_RUN_SLEEP=3
Replace your_openai_api_key and your_assistant_id with your OpenAI API key and assistant ID. Also, set http://your-client-domain.com as the allowed domain for CORS.
-
Start the Node.js server:
yarn start
The server will be running on the specified port (default is 8000).
-
Use the provided API endpoints to interact with the OpenAI GPT-3.5 model:
- POST /chats: Create a new chat thread.
- POST /chats/:threadID/:question: Post a question to an existing chat thread.
-
Create a new chat thread
curl -X POST http://localhost:8000/chats
-
Post a question to a chat thread
curl -X POST http://localhost:8000/chats/your_thread_id/Can you help me with this question?
docker compose -f docker/docker-compose.yml up -d --build
For the initial start, use:
yarn start
And for subsequent restarts, use:
yarn restart
This project is licensed under the MIT License. Feel free to use and modify the code as needed.
This project utilizes the OpenAI GPT-3.5 beta API. Visit OpenAI for more information on accessing the API.