Clone of ChatGPT, using Python, Flask, JavaScript, MySQL and an OpenAI API key. Build for a medical doctor in The Gambia, to enable access to GPT-4 through my API key. Before I met ChatGPT, I have never ever coded anything in Python. GPT-4 is amazing... It has its quirks, but once you get to know eachother, you and GPT-4 can become a great building team! The code will definitely have its flaws, especially possible security flaws. While coding, I slowly learned how to introduce SOME security features. Such as always checking if a user is logged in, using the "user_id" I stored earlier in a cookie. And the realizing an incrementing user_id starting at 1 isn't securing anything, so changing to UUID. A specific security-issue with this code: it does NOT do any REGEX checking on the input. The checks should, of course, be done on the server-side when input is collected. My userbase is small, it consists of only friends I can trust. But still... Problem: A user inputting code is not necessarily a malicious user. I have inputted loads of code, MySQL strings and HTML-designs into ChatGPT coding this app! :-) Have to think about how to solve this. Or better, let ChatGPT come up with a way to solve this. And then introduce bugs by doing so. And then listen to the "Apologies for the oversight". And then fix them with the help of ChatGPT. Thank you, ChatGPT, for your patience.
GPTalks
GPTalks is an interactive web application that enables users to have dynamic conversations with OpenAI's GPT language models. The application is built using Flask, a lightweight Python web framework, and serves as a user-friendly interface to communicate with the GPT models.
Features -Streamlined conversation interface for easy interaction with GPT models -Customizable model selection -Real-time conversation streaming for enhanced user experience -Storage and retrieval of chat history for future reference -Automatic conversation trimming to fit model token limits -Categorized chat history based on date
Get all files:
- Create a projectfolder, eg "GPTalks"
- Place "gptalks.py", "settings.env" and "requirements.txt" in the mainfolder
- Extract "subfolders.zip" in the mainfolder: you will now have a "static" and "templates" subfolder
Navigate to the project directory: cd GPTalks
Install the required dependencies: pip install -r requirements.txt
Input your own settings Open 'settings.env' Input your own settings Save as ".env" (remove 'settings' from the name)
Start the Flask server: py chatgptice.py
Open a web browser and visit http://localhost:5000 to start using GPTalks! Usage Input text and press enter, or send! -Optional: Choose a GPT model from the dropdown menu. Can also be changed dúring a conversation -Optional: Choose a prompt. The prompt is NOT loaded as role:"system" but as role:"user", since it seems to make nó difference. It can be inserted at any time (again)
The model will generate a response and display it in the conversation window. Each conversation is stored in MySQL, under a label that is generated by a seperate gpt-3.5-turbo call, that generates 1 word to describe the first input The chat history can be viewed and managed in the left sidebar. The left sidebar will collapse in windows smaller than 770px. When the user clicks on his/her own name, the "Prompts" editor can be reached, allowing the user to change the prompt order, edit the prompts, delete prompts, or add new prompts.
Contributing We welcome contributions to GPTalks! If you have any ideas, bug reports, or suggestions, feel free to open an issue or submit a pull request.
License
GPTalks is released under the MIT License. For more information, see the LICENSE file.