Chatbot Effect¶
Copyright 2023 Ethan Christensen
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class bruhanimate.bruheffect.chatbot_effect.Key(character: str, representation: list[str], value: int, x: int, y: int)[source]¶
Bases:
object
A class representing a key on the keyboard with its position and value.
- class bruhanimate.bruheffect.chatbot_effect.GradientNoise(x: int, y: int, length: int, char_halt: int = 1, color_halt: int = 1, gradient_length: int = 1)[source]¶
Bases:
object
A class representing a noise effect with a color gradient.
- __init__(x: int, y: int, length: int, char_halt: int = 1, color_halt: int = 1, gradient_length: int = 1)[source]¶
Initializes a GradientNoise object with the given parameters.
- Parameters:
x (int) – The x-coordinate of the noise effect on the screen.
y (int) – The y-coordinate of the noise effect on the screen.
length (int) – The length of the noise effect on the screen.
char_halt (int, optional) – The halt of characters changing (frame_number % character_halt == 0). Defaults to 1.
color_halt (int, optional) – The halt of colors changing (frame_number % color_halt == 0). Defaults to 1.
gradient_length (int, optional) – Length of the gradient. Defaults to 1.
- class bruhanimate.bruheffect.chatbot_effect.Loading(animate_part: GradientNoise)[source]¶
Bases:
object
A class to handle the loading animation.
- __init__(animate_part: GradientNoise)[source]¶
- class bruhanimate.bruheffect.chatbot_effect.StringStreamer(x: int, y: int, text: str, start_frame: int, halt: int = 1)[source]¶
Bases:
object
A class to handle the string streamer animation.
- class bruhanimate.bruheffect.chatbot_effect.OllamaApiCaller(model: str, use_message_history: bool = False, message_history_cap: int = 5)[source]¶
Bases:
object
A class to interact with the Ollama API.
- __init__(model: str, use_message_history: bool = False, message_history_cap: int = 5)[source]¶
Initialize the OllamaApiCaller class.
- class bruhanimate.bruheffect.chatbot_effect.OpenAiCaller(client: OpenAI | AzureOpenAI, model: str, use_message_history: bool = False, message_history_cap: int = 5)[source]¶
Bases:
object
Class to interact with the OpenAI API using the openai Python package.
- __init__(client: OpenAI | AzureOpenAI, model: str, use_message_history: bool = False, message_history_cap: int = 5)[source]¶
Initialize the OpenAiCaller class.
- Parameters:
client (openai.OpenAI | openai.AzureOpenAI) – The OpenAI client object.
model (str) – The OpenAI model to be used.
use_message_history (bool, optional) – Whether or not to use message history. Defaults to False.
message_history_cap (int, optional) – Amount of messages from history to use, sliding window. Defaults to 5.
- class bruhanimate.bruheffect.chatbot_effect.ChatbotEffect(screen: Screen, buffer: Buffer, back_buffer: Buffer, background: str = ' ')[source]¶
Bases:
BaseEffect
A class to create a chatbot effect.
- __init__(screen: Screen, buffer: Buffer, back_buffer: Buffer, background: str = ' ')[source]¶
Initialize the ChatbotEffect class.
- set_chatbot_properties(interface: str | None, model: str, user: str | None = None, client: OpenAI | AzureOpenAI | None = None, use_message_history: bool = False, message_history_cap: int = 5)[source]¶
Sets the properties for the chatbot.
- Parameters:
interface (str | None) – The interface type, e.g., “OpenAI” or “Azure OpenAI”.
model (str) – The name of the AI model to use.
user (str | None, optional) – The name of the user. Defaults to None.
client (openai.OpenAI | openai.AzureOpenAI | None, optional) – The client to use. Defaults to None.
use_message_history (bool, optional) – Whether or not to use message history. Defaults to False.
message_history_cap (int, optional) – How many messages from history to use, sliding window. Defaults to 5.
- Raises:
Exception – If the interface is not recognized, an exception will be raised.
- set_second_effect(effect: str)[source]¶
Sets the second effect for the chatbot.
- Parameters:
effect (str) – The effect to use
- set_chatbot_print_halt(halt: int)[source]¶
Sets the chatbot print halt value to control how often it prints messages.
- Parameters:
halt (int) – (frame_number % halt == 0)
- set_gradient_noise_halts(char_halt: int | None = None, color_halt: int | None = None)[source]¶
Sets the gradient noise halts for character and color shifts.
- set_chatbot_user_colors(chatbot_text_color: int | str | None = None, chatbot_background_color: int | str | None = None, chatbot_avatar_color: int | str | None = None, chatbot_avatar_text_color: int | str | None = None, user_text_color: int | str | None = None, user_background_color: int | str | None = None, user_avatar_color: int | str | None = None, user_avatar_text_color: int | str | None = None)[source]¶
Sets the colors for the chatbot and user messages.
- Parameters:
chatbot_text_color (int | str | None, optional) – Color of chatbot output text. Defaults to None.
chatbot_background_color (int | str | None, optional) – Background of chatbot output text. Defaults to None.
chatbot_avatar_color (int | str | None, optional) – Text color of avatar logo. Defaults to None.
chatbot_avatar_text_color (int | str | None, optional) – Background color of avatar logo. Defaults to None.
user_text_color (int | str | None, optional) – Color of user text. Defaults to None.
user_background_color (int | str | None, optional) – Background color of user text. Defaults to None.
user_avatar_color (int | str | None, optional) – Text color of user avatar. Defaults to None.
user_avatar_text_color (int | str | None, optional) – Background color of user avatar. Defaults to None.
- set_avatar_properties(size: int)[source]¶
Set avatar properties for user and chatbot.
- Parameters:
size (int) – Length of the avatars on left side of screen.
- set_chatbot_stats(show: bool = False)[source]¶
Set chatbot stats on the right side of screen.
- Parameters:
show (bool, optional) – Whether or not to show chatbot stats. Defaults to False.
- set_chatbot_blink_halt(halt: int)[source]¶
Set chatbot blink and halt properties.
- Parameters:
halt (int) – (frame_number % halt == 0)
- set_divider_flag(divider: bool, divider_character: str = '-')[source]¶
Set the divider flag and character for screen.
- set_chatbot_cursor_colors(color_one: int | str, color_two: int | str)[source]¶
Set the colors for chatbot cursor.
- set_chatbot_text_gradient(gradient: list[int | str], mul: int)[source]¶
Set the text color for chatbot to use a gradient.