Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb/estebanways #477

Merged
merged 15 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,18 @@ dmypy.json

# Ignore Logs
logs
# Do not ignore skill-script log files
#*.log
*.log

# Ignore the directory tests/
tests/
# Ignore .bak extensions
*.bak

# Ignore the contents of the "user/conversation_logs" directory
user/conversation_logs/*
!user/conversation_logs/.gitkeep
# Ignore the contents of the "certificates" directory
certificates/*
!certificates/.gitkeep

# Ignore the contents of the "src/bundles" directory
src/bundles/*

# Ignore the contents of the "src/certificates" directory
src/certificates/*

# Ignore the contents of the "src/config" directory
src/config/*

Expand All @@ -162,6 +158,17 @@ src/skills_db/*
# Ignore the contents of the "src/tests" directory
src/tests/*

# Ignore the directory tests/
tests/

# Ignore the contents of the "user/conversation_logs" directory
user/conversation_logs/*
!user/conversation_logs/.gitkeep

# Ignore the contents of the "user/analysis_zone/" directory
user/analysis_zone/*
!user/analysis_zone/.gitkeep

# Ignore IDE specific files
.idea/
.vscode/
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ This project is coded and organized like this:
│ └── skill_patterns
│ └── en_us
│ └── openai_whisper_model_base
├── certificates # Stores the configuration and security certificates
├── config # Stores the configuration file
├── data # Stores the voice recognition model results and other data files
├── env # Stores the environment file
Expand All @@ -123,9 +124,7 @@ This project is coded and organized like this:
│ │ ├── audiobooks
│ │ │ └── Robinson_Crusoe
│ │ └── ...
│ ├── certificates
│ ├── config
│ ├── log
│ ├── skills_db
│ │ ├── arduino
│ │ ├── bash
Expand All @@ -143,9 +142,10 @@ This project is coded and organized like this:
│ ├── tests
│ │ └── ...
│ └── ...
├── user # Stores previous conversation files and other user files
│ └── converstation_logs
└── tests # Stores the Commbase tests
├── user # Stores previous chat conversations and other user files
│ ├── analysis_zone
│ └── conversation_logs
└── tests # Stores the Commbase tests
```

## Contributing
Expand Down
6 changes: 3 additions & 3 deletions assets/docs/User's Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ The windows from 2 to 5 are not required by the app to work, and can be disabled

The window 1, "Commbase", contains 7 panes, where every pane runs a component:
- Pane 1. It is the chatroom component.
- Pane 2. It is the client component.
- Pane 2. It is the speech recognizer component.
- Pane 3. It is the server component.
- Pane 4. It is the speech recognizer component.
- Pane 4. It is the client component.
- Pane 5. It is the use mode component.
- Pane 6. It is the audio mixer component.
- Pane 7. It is the user terminal component. It is almost always focused, except when is used by Commbase for launching skill scripts.
- Pane 7. It is the voice recorder component and also the user terminal component. It's almost always focused, and it is used by Commbase for launching skills.

The window 2, "Dashboard", contains a single pane that is disabled by default in the configuration file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main():
if response is not None:
session_name = 'Commbase-0'
window_number = '1'
pane_number = '2'
pane_number = '4'
if response.status_code == 200:
# Print "JSON data saved successfully."
status = "JSON data updated successfully."
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"messages": [{"control": ""}, {"current_request": "sto"}, {"previous_request": "sto"}, {"current_response": ""}, {"runtime": ""}, {"source_code_display": ""}, {"source_code": ""}]}
{"messages": [{"control": ""}, {"current_request": "hello world"}, {"previous_request": "hello world"}, {"current_response": ""}, {"runtime": ""}, {"source_code_display": ""}, {"source_code": ""}]}
56 changes: 56 additions & 0 deletions bundles/libcommbase/libcommbase/routines/store_chat_log_copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/env bash
################################################################################
# libcommbase #
# #
# A collection of libraries to centralize common functions that can be shared #
# across multiple conversational AI assistant projects #
# #
# Change History #
# 03/06/2024 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2023-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 #

# store_chat_log_copy.sh
# Creates a timestamped copy of the current chat log file, stores it in a
# specific user directory, and then clears the original chat log content.
store_chat_log_copy() {
# Imports
source "$COMMBASE_APP_DIR"/config/commbase.conf

# Generate a chat log file name with date and a random number
random_filename="chat_log_$(date +%Y%m%d%H%M%S)_$RANDOM.txt"
# Store a copy of the chat file in the user directory
cp "$COMMBASE_APP_DIR""$CHAT_LOG_FILE" "$COMMBASE_APP_DIR/user/conversation_logs/$random_filename"
# Get rid of the chat content
rm "$COMMBASE_APP_DIR""$CHAT_LOG_FILE"

exit 99
}

# Call store_copy_of_chat_log if the script is run directly (not sourced)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
(store_chat_log_copy)
fi

exit 99
Empty file added certificates/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions data/.chat_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
🧑 END USER:
2 changes: 1 addition & 1 deletion data/.messages.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"messages":[{"control":""},{"current_request":"sto"},{"previous_request":"sto"},{"current_response":""},{"runtime":""},{"source_code_display":""},{"source_code":""}]}
{"messages":[{"control":""},{"current_request":"hello world"},{"previous_request":"hello world"},{"current_response":""},{"runtime":""},{"source_code_display":""},{"source_code":""}]}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ route_option() {
source $COMMBASE_APP_DIR/src/app.sh

# Imports from libcommbase
store_chat_log_copy=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/store_chat_log_copy.sh
update_control_in_messages_json=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/update_control_in_messages_json.sh
controller=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/controller.sh

Expand Down Expand Up @@ -198,13 +199,8 @@ route_option() {
'stop')
echo "Stopping application"
echo "Saving conversation to the user directory..."
(bash "$store_chat_log_copy")
sleep 2
# Generate a chat log file name with date and a random number
random_filename="chat_log_$(date +%Y%m%d%H%M%S)_$RANDOM.txt"
# Store a copy of the chat file in the user directory
cp "$COMMBASE_APP_DIR""$CHAT_LOG_FILE" "$COMMBASE_APP_DIR/user/conversation_logs/$random_filename"
# Get rid of the chat content
rm "$COMMBASE_APP_DIR""$CHAT_LOG_FILE"
# In this block, "pkill -f" the processes of the scripts that do not
# respond to the interrupt signal or appear to duplicate once the
# program stops and exits.
Expand Down
22 changes: 15 additions & 7 deletions src/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ app() {

# Imports from libcommbase
source "$COMMBASE_APP_DIR"/bundles/libcommbase/libcommbase/routines/check_data_exchange_server_connection.sh
store_chat_log_copy=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/store_chat_log_copy.sh
tail_chat_log=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/tail_chat_log.sh
text_animation=$COMMBASE_APP_DIR/bundles/libcommbase/libcommbase/routines/text_animation.sh

Expand Down Expand Up @@ -73,7 +74,14 @@ app() {
(tmux split-window -h && tmux select-pane -t 2 && sleep $time);

# Pane 1
# On window 0, select pane 1, open or create the chatroom file
# On window 0, if the chat file exists and is not empty, save a copy to the
# CHAT_LOG_FILE. This is to keep a backup copy of the chat progress after
# events that might have prevented the application from closing gracefully
# with the 'commbase stop' command.
if [ -s "$COMMBASE_APP_DIR$CHAT_LOG_FILE" ]; then
(bash "$store_chat_log_copy")
fi
# Select pane 1, open or create the chatroom file
(tmux select-pane -t 1 && tmux send-keys " touch $COMMBASE_APP_DIR$CHAT_LOG_FILE" C-m && sleep $time);
# Run tail_chat_log and then press the enter key
(tmux select-pane -t 1 && tmux send-keys " clear; bash $tail_chat_log" C-m && sleep $time);
Expand All @@ -91,17 +99,17 @@ app() {
# On window 0, select pane 2, activate the conda environment if it exists,
# send the enter key, and sleep.
(tmux select-pane -t 2 && tmux send-keys " conda activate $CONDA_ENV_NAME_IF_EXISTS" C-m && sleep $time);
# Run commbase-data-exchange client and then press enter
(tmux select-pane -t 2 && tmux send-keys " clear; $PYTHON_ENV_VERSION $COMMBASE_DATA_EXCHANGE_CLIENT_CONNECTION_FILE_PATH" C-m && sleep $time);
# Run the STT_ENGINE_STRING and then press the enter
(tmux select-pane -t 2 && tmux send-keys " clear; cpulimit --limit=$STT_PROCESS_CPU_LIMIT_PERCENTAGE -- $STT_ENGINE_STRING" C-m && sleep $time);
# Clear the screen, and set the prompt to an empty string
(tmux select-pane -t 2 && tmux send-keys " clear && PS1=""" C-m);

# Pane 4
# On window 0, select pane 4, activate the conda environment if it exists,
# send the enter key, and sleep.
(tmux select-pane -t 4 && tmux send-keys " conda activate $CONDA_ENV_NAME_IF_EXISTS" C-m && sleep $time);
# Run the STT_ENGINE_STRING and then press the enter
(tmux select-pane -t 4 && tmux send-keys " clear; cpulimit --limit=$STT_PROCESS_CPU_LIMIT_PERCENTAGE -- $STT_ENGINE_STRING" C-m && sleep $time);
# Clear the screen, and set the prompt to an empty string
(tmux select-pane -t 4 && tmux send-keys " clear && PS1=""" C-m);
# Run commbase-data-exchange client and then press enter
(tmux select-pane -t 4 && tmux send-keys " clear; $PYTHON_ENV_VERSION $COMMBASE_DATA_EXCHANGE_CLIENT_CONNECTION_FILE_PATH" C-m && sleep $time);

# Split vertically the pane 4
(tmux select-pane -t 4 && tmux split-pane -h && sleep $time);
Expand Down
Empty file added user/analysis_zone/.gitkeep
Empty file.
Loading