Skip to content

yharyarias/chatbot_openAI_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chatbot using OpenAI API and Docker

This project demonstrates how to create a chatbot using the OpenAI API and Dockerize it for easy deployment.

Table of Contents

Introduction

This repository contains a Python-based chatbot powered by the OpenAI API. The chatbot interacts with users in natural language, providing responses based on AI-generated content. The project demonstrates how to Dockerize the chatbot application, enabling seamless deployment across different environments.

Prerequisites

Before starting, ensure you have the following:

  • An OpenAI account
  • Python installed on your machine
  • Docker Desktop installed (for Dockerizing the application)
  • Visual Studio Code or any preferred code editor

Setup Instructions

Follow these steps to set up and run the chatbot application:

1. Create an OpenAI Account

If you haven't already, sign up for an OpenAI account at OpenAI.

2. Obtain API Key from OpenAI

After creating your account:

  • Log in to the OpenAI platform.
  • Navigate to the API section.
  • Generate an API key to authenticate API requests.

3. Setting Up Your Project

  1. Clone this repository to your local machine:

    git clone https://github.com/yourusername/chatbot-openai-docker.git
  2. Navigate into the project directory:

    cd chatbot-openai-docker
  3. Set up a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`

4. Developing the Chatbot

  1. Install required Python dependencies:
pip install -r requirements.txt
  1. Develop the chatbot script (chatbot.py) using the OpenAI API. Example code snippets are provided in the repository.

5. Configuring Environment Variables

  1. Create a .env file in the project root:
touch .env
  1. Add your OpenAI API key to the .env file:
OPENAI_API_KEY=your_api_key_here

Replace your_api_key_here with the API key obtained from OpenAI.

  1. Use the dotenv package to load environment variables in your Python script securely.

6. Running the Docker Image

  1. Ensure you have Docker Desktop installed and running on your machine.

  2. Set your OpenAI API key in Dockerfile:

# Set the environment variable for the OpenAI API key
ENV OPENAI_API_KEY="your_api_key_here"
  1. Build the Docker image using the docker build -t chatbot-image . command.
  2. Use docker run -it chatbot-imagen:latest to start the container.
  3. Test the chatbot functionality to ensure it interacts correctly with the OpenAI API.

Testing and Troubleshooting

Continue with the testing and troubleshooting sections as previously outlined in the README.

Additional Considerations

Continue with the additional considerations section as previously outlined in the README.

Contributing

Continue with the contributing section as previously outlined in the README.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published