ConnectOnionConnectOnion

Chat

Full-featured terminal chat interface for AI agents

Quick Start

main.py
1from connectonion import Agent 2from connectonion.tui import Chat 3 4agent = Agent("assistant", tools=[search, analyze]) 5 6chat = Chat(agent=agent) 7chat.run()
Python REPL
Interactive
๐Ÿค– 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
1pip install connectonion[tui] 2# or 3pip 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
1from connectonion.tui import Chat, CommandItem 2from textual_autocomplete import DropdownItem 3 4chat = Chat( 5 agent=agent, 6 triggers={ 7 "/": [ 8 CommandItem(main="/help", prefix="?", id="/help"), 9 CommandItem(main="/clear", prefix="โŒซ", id="/clear"), 10 CommandItem(main="/quit", prefix="โ†’", id="/quit"), 11 ], 12 "@": [ 13 DropdownItem(main="John", id="@john@example.com"), 14 DropdownItem(main="Jane", id="@jane@example.com"), 15 ], 16 } 17)

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
1# Copy to ./tui/chat.py 2co copy chat 3 4# Then customize 5from tui.chat import Chat, ThinkingIndicator 6 7class MyThinkingIndicator(ThinkingIndicator): 8 frames = ["โ—", "โ—“", "โ—‘", "โ—’"] # Custom spinner

Example: Gmail Agent

main.py
1from connectonion import Agent 2from connectonion.tui import Chat, CommandItem 3from connectonion.useful_tools import Gmail 4 5gmail = Gmail() 6agent = Agent("gmail-agent", tools=[gmail]) 7 8chat = Chat( 9 agent=agent, 10 title="Gmail Agent", 11 welcome="**Gmail Assistant**\n\nI can search, read, and send emails.", 12 hints=["/ commands", "@ mentions", "Enter send"], 13 triggers={ 14 "/": [ 15 CommandItem(main="/inbox", prefix="๐Ÿ“ฅ", id="/inbox"), 16 CommandItem(main="/sent", prefix="๐Ÿ“ค", id="/sent"), 17 CommandItem(main="/compose", prefix="โœ๏ธ", id="/compose"), 18 ] 19 } 20) 21 22chat.run()

Included Widgets

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