chat with gpt-4-vision-preview in the notebook
This project provides a simple chat interface that allows users to interact with OpenAI's GPT-4 Vision model. It includes functionality to send messages, upload images, and receive responses from the AI. The conversation can be cleared or downloaded as a HTML file.
- Send text messages to GPT-4 Vision model.
- Upload images to be included in the conversation.
- Adjust the AI's response creativity with a temperature slider.
- Clear the conversation history.
- Download the conversation history in HTML format.
- Save and use an OpenAI API key for authentication.
To run this project, you will need:
- An OpenAI API key with access to the GPT-4 Vision model.
- Python environment with the following packages installed:
ipywidgets
IPython
requests
base64
json
- Clone this repository or copy the code into a Python file.
- Ensure you have the required packages installed in your Python environment.
- Run the code in a Jupyter Notebook or JupyterLab environment to interact with the widgets.
- Enter your OpenAI API key in the provided text box and click "Save API Key".
- Type your message in the 'Message' text area.
- Optionally, upload an image to send along with your message.
- Click "Send Message" to send your message to the GPT-4 Vision model.
- The conversation will be displayed in the interface.
- Use the "Clear Conversation" button to reset the conversation history.
- Use the "Download Conversation" button to save the conversation to your device.
- Adjust the "Temperature" slider to control the randomness of the AI's responses.
- The
send_message
function handles the sending of messages and images, as well as the reception of AI responses. - The
clear_conversation
function resets the conversation history. - The
download_conversation
function allows you to download the conversation history as a HTML file. - The
save_api_key
function saves the API key entered by the user for subsequent requests.
This code is for demonstration purposes and is not production-ready. Ensure you handle your API keys securely and adhere to OpenAI's usage policies.
This project is open-sourced under the MIT License. See the LICENSE file for more information.