This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_formatting.py
715 lines (617 loc) · 29.3 KB
/
text_formatting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
################################################################################
# commbase-stt-vosk-p #
# #
# An ASR (Automatic Speech Recognition) engine. #
# #
# Change History #
# 04/29/2023 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2022-present Esteban Herrera C. #
# stv.herrera@gmail.com #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# text_formatting.py
# This file provides utility functions for working with terminal formatting. It
# includes functions to modify the text color, background color, and text
# formatting in the terminal output. These functions can be used to enhance the
# visual appearance and readability of command-line interfaces.
# Requires os.path already imported
# Requires to import load_config_file from functions in case CONFIG_FILE_PATH is
# not used
# Requirements
from config import CONFIG_FILE_PATH
def get_terminal_colors():
"""
Gets the terminal colors from the config file.
Reads the environment variables from the environment configuration file.
Returns a tuple containing the string values of the variables if found, or
None if any of the variables are not present.
Returns:
tuple or None: A tuple containing the terminal colors, or None, if any
of the variables are not found.
"""
# Initialize variables for the background colors
red_background_color_code_start = None
green_background_color_code_start = None
yellow_background_color_code_start = None
blue_background_color_code_start = None
magenta_background_color_code_start = None
cyan_background_color_code_start = None
white_background_color_code_start = None
black_background_color_code_start = None
# Initialize variables for the text colors
red_text_color_code_start = None
green_text_color_code_start = None
yellow_text_color_code_start = None
blue_text_color_code_start = None
magenta_text_color_code_start = None
cyan_text_color_code_start = None
white_text_color_code_start = None
black_text_color_code_start = None
# Initialize the variable for the end of the color
color_code_end = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the file
if variable_name == "TERMINAL_RED_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
red_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_GREEN_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
green_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_YELLOW_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
yellow_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_BLUE_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
blue_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_MAGENTA_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
magenta_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_CYAN_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
cyan_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_WHITE_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
white_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_BLACK_BACKGROUND_COLOR_CODE_START":
# Remove the quotes from the value of the variable
black_background_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_RED_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
red_text_color_code_start = value.strip()[1:-1]
# Check if the variable we are looking for exists in the line
elif variable_name == "TERMINAL_GREEN_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
green_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_YELLOW_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
yellow_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_BLUE_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
blue_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_MAGENTA_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
magenta_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_CYAN_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
cyan_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_WHITE_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
white_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_BLACK_TEXT_COLOR_CODE_START":
# Remove the quotes from the value of the variable
black_text_color_code_start = value.strip()[1:-1]
elif variable_name == "TERMINAL_COLOR_CODE_END":
# Remove the quotes from the value of the variable
color_code_end = value.strip()[1:-1]
# Check if all the variables were found
if (
red_background_color_code_start is not None
and green_background_color_code_start is not None
and yellow_background_color_code_start is not None
and blue_background_color_code_start is not None
and magenta_background_color_code_start is not None
and cyan_background_color_code_start is not None
and white_background_color_code_start is not None
and black_background_color_code_start is not None
and red_text_color_code_start is not None
and green_text_color_code_start is not None
and yellow_text_color_code_start is not None
and blue_text_color_code_start is not None
and magenta_text_color_code_start is not None
and cyan_text_color_code_start is not None
and white_text_color_code_start is not None
and black_text_color_code_start is not None
and color_code_end is not None
):
return (
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
)
# If any of the variables are not found, return None
return None
def get_chat_participant_colors():
"""
Gets the chat participant background and text colors from the config file.
Reads the assistant, system, and end user variables from the environment
configuration file. Returns a tuple containing the string values of the
variables if found, or None if any of the variables are not present.
Returns:
tuple or None: A tuple containing the assistant, system, and end user
background and text colors in the chat pane, or None, if any of the
variables are not found.
"""
# Initialize variables for the colors of the chat participants
end_user_background_color = None
assistant_background_color = None
system_background_color = None
end_user_text_color = None
assistant_text_color = None
system_text_color = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "END_USER_BACKGROUND_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
end_user_background_color = value.strip()[1:-1]
elif variable_name == "ASSISTANT_BACKGROUND_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
assistant_background_color = value.strip()[1:-1]
elif variable_name == "SYSTEM_BACKGROUND_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
system_background_color = value.strip()[1:-1]
elif variable_name == "END_USER_TEXT_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
end_user_text_color = value.strip()[1:-1]
elif variable_name == "ASSISTANT_TEXT_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
assistant_text_color = value.strip()[1:-1]
elif variable_name == "SYSTEM_TEXT_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
system_text_color = value.strip()[1:-1]
# Check if all six variables were found
if (
end_user_background_color is not None
and assistant_background_color is not None
and system_background_color is not None
and end_user_text_color is not None
and assistant_text_color is not None
and system_text_color is not None
):
return (
end_user_background_color,
assistant_background_color,
system_background_color,
end_user_text_color,
assistant_text_color,
system_text_color,
)
# If any of the variables are not found, return None
return None
def get_assistant_avatar_color():
"""
Gets the assistant avatar color from the config file.
Reads the 'ASSISTANT_AVATAR_COLOR_IN_CHAT_PANE' variable from the
environment configuration file. Returns the string value of the variable if
found, or None if the variable is not present.
Returns:
srt or None: A string containing the assitant avatar color in the chat
pane, or None, if the variable is not found.
"""
# Initialize variable for the avatar color
avatar_color = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "ASSISTANT_AVATAR_COLOR_IN_CHAT_PANE":
# Remove the quotes from the value of the variable
avatar_color = value.strip()[1:-1]
# Check if the variable was found
if avatar_color is not None:
return avatar_color
# If the variable was not found, return None
return None
def set_end_user_background_color(end_user_background_color):
"""
Sets the background color for the END USER.
Parameters:
end_user_background_color (str): The desired background color for the
END USER.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected background color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the END USER user background color
if end_user_background_color == "red":
end_user_background_color_start = red_background_color_code_start
elif end_user_background_color == "green":
end_user_background_color_start = green_background_color_code_start
elif end_user_background_color == "yellow":
end_user_background_color_start = yellow_background_color_code_start
elif end_user_background_color == "blue":
end_user_background_color_start = blue_background_color_code_start
elif end_user_background_color == "magenta":
end_user_background_color_start = magenta_background_color_code_start
elif end_user_background_color == "cyan":
end_user_background_color_start = cyan_background_color_code_start
elif end_user_background_color == "white":
end_user_background_color_start = white_background_color_code_start
elif end_user_background_color == "black":
end_user_background_color_start = black_background_color_code_start
return end_user_background_color_start
def set_assistant_user_background_color(assistant_background_color):
"""
Sets the background color for the ASSISTANT user.
Parameters:
assistant_background_color (str): The desired background color for the
ASSISTANT user.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected background color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the ASSISTANT user background color
if assistant_background_color == "red":
assistant_background_color_start = red_background_color_code_start
elif assistant_background_color == "green":
assistant_background_color_start = green_background_color_code_start
elif assistant_background_color == "yellow":
assistant_background_color_start = yellow_background_color_code_start
elif assistant_background_color == "blue":
assistant_background_color_start = blue_background_color_code_start
elif assistant_background_color == "magenta":
assistant_background_color_start = magenta_background_color_code_start
elif assistant_background_color == "cyan":
assistant_background_color_start = cyan_background_color_code_start
elif assistant_background_color == "white":
assistant_background_color_start = white_background_color_code_start
elif assistant_background_color == "black":
assistant_background_color_start = black_background_color_code_start
return assistant_background_color_start
def set_system_user_background_color(system_background_color):
"""
Sets the background color for the SYSTEM user.
Parameters:
system_background_color (str): The desired background color for the
SYSTEM user.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected background color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the SYSTEM user background color
if system_background_color == "red":
system_background_color_start = red_background_color_code_start
elif system_background_color == "green":
system_background_color_start = green_background_color_code_start
elif system_background_color == "yellow":
system_background_color_start = yellow_background_color_code_start
elif system_background_color == "blue":
system_background_color_start = blue_background_color_code_start
elif system_background_color == "magenta":
system_background_color_start = magenta_background_color_code_start
elif system_background_color == "cyan":
system_background_color_start = cyan_background_color_code_start
elif system_background_color == "white":
system_background_color_start = white_background_color_code_start
elif system_background_color == "black":
system_background_color_start = black_background_color_code_start
return system_background_color_start
def set_end_user_text_color(end_user_text_color):
"""
Sets the text color for the END USER user.
Parameters:
end_user_text_color (str): The desired text color for the END USER user.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected text color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the END USER user text color
if end_user_text_color == "red":
end_user_text_color_start = red_text_color_code_start
elif end_user_text_color == "green":
end_user_text_color_start = green_text_color_code_start
elif end_user_text_color == "yellow":
end_user_text_color_start = yellow_text_color_code_start
elif end_user_text_color == "blue":
end_user_text_color_start = blue_text_color_code_start
elif end_user_text_color == "magenta":
end_user_text_color_start = magenta_text_color_code_start
elif end_user_text_color == "cyan":
end_user_text_color_start = cyan_text_color_code_start
elif end_user_text_color == "white":
end_user_text_color_start = white_text_color_code_start
elif end_user_text_color == "black":
end_user_text_color_start = black_text_color_code_start
return end_user_text_color_start
def set_assistant_user_text_color(assistant_text_color):
"""
Sets the text color for the ASSISTANT user.
Parameters:
assistant_text_color (str): The desired text color for the ASSISTANT
user.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected text color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the ASSISTANT user text color
if assistant_text_color == "red":
assistant_text_color_start = red_text_color_code_start
elif assistant_text_color == "green":
assistant_text_color_start = green_text_color_code_start
elif assistant_text_color == "yellow":
assistant_text_color_start = yellow_text_color_code_start
elif assistant_text_color == "blue":
assistant_text_color_start = blue_text_color_code_start
elif assistant_text_color == "magenta":
assistant_text_color_start = magenta_text_color_code_start
elif assistant_text_color == "cyan":
assistant_text_color_start = cyan_text_color_code_start
elif assistant_text_color == "white":
assistant_text_color_start = white_text_color_code_start
elif assistant_text_color == "black":
assistant_text_color_start = black_text_color_code_start
return assistant_text_color_start
def set_system_user_text_color(system_text_color):
"""
Sets the text color for the SYSTEM user.
Parameters:
system_text_color (str): The desired text color for the SYSTEM user.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected text color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the SYSTEM user text color
if system_text_color == "red":
system_text_color_start = red_text_color_code_start
elif system_text_color == "green":
system_text_color_start = green_text_color_code_start
elif system_text_color == "yellow":
system_text_color_start = yellow_text_color_code_start
elif system_text_color == "blue":
system_text_color_start = blue_text_color_code_start
elif system_text_color == "magenta":
system_text_color_start = magenta_text_color_code_start
elif system_text_color == "cyan":
system_text_color_start = cyan_text_color_code_start
elif system_text_color == "white":
system_text_color_start = white_text_color_code_start
elif system_text_color == "black":
system_text_color_start = black_text_color_code_start
return system_text_color_start
def set_assistant_avatar_color(avatar_color):
"""
Sets the avatar color for the assistant.
Parameters:
avatar_color (str): The desired color for the assistant's avatar.
Valid options are: 'red', 'green', 'yellow', 'blue', 'magenta',
'cyan', 'white', 'black'.
Returns:
str: The start code for the selected avatar color.
Notes:
This function internally uses the get_terminal_colors() function to
obtain the necessary color codes.
"""
# Assign the values returned by get_terminal_colors()
(
red_background_color_code_start,
green_background_color_code_start,
yellow_background_color_code_start,
blue_background_color_code_start,
magenta_background_color_code_start,
cyan_background_color_code_start,
white_background_color_code_start,
black_background_color_code_start,
red_text_color_code_start,
green_text_color_code_start,
yellow_text_color_code_start,
blue_text_color_code_start,
magenta_text_color_code_start,
cyan_text_color_code_start,
white_text_color_code_start,
black_text_color_code_start,
color_code_end,
) = get_terminal_colors()
# Set the assistant avatar color
if avatar_color == "red":
avatar_color_start = red_text_color_code_start
elif avatar_color == "green":
avatar_color_start = green_text_color_code_start
elif avatar_color == "yellow":
avatar_color_start = yellow_text_color_code_start
elif avatar_color == "blue":
avatar_color_start = blue_text_color_code_start
elif avatar_color == "magenta":
avatar_color_start = magenta_text_color_code_start
elif avatar_color == "cyan":
avatar_color_start = cyan_text_color_code_start
elif avatar_color == "white":
avatar_color_start = white_text_color_code_start
elif avatar_color == "black":
avatar_color_start = black_text_color_code_start
return avatar_color_start