Skip to content

Commit

Permalink
Merge pull request #427 from mydroidandi/fb/estebanways
Browse files Browse the repository at this point in the history
Fb/estebanways
  • Loading branch information
estebanways authored Feb 26, 2024
2 parents 5117f61 + 93be30d commit 8b82f64
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ shell=bash
# Enable specific checks (comma-separated)
# To disable a check, prefix it with "no"
#enable=SC1000,noSC2000
disable=SC1090
disable=SC1090,SC1091,SC1087

# Ignore specific errors in certain lines
# Example: Ignore SC1000 and SC2000 in lines 5 and 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"messages": [{"control": ""}, {"current_request": "Ok stop!"}, {"previous_request": "Ok stop!"}, {"current_response": ""}, {"runtime": ""}, {"source_code_display": ""}, {"source_code": ""}]}
{"messages": [{"control": ""}, {"current_request": "tell me about yourself"}, {"previous_request": "tell me about yourself"}, {"current_response": ""}, {"runtime": ""}, {"source_code_display": ""}, {"source_code": ""}]}
7 changes: 4 additions & 3 deletions bundles/libcommbase/libcommbase/controller/controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@
# through the commbase-data-exchange client.
controller() {
# Imports
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR/config/commbase.conf"

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

# Extract the JSON object property value current_request from the file
# messages json.
messages_json=$(<$COMMBASE_APP_DIR$MESSAGING_FILE)
messages_json=$(<"$COMMBASE_APP_DIR""$MESSAGING_FILE")
# Read the value of current_request property from JSON
current_request=$(jq -r '.messages[1].current_request' <<< "$messages_json")

# Extract the JSON object control patterns from file and process them
patterns_file=$(<$COMMBASE_APP_DIR$CONTROL_PATTERNS_FILE)
patterns_file=$(<"$COMMBASE_APP_DIR""$CONTROL_PATTERNS_FILE")
#cat $COMMBASE_APP_DIR$CONTROL_PATTERNS_FILE | jq 'to_entries[] | .key, .value[]'

matching_property=""
Expand All @@ -67,6 +67,7 @@ controller() {

# Search for exactly equal string matches
for property in $(echo "$patterns_file" | jq -r 'keys_unsorted[]'); do
# Braces '{[]}' wrap the array expansion without changing the behavior of the code.
# To protect against the possibility that .items is not an array use "?"
values=$(echo "$patterns_file" | jq -r ".$property[]?" | tr '\n' '|')
values=${values%|} # Remove the trailing "|"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
check_data_exchange_server_connection() {

# The configuration file
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/commbase.conf

# Data exchange server IP address and port
SERVER_HOST=$COMMBASE_DATA_EXCHANGE_SERVER_HOST_ADDRESS
Expand Down
2 changes: 1 addition & 1 deletion bundles/libcommbase/libcommbase/routines/tail_chat_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# color formatting.
tail_chat_log() {
# Imports
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/commbase.conf

# Define the strings as variables
assistant_string="$ASSISTANT_NAME_IN_CHAT_PANE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ update_hostname_and_ip_address() {
ENV_FILE="$COMMBASE_APP_DIR/env/.env";

# The configuration file
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/commbase.conf

# Capture the current host name and host IP address and storing them
NEW_HOST_NAME=$(hostname | awk '{print $1}');
Expand Down
42 changes: 0 additions & 42 deletions data/.chat_log.txt

This file was deleted.

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":"Ok stop!"},{"previous_request":"Ok stop!"},{"current_response":""},{"runtime":""},{"source_code_display":""},{"source_code":""}]}
{"messages":[{"control":""},{"current_request":"tell me about yourself"},{"previous_request":"tell me about yourself"},{"current_response":""},{"runtime":""},{"source_code_display":""},{"source_code":""}]}
4 changes: 1 addition & 3 deletions scripts/configuration/build_conda_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ recreate_conda_env(){
exit 99
}

recreate_conda_env || exit 99;

exit 99
recreate_conda_env;
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Uses the keyboard binding ALT + SHIFT + 1.
toggle_capture_on_off() {
# Imports
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/commbase.conf

tts_engine="$TTS_ENGINE_STRING"

Expand Down
5 changes: 2 additions & 3 deletions src/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
# Creates the Commbase application interface and enters the Commbase session.
app() {
# The configuration file
source $COMMBASE_APP_DIR/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/commbase.conf

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

# Give .3 seconds to tmux to draw its content before continuing
Expand Down
32 changes: 14 additions & 18 deletions src/client_skill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
# are missing.
client_skill() {
# Configuration files
source $COMMBASE_APP_DIR/config/commbase.conf
source $COMMBASE_APP_DIR/config/app.conf
source $COMMBASE_APP_DIR/config/secrets
source "$COMMBASE_APP_DIR"/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/app.conf
source "$COMMBASE_APP_DIR"/config/secrets

# Tmux session
session_name="Commbase-0"
Expand All @@ -53,7 +53,7 @@ client_skill() {
fi

# Data files
json_data=$(cat $COMMBASE_APP_DIR/data/.messages.json)
json_data=$(cat "$COMMBASE_APP_DIR"/data/.messages.json)

# Extract values from JSON object
source_code=$(echo "$json_data" | jq -r '.messages[] | select(has("source_code")).source_code')
Expand All @@ -68,22 +68,20 @@ client_skill() {
fi

# Save source code to a temporary file
echo "$source_code" > $COMMBASE_APP_DIR/data/.skill_runner
echo "$source_code" > "$COMMBASE_APP_DIR"/data/.skill_runner

# Check if the specified runtime is available
case "$runtime" in
"bash")
if ! command -v bash &> /dev/null; then
echo "Bash is not installed. Please install it before running this script."
rm $COMMBASE_APP_DIR/data/.skill_runner
rm "$COMMBASE_APP_DIR"/data/.skill_runner
exit 1
fi
# TODO: The echoes for the pane 1, chatroom, must include string of the
# Assistant name with tag and colors, something like
# printf "\e[1;41mCOMMBASE:\e[1;m I don't understand: %s\n" "$current_request""." ----> but using the config file variables.
tmux has-session -t $session_name 2>/dev/null

if [ $? != 0 ]; then
# TODO: Append echoes using assistant name in confir contants file, to
# write ASSISTANT: blablabla, in chat_log.txt
if ! tmux has-session -t $session_name 2>/dev/null; then
echo "Session does not exist. Please create or start the session first."
else
if [ "$source_code_display" = "session_pane_six" ]; then
Expand Down Expand Up @@ -141,12 +139,11 @@ client_skill() {
"nodejs")
if ! command -v node &> /dev/null; then
echo "Node.js is not installed. Please install it before running this script."
rm $COMMBASE_APP_DIR/data/.skill_runner
rm "$COMMBASE_APP_DIR"/data/.skill_runner
exit 1
fi
tmux has-session -t $session_name 2>/dev/null

if [ $? != 0 ]; then
if ! tmux has-session -t $session_name 2>/dev/null; then
echo "Session does not exist. Please create or start the session first."
else
if [ "$source_code_display" = "session_pane_six" ]; then
Expand Down Expand Up @@ -204,12 +201,11 @@ client_skill() {
"python")
if ! command -v python &> /dev/null; then
echo "Python is not installed. Please install it before running this script."
rm $COMMBASE_APP_DIR/data/.skill_runner
rm "$COMMBASE_APP_DIR"/data/.skill_runner
exit 1
fi
tmux has-session -t $session_name 2>/dev/null

if [ $? != 0 ]; then
if ! tmux has-session -t $session_name 2>/dev/null; then
echo "Session does not exist. Please create or start the session first."
else
if [ "$source_code_display" = "session_pane_six" ]; then
Expand Down Expand Up @@ -267,7 +263,7 @@ client_skill() {
# Add custom runtimes here ...
*)
echo "Unsupported runtime: $runtime"
rm $COMMBASE_APP_DIR/data/.skill_runner
rm "$COMMBASE_APP_DIR"/data/.skill_runner
exit 1
;;
esac
Expand Down
8 changes: 4 additions & 4 deletions src/server_skill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
# directory, and calls the updater in the server side.
server_skill() {
# The configuration files
source $COMMBASE_APP_DIR/config/commbase.conf
source $COMMBASE_APP_DIR/config/app.conf
source $COMMBASE_APP_DIR/config/secrets
source "$COMMBASE_APP_DIR"/config/commbase.conf
source "$COMMBASE_APP_DIR"/config/app.conf
source "$COMMBASE_APP_DIR"/config/secrets

# Read the new JSON data request stored in commbase-data-exchange/server/client_data
data_exchange_client_data_file=/bundles/commbase-data-exchange/server/client_data/json_1.json

messages=$(<$COMMBASE_APP_DIR$data_exchange_client_data_file)
messages=$(<"$COMMBASE_APP_DIR"$data_exchange_client_data_file)

# Extract and echo each message
#echo "$messages" | jq -r '.messages[] | to_entries[] | "\(.key): \(.value)"'
Expand Down

0 comments on commit 8b82f64

Please sign in to comment.