liveBook · Manning

Message

As explained in Build Python Web Apps with Streamlit

A user message contains the instruction or request submitted on behalf of the person interacting with a language model.

A message is one unit of conversation between a person and a language model. In an API prompt, messages are dictionaries with role and content: the user message contains the instruction the model should answer, while system messages provide behavior or context. section 9.2.3

A focused user request

A system message can establish the assistant’s behavior, while the user message asks, “Explain what Streamlit is in 10 words or fewer.” The message list is then passed to the chat completions endpoint. section 9.2.3

Messages also form conversation history. A backend can return its messages list, and a Streamlit frontend can display each message with its type and content, allowing users to follow the complete exchange rather than only the latest reply. section 10.3.2

>>> messages = [
...     {'role': 'system', 'content': 'You are a helpful programming assistant'},
...     {'role': 'user', 'content': 'Explain what Streamlit is in 10 words or fewer'}
... ]

Inspect the message-list structure used to send system context and a user instruction together. section 9.2.3

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines role and content, demonstrates API assembly, and shows state retrieval and rendering without detailing message serialization internals.
Examples
Uses a Streamlit explanation request, an OpenAI message list, and a Streamlit loop that renders stored conversation messages.
What it assumes
Assumes basic Python use and an API key, while introducing prompts, message roles, conversation state, and chat-message rendering.
What you can do after
Apply it via the OpenAI Python library and Streamlit to send user requests and display complete chat history.
How it connects
Connects messages to prompts, system instructions, chat completions, conversation history, Streamlit, and LangGraph.

Also explained in

Compare how 7 books explain message →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.