A natural language interface gives users a conversational way to call an LLM service through a web app, phone app, CLI, SDK, or similar client. The simplest version is a chatbox with an input field, send button, and conversation display; streaming, history, and prompt handling make it more useful in practice. section 8.1
Useful interface features include:
- Streaming responses so users see generated output as it arrives. section 8.1
- Chat history that preserves prior turns for the interaction and supports prompt construction. section 8.1
- Stop, Retry, and Undo controls that improve conversational usability. section 8.1.3
- A framework such as Gradio that supplies customizable web UI components without requiring HTML, CSS, or JavaScript. section 8.1.3
A minimal Gradio chatbot
Define a generate(message, history) function, transform the conversation into the prompt expected by a local API, yield streamed output, and pass the function to gr.ChatInterface(...).queue().launch(). section 8.1.3
Listing 8.3 Local LLM Gradio chat app with Stop, Retry, and Undo
import gradio as gr
import requests
import json
url = "http://localhost:8000/generate" #1
def generate(message, history):
history_transformer_format = history + [[message, ""]]
messages = "".join(
[
"".join(["\n<human>:" + h, "\n<bot>:" + b])
for h, b in history_transformer_format
]
)
data = json.dumps({"prompt": messages})
full_response = ""
with requests.post(url, data=data, stream=True) as r: #2
for line in r.iter_lines(decode_unicode=True):
full_response += line.decode("utf-8")
yield full_response + "▌" #3
yield full_response
gr.ChatInterface(generate, theme="soft").queue().launch()
Inspect the complete Gradio example, including history transformation, streamed requests, and the resulting Stop, Retry, and Undo controls. section 8.1.3





