{"id":25376481,"url":"https://github.com/sbslee/streamlit-openai","last_synced_at":"2025-10-30T07:31:16.051Z","repository":{"id":275727702,"uuid":"926897060","full_name":"sbslee/streamlit-openai","owner":"sbslee","description":"Build AI chatbots with Streamlit and OpenAI's API","archived":false,"fork":false,"pushed_at":"2025-02-09T12:33:50.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T01:35:29.898Z","etag":null,"topics":["assistants-api","chat-completions-api","function-calling","openai","streamlit"],"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/sbslee.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,"publiccode":null,"codemeta":null}},"created_at":"2025-02-04T03:33:12.000Z","updated_at":"2025-02-08T06:44:30.000Z","dependencies_parsed_at":"2025-02-04T09:26:16.887Z","dependency_job_id":"8bcf3b3d-4351-472a-8c80-c481ec047f65","html_url":"https://github.com/sbslee/streamlit-openai","commit_stats":null,"previous_names":["sbslee/streamlit-openai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbslee%2Fstreamlit-openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbslee%2Fstreamlit-openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbslee%2Fstreamlit-openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbslee%2Fstreamlit-openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbslee","download_url":"https://codeload.github.com/sbslee/streamlit-openai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238945663,"owners_count":19556699,"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":["assistants-api","chat-completions-api","function-calling","openai","streamlit"],"created_at":"2025-02-15T04:28:04.076Z","updated_at":"2025-10-30T07:31:16.044Z","avatar_url":"https://github.com/sbslee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/streamlit-openai.svg)](https://badge.fury.io/py/streamlit-openai)\n\nWelcome to the `streamlit-openai` package!\n\nThis package provides a Streamlit component for building interactive chat \ninterfaces powered by OpenAI.\n\nHere’s a quick overview of the package’s key features:\n\n- Easily create chat interfaces in Streamlit\n- Real-time streaming responses using the Responses API\n- Integration with OpenAI tools: reasoning, function calling, remote MCP, file search, code interpreter, vision, image generation, web search, and more\n- File input support for richer interactions\n- Fully customizable chat interface, including model selection, temperature settings, and more\n- Support for saving and retrieving chat history\n\n# Table of Contents\n- [Installation](#installation)\n- [Usage](#usage)\n- [Schematic Diagram](#schematic-diagram)\n- [Features](#features)\n  - [Function Calling](#function-calling)\n    - [Image Generation Example](#image-generation-example)\n    - [Web Search Example](#web-search-example)\n    - [Audio Transcription Example](#audio-transcription-example)\n  - [Reasoning](#reasoning)\n  - [Remote MCP](#remote-mcp)\n  - [File Inputs](#file-inputs)\n    - [Message Attachments](#message-attachments)\n    - [Static File Upload](#static-file-upload)\n    - [File Uploader Widget](#file-uploader-widget)\n  - [Vision](#vision)\n  - [Image Generation](#image-generation)\n  - [File Search](#file-search)\n    - [PDF Vision Support](#pdf-vision-support)\n    - [Vector Store Retrieval](#vector-store-retrieval)\n  - [Web Search](#web-search)\n  - [Code Interpreter](#code-interpreter)\n  - [Chat History](#chat-history)\n  - [Chat Summary](#chat-summary)\n  - [Token Usage](#token-usage)\n  - [Storage Management](#storage-management)\n- [Customization](#customization)\n  - [Model Selection](#model-selection)\n  - [Temperature](#temperature)\n  - [Instructions](#instructions)\n  - [Avatar Image](#avatar-image)\n  - [Welcome Message](#welcome-message)\n  - [Example Messages](#example-messages)\n  - [Info Message](#info-message)\n  - [Input Box Placeholder](#input-box-placeholder)\n- [Chat Completions and Assistants APIs](#chat-completions-and-assistants-apis)\n- [Changelog](#changelog)\n\n# Installation\n\n```sh\n$ pip install streamlit-openai streamlit openai\n```\n\n# Usage\n\nExport your OpenAI API key:\n\n```sh\n$ export OPENAI_API_KEY='sk-...'\n```\n\nSave the following code to `app.py`:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat()\n\nst.session_state.chat.run()\n```\n\nRun the app:\n\n```sh\n$ streamlit run app.py\n```\n\n# Schematic Diagram\n\nThe diagram below illustrates the `Section` and `Block` classes used\nto create a chat interface.\n\nIn the diagram, the uploaded file (`instructions.txt`) contains the following \ncontent:\n\n\"Create a 2x10 table with random numbers and save it as a CSV file, using 'X' \nand 'Y' as column names. Then, generate a scatter plot based on this table. \nSave the plot as a PNG file. Finally, display both the plot and the table.\"\n\nThe assistant uses file search to retrieve the instructions from the uploaded \nfile, and the code interpreter to execute the instructions and generate the \noutput files.\n\n![Schematic diagram](schematic_diagram.png)\n\n# Features\n\n## Function Calling\n\nYou can define and invoke custom functions within a chat using OpenAI's \nfunction calling capabilities. To create a custom function, provide the \n`name`, `description`, `parameters`, and `handler` arguments when initializing \na `CustomFunction`.\n\n### Image Generation Example\n\nUpdate: As of the 0.1.2 release, the `streamlit_openai` package natively \nsupports image generation (see [Image Generation](#image-generation)) \nTherefore, creating a custom function for this purpose is no longer necessary. \nHowever, if you prefer to define a custom image generation function, you can \nstill do so using the `CustomFunction` class.\n\nBelow is an example of a custom function that generates an image based on a \nuser-provided prompt:\n\n```python\nimport streamlit as st\nimport openai\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    def handler(prompt):\n        client = openai.OpenAI()\n        response = client.images.generate(\n            model=\"dall-e-3\",\n            prompt=prompt,\n            size=\"1024x1024\",\n            quality=\"standard\",\n            n=1,\n        )\n        return response.data[0].url\n    \n    generate_image = streamlit_openai.CustomFunction(\n        name=\"generate_image\",\n        description=\"Generate an image based on a given prompt.\",\n        parameters={\n            \"type\": \"object\",\n            \"properties\": {\n                \"prompt\": {\n                    \"type\": \"string\",\n                    \"description\": \"A description of the image to be generated.\",\n                }\n            },\n            \"required\": [\"prompt\"]\n        },\n        handler=handler\n    )\n\n    st.session_state.chat = streamlit_openai.Chat(\n        functions=[generate_image]\n    )\n\nst.session_state.chat.run()\n```\n\n### Web Search Example\n\nUpdate: As of the 0.1.2 release, the `streamlit_openai` package natively \nsupports web search (see [Web Search](#web-search)). Therefore, creating a \ncustom function for this purpose is no longer necessary. However, if you \nprefer to define a custom web search function, you can still do so using the \n`CustomFunction` class.\n\nYou can create a custom function to search the web using a given query. Below \nis an example:\n\n```python\nimport streamlit as st\nimport openai\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    def handler(prompt):\n        client = openai.OpenAI()\n        response = client.chat.completions.create(\n            model=\"gpt-4o-search-preview\",\n            web_search_options={},\n            messages=[{\"role\": \"user\", \"content\": prompt}],\n        )\n        return response.choices[0].message.content\n    \n    search_web = streamlit_openai.CustomFunction(\n        name=\"search_web\",\n        description=\"Search the web using a query.\",\n        parameters={\n            \"type\": \"object\",\n            \"properties\": {\n                \"prompt\": {\n                    \"type\": \"string\",\n                    \"description\": \"Search query.\",\n                }\n            },\n            \"required\": [\"prompt\"]\n        },\n        handler=handler\n    )\n\n    st.session_state.chat = streamlit_openai.Chat(\n        functions=[search_web],\n    )\n\nst.session_state.chat.run()\n```\n\n### Audio Transcription Example\n\nYou can create a custom function to transcribe audio files. Below is an \nexample:\n\n```python\nimport streamlit as st\nimport openai\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    def handler(audio_file):\n        client = openai.OpenAI()\n        response = client.audio.transcriptions.create(\n            model=\"gpt-4o-transcribe\",\n            file=open(audio_file, \"rb\"),\n        )\n        return response.text\n    \n    transcribe_audio = streamlit_openai.CustomFunction(\n        name=\"transcribe_audio\",\n        description=\"Convert speech to text.\",\n        parameters={\n            \"type\": \"object\",\n            \"properties\": {\n                \"audio_file\": {\n                    \"type\": \"string\",\n                    \"description\": \"The audio file to transcribe.\",\n                }\n            },\n            \"required\": [\"audio_file\"]\n        },\n        handler=handler\n    )\n\n    st.session_state.chat = streamlit_openai.Chat(\n        functions=[transcribe_audio],\n    )\n    \nst.session_state.chat.run()\n```\n\n## Reasoning\n\nThe `Chat` class supports OpenAI's reasoning capabilities, allowing the\nassistant to perform complex reasoning tasks. To enable reasoning, select a \nreasoning model when initializing the `Chat` class (e.g., `model=\"o3\"`). \nDepending on the selected model, you may need to disable some features that \nare not compatible with reasoning. For example, web search is not supported \nwith reasoning models, so you should set `allow_web_search=False` when \ninitializing the `Chat` class.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        model=\"o3\",             # Select a reasoning model\n        allow_web_search=False, # Disable web search\n    )\n\nst.session_state.chat.run()\n```\n\n## Remote MCP\n\nThe `Chat` class supports OpenAI's remote MCP (Model Context Protocol) for \nperforming various tasks. To create a remote MCP, provide the required \nparameters -- `server_label` and `server_url` -- when initializing a \n`RemoteMCP`. Depending on your use case, you may also need to specify \nadditional parameters such as `require_approval`, `headers`, and \n`allowed_tools`.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    deepwiki = streamlit_openai.RemoteMCP(\n        server_label=\"deepwiki\",\n        server_url=\"https://mcp.deepwiki.com/mcp\",\n    )\n\n    st.session_state.chat = streamlit_openai.Chat(\n        mcps=[deepwiki]\n    )\n\nst.session_state.chat.run()\n```\n\n## File Inputs\n\nYou can provide file inputs to the chat interface, allowing the assistant\nto access and utilize the content of the files during the conversation.\n\n### Message Attachments\n\nYou can upload files in the chat by clicking the attachment icon or dragging \nthem into the input box. Uploaded files are sent along with your message, and \nthe assistant can access their content. This behavior is controlled by the \n`accept_file` parameter when initializing the `Chat` class. Below is an \nexample of how to enable file uploads in the chat interface:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        accept_file=\"multiple\" # Allow multiple file uploads (default)\n        # accept_file=True,    # Allow only one file upload\n        # accept_file=False,   # Disable file uploads entirely\n    )\n\nst.session_state.chat.run()\n```\n\n### Static File Upload\n\nYou can upload files statically by providing the `uploaded_files` parameter\nwhen initializing the `Chat` class. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        uploaded_files=[\"example.pdf\"]\n    )\n\nst.session_state.chat.run()\n```\n\n### File Uploader Widget\n\nYou can use `st.file_uploader` to allow users to upload files dynamically. \nNote that while the widget supports file removal, the files will still remain \nin the chat context. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat()\n    \nuploaded_files = st.sidebar.file_uploader(\"Upload Files\", accept_multiple_files=True)\n\nst.session_state.chat.run(uploaded_files=uploaded_files)\n```\n\n## Vision\n\nThe `Chat` class supports OpenAI’s vision capabilities, allowing image input \nto be processed within a chat.\n\nCurrently, the following image formats are supported: `.png`, `.jpeg`, `.jpg`, \n`.webp`, and `.gif`.\n\nHere’s an example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        uploaded_files=[\"example.jpeg\"]\n    )\n\nst.session_state.chat.run()\n```\n\n## Image Generation\n\nThe `Chat` class supports OpenAI's image generation capabilities, allowing the\nassistant to generate images based on user prompts. By default, this feature is\nenabled, but you can disable it by setting `allow_image_generation=False` when\ninitializing the `Chat` class. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        allow_image_generation=True,    # Enable image generation (default)\n        # allow_image_generation=False, # Disable it\n    )\n\nst.session_state.chat.run()\n```\n\n## File Search\n\nThe `Chat` class supports file search capabilities, enabling the assistant to \nsearch through uploaded files and retrieve relevant information during a \nconversation. To disable it, set `allow_file_search=False` when initializing \n`Chat`.\n\nThe following file formats are currently supported: `.c`, `.cpp`, `.cs`, \n`.css`, `.doc`, `.docx`, `.go`, `.html`, `.java`, `.js`, `.json`, `.md`, \n`.pdf`, `.php`, `.pptx`, `.py`, `.rb`, `.sh`, `.tex`, `.ts`, and `.txt`.\n\nIt's notewordthy that the file search feature doesn't support image \nprocessing, except for PDFs, which can be processed using OpenAI's vision. \nSee [PDF Vision Support](#pdf-vision-support) for more details.\n\nWhen the user uploads one or more files, a new vector store is created, and \nthe files are indexed for search. If additional files are uploaded later, the \nexisting vector store is updated with the new files.\n\nNote that OpenAI's file search currently supports a maximum of two vector \nstores in use simultaneously. See \n[Vector Store Retrieval](#vector-store-retrieval) for more details.\n\nBelow is an example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        allow_file_search=True,   # Enable file search (default)\n        # allow_file_search=False # Disable it\n        uploaded_files=[\"example.docx\"]\n    )\n\nst.session_state.chat.run()\n```\n\n### PDF Vision Support\n\nFile search retrieves information from a knowledge base using semantic and \nkeyword search. However, it does not support processing images within files \n-- except in the case of PDFs. PDF files can be processed using OpenAI's \nvision capabilities, allowing the assistant to extract both text and images \nfrom each page. Notably, PDFs processed this way do not trigger the creation \nof a vector store, as they are handled through the vision model instead.\n\nThere is a limitation, however: you can upload up to 100 pages and a total of \n32MB of content in a single PDF upload. If the uploaded PDF exceeds this \nlimit, the assistant will fall back to standard file search, which indexes \nonly the text content of the PDF.\n\n### Vector Store Retrieval\n\nIf you already have existing vector stores created using the OpenAI API, you \ncan use them in the chat interface. This is particularly useful for retrieving \nrelevant information from previously indexed files without needing to \nre-upload them -- especially if the files are large or numerous.\n\nTo use existing vector stores in a chat, provide their IDs when initializing \nthe `Chat` class. This enables the system to search and retrieve relevant \ninformation from those stores.\n\nNote that OpenAI's file search currently supports a maximum of two vector \nstores at a time, meaning you can provide up to two vector store IDs. However, \nif you specify two vector store IDs, you won’t be able to upload new files. \nThis is by design -- existing vector stores are not updated because they are \npresumably important and shared across applications, and modifying them could \nlead to unintended issues.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        vector_store_ids=[\"vs_...\", \"vs_...\"]\n    )\nst.session_state.chat.run()\n```\n\n## Web Search\n\nBy default, the `Chat` class supports OpenAI's web search capability,\nallowing the assistant to retrieve up-to-date information from the web.\nTo disable this feature, set `allow_web_search=False` when initializing\nthe `Chat` class. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        allow_web_search=True    # Enable web search (default)\n        # allow_web_search=False # Disable it\n    )\n\nst.session_state.chat.run()\n```\n\n## Code Interpreter\n\nBy default, the `Chat` class runs Python code in a sandboxed environment using \nOpenAI's code interpreter. It can read, write, and analyze files in formats \nlike text, CSV, and images. To disable this, set \n`allow_code_interpreter=False` when initializing `Chat`.\n\nThe following file formats are currently supported: `.c`, `.cs`, `.cpp`, \n`.csv`, `.doc`, `.docx`, `.html`, `.java`, `.json`, `.md`, `.pdf`, `.php`, \n`.pptx`, `.py`, `.rb`, `.tex`, `.txt`, `.css`, `.js`, `.sh`, `.ts`, `.csv`, \n`.jpeg`, `.jpg`, `.gif`, `.pkl`, `.png`, `.tar`, `.xlsx`, `.xml`, and `.zip`.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        allow_code_interpreter=True    # Enable code interpreter (default)\n        # allow_code_interpreter=False # Disable it\n    )\n\nst.session_state.chat.run()\n```\n\n## Chat History\n\nYou can save chat history to let users resume conversations across sessions. \nUse the `Chat` class’s `save` method to save history as a ZIP file. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat()\n    \nwith st.sidebar:\n    if st.button(\"Save\"):\n        st.session_state.chat.save(\"history.zip\")\n\nst.session_state.chat.run()\n```\n\nAfter saving the chat history, you can load it in a new session by passing\nthe file path to the `Chat.load` method:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat.load(\"history.zip\")\n\nst.session_state.chat.run()\n```\n\n## Chat Summary\n\nThe `Chat` class automatically generates a summary of the chat history, \naccessible via the `Chat.summary` property. This summary is created using \nOpenAI's Chat Completions API and provides a concise overview of the \nconversation. Note that when a new chat is started, the default summary is \n`\"New Chat\"`. When there is enough context in the chat history, the summary \nwill be automatically generated. Once the summary is generated, it will not \nchange.\n\n## Token Usage\n\nThe `Chat` class offers the `Chat.input_tokens` and `Chat.output_tokens` \nproperties to monitor token usage during a chat session. These properties \nreturn the number of input and output tokens used, respectively. This feature \nis particularly useful for tracking token consumption and managing costs when \nutilizing OpenAI's API.\n\n## Storage Management\n\nYou can delete all vector stores, files, and containers associated with the \nexported API key using the command-line interface:\n\n```sh\n$ streamlit-openai -h\nusage: streamlit-openai [-h] [-v] [--keep ID [ID ...]] {delete-all,delete-files,delete-vector-stores,delete-containers}\n\nCLI tool to delete OpenAI files, vector stores, and containers.\n\npositional arguments:\n  {delete-all,delete-files,delete-vector-stores,delete-containers}\n                        command to execute\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --version         show the version of the tool\n  --keep ID [ID ...]    list of IDs to keep (e.g., file-123, vs_456, cntr_789)\n```\n\n# Customization\n\n## Model Selection\n\nThe default model used by the assistant in the chat interface is `gpt-4o`. You\ncan customize the model used by the assistant by providing the `model` \nparameter. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(model=\"o3-mini\")\n\nst.session_state.chat.run()\n```\n\n## Temperature\n\nYou can customize the temperature used by the assistant in the chat interface\nby providing the `temperature` parameter. The temperature controls the \nrandomness of the assistantant's responses. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(temperature=0.5)\n\nst.session_state.chat.run()\n```\n\n## Instructions\n\nYou can customize the instructions provided to the assistant in the chat\ninterface by providing the `instructions` parameter. The instructions provide \ncontext for the assistant and can help guide its responses. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        instructions=\"You are a helpful assistant.\"\n    )\n\nst.session_state.chat.run()\n```\n\n## Avatar Image\n\nYou can customize the avatar images for the assistant and user in the chat \ninterface by providing the `assistant_avatar` and `user_avatar` parameters. \nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(assistant_avatar=\"🦖\")\n\nst.session_state.chat.run()\n```\n\n## Welcome Message\n\nYou can customize the welcome message displayed in the chat interface by\nproviding the `welcome_message` parameter.\n\nNote that if a chat history is provided, the welcom message will not be \ndisplayed, as the chat history takes precedence.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        welcome_message=\"Hello! How can I assist you today?\"\n    )\n\nst.session_state.chat.run()\n```\n\n## Example Messages\n\nYou can use the `example_messages` parameter to provide example messages in \nthe chat interface, helping users understand how to interact with the \nassistant.\n\nNote that if a chat history is provided, the example messages will not be \ndisplayed, as the chat history takes precedence.\n\nExample:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        example_messages=[\n            \"Can you tell me a joke?\",\n            \"What is the capital of France?\",\n            \"How do you make a paper airplane?\",\n            \"What is the weather like today?\",\n        ],\n    )\n\nst.session_state.chat.run()\n```\n\n## Info Message\n\nThe `info_message` parameter displays a persistent message at the top of the \nchat, guiding users on how to interact with the assistant. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        info_message=\"Don't share sensitive info. AI may be inaccurate.\"\n    )\n\nst.session_state.chat.run()\n```\n\n## Input Box Placeholder\n\nYou can set custom placeholder text for the chat input box using the \n`placeholder` parameter when initializing the `Chat` class. Example:\n\n```python\nimport streamlit as st\nimport streamlit_openai\n\nif \"chat\" not in st.session_state:\n    st.session_state.chat = streamlit_openai.Chat(\n        placeholder=\"Type your message here...\"\n    )\n\nst.session_state.chat.run()\n```\n\n# Chat Completions and Assistants APIs\n\nBefore the 0.1.0 release, the `streamlit-openai` package supported the OpenAI \nChat Completions and Assistants APIs. However, the Responses API is now \nOpenAI's most advanced interface for generating model outputs, and the \nAssistants API is scheduled for deprecation in early 2026. While the Chat \nCompletions API will remain available, OpenAI recommends using the Responses \nAPI for all new applications, as it offers a more powerful and flexible way \nto interact with their models. Starting with the 0.1.0 release, the package \nhas been updated to use the Responses API exclusively.\n\n# Changelog\n\nFor a detailed list of changes, please refer to the [CHANGELOG](CHANGELOG.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbslee%2Fstreamlit-openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbslee%2Fstreamlit-openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbslee%2Fstreamlit-openai/lists"}