Welcome to the gpt-backend repository! This backend is built using Express and Node.js, incorporating JOI for request validation and the OpenAI library for handling chat-based requests to GPT (Generative Pre-trained Transformer) based on your OpenAI account tier.
-
Clone the Repository:
git clone https://github.com/shashanksingh2002/gpt-backend.git
-
Navigate to the Project Directory:
cd gpt-backend
-
Install Dependencies:
npm install
-
Set Up Environment Variables:
- Copy the contents of the
.env.example
file and create a new file named.env
. - Add your OpenAI API key and any other necessary environment variables.
- Copy the contents of the
-
Start the Server:
npm start
Once the server is running, you can make requests to the chat endpoint to interact with GPT:
- Endpoint:
/api/gpt
- Method: POST
- Body:
{ "model":"your gpt model name", "prompt": "Your message to GPT" }
This system is not limited to farm-related queries. You can customize the behavior by changing the system prompt present in the constant folder. Modify the system prompt to suit your use case and make the GPT work however you want!
Ensure that your OpenAI account tier supports the features used in this backend. Adjust your account settings accordingly to meet the requirements.
Feel free to contribute to the project by submitting issues or pull requests. We appreciate your feedback and help in making this backend more robust.
Happy customizing with gpt-backend! 🤖🌐