{"id":19044277,"url":"https://github.com/arturogonzalezm/chatbot_chatgpt","last_synced_at":"2026-05-12T23:33:25.834Z","repository":{"id":229549529,"uuid":"777021396","full_name":"arturogonzalezm/chatbot_chatgpt","owner":"arturogonzalezm","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-26T03:12:29.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T08:14:42.615Z","etag":null,"topics":["chatbot","chatgpt-api","python310","streamlit","streamlit-application"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arturogonzalezm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-25T03:08:49.000Z","updated_at":"2024-03-26T03:26:32.000Z","dependencies_parsed_at":"2024-03-25T04:32:20.160Z","dependency_job_id":"209f1e3d-fbb1-41de-977c-e22e061e0ffa","html_url":"https://github.com/arturogonzalezm/chatbot_chatgpt","commit_stats":null,"previous_names":["arturogonzalezm/chatbot_chatgpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturogonzalezm%2Fchatbot_chatgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturogonzalezm%2Fchatbot_chatgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturogonzalezm%2Fchatbot_chatgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturogonzalezm%2Fchatbot_chatgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arturogonzalezm","download_url":"https://codeload.github.com/arturogonzalezm/chatbot_chatgpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240100558,"owners_count":19747689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","chatgpt-api","python310","streamlit","streamlit-application"],"created_at":"2024-11-08T22:45:22.481Z","updated_at":"2026-05-09T16:30:22.124Z","avatar_url":"https://github.com/arturogonzalezm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-purple.svg)](https://github.com/arturogonzalezm/chatbot_chatgpt/blob/master/LICENSE)\n[![Read the Docs](https://img.shields.io/readthedocs/:packageName)](https://github.com/arturogonzalezm/chatbot_chatgpt/wiki)\n[![PyLint](https://github.com/arturogonzalezm/chatbot_chatgpt/actions/workflows/workflow.yml/badge.svg)](https://github.com/arturogonzalezm/chatbot_chatgpt/actions/workflows/workflow.yml)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/arturogonzalezm/chatbot_chatgpt)\n\n# Streamlit Chatbot with OpenAI\n\nThis project integrates OpenAI's language models into a Streamlit web application, creating an interactive chatbot interface. It allows users to send messages and receive AI-generated responses, manage conversation history, and perform other interactions in real time.\n\n## Features\n\n- **Interactive Chat Interface**: Engage in a conversation with the AI, with the ability to view each message's response in real time.\n- **Conversation History**: Maintains a log of the entire conversation for reference.\n- **Conversation Management**: Supports starting new conversations, saving current conversations, renaming them, and switching between them.\n\n## Screenshots\n\n- **White:**\n\n![white](images/white.png)\n\n- **Dark:**\n\n![dark](images/dark.png)\n\n## Tech Specs\n\n- **Conda**: Python 3.10\n- **Streamlit**: 1.32.2\n- **OpenAI**: 1.14.3\n- **ChatGPT**: gpt-4-turbo-preview\n\n## Code Breakdown\n\n### OpenAI Integration\n\n- `AsyncOpenAI Client`: Utilises `openai.AsyncOpenAI` for creating an asynchronous client with the OpenAI API, authorised via an environment-stored API key.\n- `get_response`: An asynchronous function that sends user messages to the OpenAI API and awaits responses, utilizing the \"gpt-4-turbo-preview\" model.\n\n### Streamlit Interface\n\n- **Initialization**: Checks and initialises `session_state` variables for storing conversation histories and saved conversations.\n- **User Input Form**: Allows users to write and submit messages to the chatbot.\n- **Display Area**: Shows the ongoing conversation history.\n- **Sidebar Features**: Provides controls for new conversations, saving current chats, and managing saved conversations.\n\n### Conversation Management\n\n- `save_current_chat`: Verifies whether the current conversation is already saved; if not, it saves the chat with a unique timestamp.\n- **Sidebar Controls**: Include functionality for initiating new conversations, saving and renaming conversations, and loading previously saved chats.\n\n## Sequence Diagram\n\nBelow is a sequence diagram illustrating the interaction flow within the application:\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant Interface as Streamlit Interface\n    participant Server as AsyncOpenAI Client\n\n    User-\u003e\u003eInterface: Enters message\n    Interface-\u003e\u003eServer: Sends message\n    Server-\u003e\u003eServer: Processes AI response\n    Server-\u003e\u003eInterface: Returns AI response\n    Interface-\u003e\u003eUser: Displays response\n```\n\n### Custom CSS\n\n- **custom_css**: Custom CSS for styling the Streamlit interface, making the background gradient and adjusting other UI elements to improve the user experience.\n\n## Usage\n\n1. Install all required packages from the requirements.txt file.\n2. Set your OpenAI API key in the `.env` file.\n3. Run the Streamlit application using the command `streamlit run app.py`.\n4. Interact with the chatbot through the web interface.\n\n## Note\n\n- The application uses asynchronous calls to interact with OpenAI's API, ensuring that the user interface remains responsive.\n- The chat history and saved conversations are stored in the session state, meaning they are temporary and will be cleared once the session ends or the app is reloaded.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturogonzalezm%2Fchatbot_chatgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturogonzalezm%2Fchatbot_chatgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturogonzalezm%2Fchatbot_chatgpt/lists"}