API Reference - Local terminal output#
src
#
intentional_terminal
#
Init file for intentional_terminal
.
__about__
#
Package descriptors for intentional-terminal.
bot_interface
#
Local bot interface for Intentional.
TerminalBotInterface
#
Bases: BotInterface
Bot that uses the local command line interface to interact with the user.
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
check_for_transcripts(event)
async
#
Checks for transcripts from the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the transcript. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
122 123 124 125 126 127 128 129 130 |
|
handle_audio_messages(event)
async
#
Plays audio responses from the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the audio message. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
165 166 167 168 169 170 171 172 |
|
handle_conversation_ended(_)
async
#
The conversation is over, so let's ask the user if they want to have another go.
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
201 202 203 204 205 206 207 208 209 210 |
|
handle_finish_text_response(_)
async
#
Prints to the console when the bot starts generating a text response.
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
138 139 140 141 142 143 |
|
handle_llm_connection(event)
async
#
Prints to the console when the bot connects to the LLM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the LLM connection event. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
145 146 147 148 149 150 151 152 153 |
|
handle_start_text_response(_)
async
#
Prints to the console when the bot starts generating a text response.
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
132 133 134 135 136 |
|
handle_text_messages(event)
async
#
Prints to the console any text message from the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the message. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
155 156 157 158 159 160 161 162 163 |
|
run()
async
#
Chooses the specific loop to use for this combination of bot and modality and kicks it off.
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
speech_started(event)
async
#
Prints to the console when the bot starts speaking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the speech start event. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
speech_stopped(event)
async
#
Prints to the console when the bot stops speaking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the speech stop event. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/bot_interface.py
192 193 194 195 196 197 198 199 |
|
handlers
#
Init file for intentional_terminal
.
audio_handler
#
CLI handler for the bot's audio input and output.
Uses PyAudio for audio input and output, and runs a separate thread for recording and playing audio.
When playing audio, it uses a buffer to store audio data and plays it continuously to ensure smooth playback.
AudioHandler
#
Handles audio input and output for the chatbot.
Uses PyAudio for audio input and output, and runs a separate thread for recording and playing audio.
When playing audio, it uses a buffer to store audio data and plays it continuously to ensure smooth playback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_format
|
int
|
The audio format (paInt16). |
paInt16
|
channels
|
int
|
The number of audio channels (1). |
1
|
rate
|
int
|
The sample rate (24000). |
24000
|
chunk
|
int
|
The size of the audio buffer (1024). |
1024
|
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
cleanup()
#Clean up audio resources.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
play_audio(audio_data)
#Add audio data to the buffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_data
|
bytes
|
The audio data to play. |
required |
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
start_streaming(client_streaming_callback)
async
#Start continuous audio streaming.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
stop_playback_immediately()
#Stop audio playback immediately. Sets the relevant flags and empties the queue.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
stop_streaming()
#Stop audio streaming.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/audio_handler.py
106 107 108 109 110 111 112 113 114 |
|
input_handler
#
Handles keyboard input for the bot's CLI interface.
This module is responsible for capturing keyboard input and translating it into commands for the bot.
InputHandler
#
Handles keyboard input for the chatbot.
This class is responsible for capturing keyboard input and translating it into commands for the chatbot.
Attributes:
Name | Type | Description |
---|---|---|
text_input |
str
|
The current text input from the user. |
text_ready |
Event
|
An event that is set when the user has finished typing. |
command_queue |
Queue
|
A queue that stores commands for the chatbot. |
loop |
AbstractEventLoop
|
The event loop for the input handler. |
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/input_handler.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
__init__()
#Handles keyboard input for the chatbot.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/input_handler.py
33 34 35 36 37 38 39 40 |
|
on_press(key)
#Keyboard event handler.
Source code in plugins/intentional-terminal/src/intentional_terminal/handlers/input_handler.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|