This project is a simple chatbot that leverages the OpenAI API to generate conversational responses based on user inputs and maintains conversation history for contextual relevance.
- Uses OpenAI's API to generate responses with context retention.
- Configuration options for model selection, response creativity, and token length.
- Secure handling of API keys through environment variables.
- Terminal-based interface for user interaction.
Ensure you have the following installed:
- Python 3
- Virtual environment
- OpenAI API key
-
Clone the repository:
git clone https://github.com/AlvinIsac/OpenApi.git
-
Navigate to the project directory:
cd OpenApi
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project directory and add your OpenAI API key:OPENAI_API_KEY= <open_api_key>
Note: You can purchase a new one from OpenAI's Platform.
-
Run the chatbot script:
python chatbot.py
-
Interact with the chatbot by typing messages and you can also customise it for your needs. Type
exit
to end the conversation.
model
: Specifies the OpenAI model to use (default:gpt-4o-mini
).temperature
: Controls response creativity (default: 0.7).max_tokens
: Sets the maximum length of responses (default: 100 tokens).