A prompt is the input you send to a large language model to get a response. For a chat request, it is a list of messages. Each message has a role identifying its speaker and content containing its text. A user message asks for something; an optional system message sets context or instructions; assistant messages represent model responses. section 9.2.3 section 9.2.4
>>> messages = [
... {'role': 'system', 'content': 'You are a helpful programming assistant'},
... {'role': 'user', 'content': 'Explain what Streamlit is in 10 words or fewer'}
... ]
This small Python prompt pairs a system instruction with a specific user request. The order lets the model receive its context before the question. section 9.2.3
Send the message list to a text-generation endpoint and read the returned response. In an app, a helper can assemble the list from a user message and an optional system message, keeping prompt construction separate from the API call. section 9.2.3 section 9.2.4
Keep a trivia game fresh
A question-generation prompt can tell the model to act as a quizmaster, request a new category and topic, and include questions already asked. The app fills in those questions and a changing seed before each request. Temperature and top_p are also passed to the model to help vary the results; the prompt states the desired behavior rather than guaranteeing uniqueness. section 9.6.2
For a customer-support chatbot, a base system message can identify the support role and instruct the model to refuse unrelated requests. In a LangGraph workflow, place that system message before the conversation messages sent to the model. This gives each request the same intended context without replacing the user’s question. section 10.4.1 section 10.4.2
sys_msg = SystemMessage(content=state["sys_msg_text"])
messages_to_send = [sys_msg] + state["messages"]
ai_response_message = self.llm.invoke(messages_to_send)
The graph constructs a SystemMessage, puts it first, then invokes the model with the resulting message list. section 10.4.2

















































