app_utils module

This module has the necesary utils to deal with App Interface and intereactions

app_utils.add_model(model_meta_info: ModelMetaInfo) None[source]

This function adds a model

Parameters:

model_meta_info – The model meta information

app_utils.cancel_model_focus_mode() None[source]

This function cancels the edit mode

app_utils.conversation_on_click(conversation: Conversation) Callable[[], None][source]

This function returns a function that is called when a conversation is clicked

Parameters:

conversation – The conversation object of the clicked conversation

Returns:

The function callback that is called when the conversation is clicked

app_utils.create_model(model_meta_info: ModelMetaInfo) None[source]

This function creates a model

Parameters:

model_meta_info – The model meta information

app_utils.edit_model(model_meta_info: ModelMetaInfo) None[source]

This function edits a model

Parameters:

model_meta_info – The model meta information

app_utils.get_current_conversation() Conversation[source]

This function returns the current conversation

Returns:

The current conversation

app_utils.get_current_group_conversation() GroupConversation | None[source]

This function returns the current group conversation

Returns:

The current group conversation

app_utils.get_current_model_index(models: List[ModelMetaInfo], chosen_model_name: str) int[source]

This function returns the index for the user chosen model

Parameters:
  • models – The list of models

  • chosen_model_name – The current model

Returns:

The current model index

app_utils.get_group_conversations() List[GroupConversation][source]

This function returns the group conversations

Returns:

The list of group conversations

app_utils.get_group_view_mode() Literal['agents_view', 'character_view', 'chat_view'] | None[source]

This function returns the group view mode

app_utils.get_model_in_focus() dict[str, FormatOption][source]

This function returns the model meta information of the model in focus

Returns:

The model meta information of the model in focus

app_utils.get_selected_model(model_meta_infos: List[ModelMetaInfo]) ModelMetaInfo | None[source]

This function returns the selected model

Parameters:

model_meta_infos – The list of model meta information objects

Returns:

The selected model

app_utils.get_session_id() str[source]

This function returns the session id

app_utils.group_chat_on_submit(key: str, group_agent: GroupAgent) None[source]
app_utils.group_conversation_on_click(group_conversation: GroupConversation) None[source]

This function is called when a group conversation is clicked

Parameters:

group_conversation – The group conversation object

app_utils.is_model_locked() bool[source]

This function returns whether the model is locked for edit/create

Returns:

True if the model is locked, False otherwise

app_utils.load_conversations() List[Conversation][source]

This function loads the conversations from the session state If the conversations are not loaded, it initializes the conversations

Returns:

The list of conversations

app_utils.load_group_agents(config_file: str, base_path: str) Dict[str, GroupAgent][source]

This function loads the group agents from the config file If the group agents are already loaded, it returns the group agents from the session state

Parameters:
  • config_file – The path to the config file

  • base_path – The base path of the app

Returns:

A dictionary of group agents with key as the group agent identifier and value as the group agent object

app_utils.load_models(config_file: str, base_path: str) Dict[str, ModelMetaInfo][source]

This function loads the models from the config file If the models are already loaded, it returns the models from the session state

Parameters:
  • config_file – The path to the config file

  • base_path – The base path of the app

Returns:

A dictionary of models with key as the model identifier and value as the model meta info object

app_utils.model_exists(models: list[ModelMetaInfo], name: str, ignore: ModelMetaInfo | None = None) bool[source]

This function checks if the model exists with the given name

Parameters:
  • models – The list of models

  • name – The name of the model

  • ignore – The model to ignore (used in edit mode)

Returns:

True if the model exists, False otherwise

app_utils.on_base_model_change(key: str, model_meta_infos: List[ModelMetaInfo])[source]

This function is called when the base model is changed

Parameters:
  • key – The key of the selectbox

  • model_meta_infos – The list of model meta information

app_utils.on_click_group_chat_in_focus(mode: Literal['agents_view', 'character_view', 'chat_view'], group_agent: GroupAgent) Callable[[], None][source]

This function returns a function that is called when a group agent is clicked

Parameters:
  • mode – The mode in which the group agent will be used

  • group_agent – The group agent object

Returns:

The function callback that is to be called when the group agent is clicked

app_utils.on_click_model_in_focus(mode: Literal['view', 'model_create', 'model_delete', 'model_view', 'model_edit'], model_meta_info: ModelMetaInfo) Callable[[], None][source]

This function returns a function that is called when a model is clicked

Parameters:
  • mode – The mode in which the model will be used

  • model_meta_info – The model meta information

Returns:

The function callback that is to be called when the model is clicked

app_utils.on_new_user_messaage(current_conversation: Conversation, model_used_by_user: ModelMetaInfo) None[source]

This function is called when a new user message is submitted A new conversation is created if the current conversation doesnt exist

Parameters:
  • current_conversation – The current conversation

  • model_used_by_user – The model used by the user

app_utils.render_conversation(current_conversation: Conversation, model_used_by_user: ModelMetaInfo) None[source]

This function renders the conversation

Parameters:
  • current_conversation – The current conversation

  • model_used_by_user – The model used by the user for the conversation

app_utils.render_group_agents_view(config_file: str, base_path: str) None[source]

This function renders the group agents view

Parameters:
  • config_file – The path to the config file

  • base_path – The base path

app_utils.render_group_conversation(group_conversation: GroupConversation) None[source]

This function renders the group conversation

Parameters:

group_conversation – The group conversation object

app_utils.render_model_create(model_meta_infos: List[ModelMetaInfo]) None[source]

This function renders the model create view

Parameters:

model_meta_info – The model meta information

app_utils.render_model_description(current_conversation: Conversation, model_used_by_user: ModelMetaInfo) None[source]

This function renders the model description

Parameters:
  • current_conversation – The current conversation

  • model_used_by_user – The model used by the user for the conversation

app_utils.render_model_edit(model_meta_info: ModelMetaInfo) None[source]

This function renders the model create view

Parameters:

model_meta_info – The model meta information

app_utils.render_model_view(model_meta_info: ModelMetaInfo) None[source]

This function renders the model view

Parameters:

model_meta_info – The model meta information

app_utils.render_models_view(config_file: str, base_path: str) None[source]

This function renders the models view

Parameters:
  • config_file – The path to the config file

  • base_path – The base path

app_utils.render_sidebar(current_conversation: Conversation, all_conversations: List[Conversation]) None[source]

This function renders the sidebar with the list of conversations

Parameters:
  • current_conversation – The current conversation

  • all_conversations – The list of all conversations

app_utils.reset_conversation() None[source]

This function resets the screen to start a new conversation

app_utils.reset_group_conversation() None[source]

This function resets the group conversation

app_utils.set_current_conversation(conversation: Conversation) None[source]

This function sets the current conversation to the session state

Parameters:

conversation – The conversation object to set as current conversation

app_utils.set_page_config()[source]

This function sets the page config for Streamlit app

app_utils.state_of_model() Literal['view', 'model_create', 'model_delete', 'model_view', 'model_edit'][source]

This function returns the state of the model

Returns:

The state of the model

app_utils.validate_settings_and_start_group_chat(group_agent: GroupAgent) None[source]

This function validates the settings and starts the group chat

Parameters:

group_agent – The group agent object