API Reference - Local CLI output#
src
#
intentional_local
#
Init file for intentional_local
.
__about__
#
Package descriptors for intentional-local.
bot_interface
#
Local bot interface for Intentional.
LocalBotInterface
#
Bases: BotInterface
Bot that uses the local command line interface to interact with the user.
Source code in plugins/intentional-local/src/intentional_local/bot_interface.py
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 |
|
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-local/src/intentional_local/bot_interface.py
134 135 136 137 138 139 140 141 142 |
|
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-local/src/intentional_local/bot_interface.py
177 178 179 180 181 182 183 184 |
|
handle_finish_text_response(_)
async
#
Prints to the console when the bot starts generating a text response.
Source code in plugins/intentional-local/src/intentional_local/bot_interface.py
150 151 152 153 154 155 |
|
handle_model_connection(event)
async
#
Prints to the console when the bot connects to the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Dict[str, Any]
|
The event dictionary containing the model connection event. |
required |
Source code in plugins/intentional-local/src/intentional_local/bot_interface.py
157 158 159 160 161 162 163 164 165 |
|
handle_start_text_response(_)
async
#
Prints to the console when the bot starts generating a text response.
Source code in plugins/intentional-local/src/intentional_local/bot_interface.py
144 145 146 147 148 |
|
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-local/src/intentional_local/bot_interface.py
167 168 169 170 171 172 173 174 175 |
|
run()
async
#
Chooses the specific loop to use for this combination of bot and modality and kicks it off.
Source code in plugins/intentional-local/src/intentional_local/bot_interface.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
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-local/src/intentional_local/bot_interface.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
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-local/src/intentional_local/bot_interface.py
204 205 206 207 208 209 210 211 |
|
handlers
#
Init file for intentional_local
.
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-local/src/intentional_local/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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
cleanup()
#Clean up audio resources.
Source code in plugins/intentional-local/src/intentional_local/handlers/audio_handler.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
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-local/src/intentional_local/handlers/audio_handler.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
start_recording()
#Start recording audio from microphone and return bytes
Source code in plugins/intentional-local/src/intentional_local/handlers/audio_handler.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
start_streaming(client_streaming_callback)
async
#Start continuous audio streaming.
Source code in plugins/intentional-local/src/intentional_local/handlers/audio_handler.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
stop_playback_immediately()
#Stop audio playback immediately. Sets the relevant flags and empties the queue.
Source code in plugins/intentional-local/src/intentional_local/handlers/audio_handler.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
stop_streaming()
#Stop audio streaming.
Source code in plugins/intentional-local/src/intentional_local/handlers/audio_handler.py
160 161 162 163 164 165 166 167 168 |
|
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-local/src/intentional_local/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-local/src/intentional_local/handlers/input_handler.py
33 34 35 36 37 38 39 40 |
|
on_press(key)
#Keyboard event handler.
Source code in plugins/intentional-local/src/intentional_local/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 |
|