TUIChat Interface

Chat

Full-featured terminal chat interface for AI agents

Quick Start

main.py
from connectonion import Agent from connectonion.tui import Chat agent = Agent("assistant", tools=[search, analyze]) chat = Chat(agent=agent) chat.run()
output
๐Ÿค– Assistant โ— Ready co/gpt-4 0 tok $0.0000
ย 
Welcome! How can I help?
ย 
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Type a message... (/ for commands) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
/ commands โ€ข Enter send โ€ข Ctrl+D quit

Installation

code
pip install connectonion[tui] # or pip install textual textual-autocomplete

Parameters

ParameterTypeDescription
agentAgentConnectOnion agent instance
handlerCallableCustom message handler (alternative to agent)
titlestrWindow title
welcomestrWelcome message (markdown supported)
hintslist[str]Footer hints
triggersdictAutocomplete triggers (/, @)
on_errorCallableCustom error handler

Thinking Indicator

Shows real-time progress during LLM calls and tool execution:

During LLM thinking:
โ น Thinking... 5s (usually 3-10s)
During tool execution:
โ น Search emails in inbox
  โ””โ”€ search_emails("aaron")

Shows description (what's happening) and function call (technical detail).

Autocomplete Triggers

main.py
from connectonion.tui import Chat, CommandItem from textual_autocomplete import DropdownItem chat = Chat( agent=agent, triggers={ "/": [ CommandItem(main="/help", prefix="?", id="/help"), CommandItem(main="/clear", prefix="โŒซ", id="/clear"), CommandItem(main="/quit", prefix="โ†’", id="/quit"), ], "@": [ DropdownItem(main="John", id="@john@example.com"), DropdownItem(main="Jane", id="@jane@example.com"), ], } )

Status Bar

Shows real-time information in a three-column layout:

๐Ÿค– Assistant    โ— Thinking (1/10)    co/gpt-4  1,234 tok  $0.0012
  • Left: Agent name
  • Center: Current status with iteration
  • Right: Model, token count, cost

Customizing

Copy and modify the Chat component:

code
# Copy to ./tui/chat.py co copy chat # Then customize from tui.chat import Chat, ThinkingIndicator class MyThinkingIndicator(ThinkingIndicator): frames = ["โ—", "โ—“", "โ—‘", "โ—’"] # Custom spinner

Example: Gmail Agent

main.py
from connectonion import Agent from connectonion.tui import Chat, CommandItem from connectonion.useful_tools import Gmail gmail = Gmail() agent = Agent("gmail-agent", tools=[gmail]) chat = Chat( agent=agent, title="Gmail Agent", welcome="**Gmail Assistant**\n\nI can search, read, and send emails.", hints=["/ commands", "@ mentions", "Enter send"], triggers={ "/": [ CommandItem(main="/inbox", prefix="๐Ÿ“ฅ", id="/inbox"), CommandItem(main="/sent", prefix="๐Ÿ“ค", id="/sent"), CommandItem(main="/compose", prefix="โœ๏ธ", id="/compose"), ] } ) chat.run()

Included Widgets

WidgetPurpose
ChatStatusBarTop status bar
HintsFooterBottom hints
WelcomeMessageInitial welcome
UserMessageUser message bubble
AssistantMessageAgent response
ThinkingIndicatorProcessing animation
TriggerAutoCompleteTrigger-based autocomplete
main.py
from connectonion.tui import ( Chat, ChatStatusBar, ThinkingIndicator, TriggerAutoComplete, )

Star us on GitHub

If ConnectOnion saves you time, a โญ goes a long way โ€” and earns you a coffee chat with our founder.