This repository contains a Streamlit-based chatbot application that leverages the power of OpenAI's GPT models to assist Python developers with their coding tasks. The chatbot can provide code snippets, answer questions, and help with various programming tasks.
The chatbot reads your code files continously to help you improve on it. You can interact with it using speech or typed text. HTML display makes the chatbot response easy to read.
I started this repo because Github-copilot is not integrated in my favorite IDE. So I figured I'd do something similar, with no integration.
- Multiple modes: coder, code commenter, simple chatbot, and Python copilot
- Python copilot mode allows inputting file paths to interact with your codebase, providing context-aware assistance
- Automatic updates and loading of provided code files in Python copilot mode
- Streamlit-based user interface with speech-to-text and text input options for interaction
- Python code generation and assistance
- In-context code commenting and documentation
- Support for multiple GPT models
- Automatic and dynamic context size management to avoid overflowing context tokens
.
├── streamlit_app.py # Streamlit frontend application
├── chatbot_streamlit.py # Backend chatbot logic and interaction with OpenAI API
├── openia_config.txt # OpenAI API configuration file
├── Dockerfile # Dockerfile for containerizing the application
└── README.md # This README file
- Clone the repository:
git clone https://github.com/yourusername/python-copilot-chatbot.git
cd python-copilot-chatbot
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # For Windows: venv\Scripts\activate
- Install the required packages:
pip install -r requirements.txt
- Set up your OpenAI API key. You can obtain an API key from the OpenAI website. Save your API key in the
openia_config.txt
file.
openai.api_type = <api host>
openai.api_base = <api deployement ressource>
openai.api_version = 2023-03-15-preview
openai.api_key = <your api_key>
- Run the Streamlit application:
streamlit run streamlit_app.py
-
Open the provided URL in your web browser to access the chatbot interface.
-
Interact with the chatbot by typing your questions or code requests in the input area, or use the speech-to-text feature.
-
You can also provide file paths to Python files in your project to give the chatbot context about your codebase.
To containerize the application using Docker, follow these steps:
-
Make sure you have Docker installed on your system.
-
Build the Docker image:
docker build -t python-copilot-chatbot .
- Run the Docker container:
docker run -p 8501:8501 python-copilot-chatbot
- Open your web browser and navigate to
http://localhost:8501
to access the chatbot interface.
Contributions are welcome! Please feel free to submit issues or pull requests to improve the chatbot's functionality and performance.
This project is licensed under the MIT License.