Skip to content

Commit b08fcb7

Browse files
author
Warren Mann
committed
Tweak scripts
1 parent 263fff7 commit b08fcb7

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

chewie-chat

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export CHEWIECHAT_CONTEXT_FILE=$CHEWIECHAT_CONTEXT_PATH/$CHEWIECHAT_CONTEXT_FILE
2424

2525
echo "Using context file \"$CHEWIECHAT_CONTEXT_FILE\""
2626
mkdir -p $CHEWIECHAT_CONTEXT_PATH
27+
if [ ! -f $CHEWIECHAT_CONTEXT_FILE ] ; then
28+
echo "Creating context file..."
29+
create_ctx()
30+
echo "context file created"
31+
fi
2732

2833
echo "Press Ctrl-C to exit."
2934

@@ -43,11 +48,16 @@ while [ 1 ] ; do
4348
exit 0
4449
elif [ x"$input" == "x/r" ] ; then
4550
echo "Resetting context..."
46-
chewie r u aip="$CHEWIECHAT_API" mdl="$CHEWIECHAT_MODEL" ctx="$CHEWIECHAT_CONTEXT_FILE" > /dev/null
51+
create_ctx()
4752
echo "context file reset"
4853
continue
4954
fi
5055
echo -n "chewie > "
5156
echo "$input" | chewie aip="$CHEWIECHAT_API" mdl="$CHEWIECHAT_MODEL" aih="$CHEWIECHAT_HOST" ctx="$CHEWIECHAT_CONTEXT_FILE"
5257
done
5358

59+
function create_ctx()
60+
{
61+
chewie r u ctx="$CHEWIECHAT_CONTEXT_FILE" > /dev/null
62+
chewie u aip="$CHEWIECHAT_API" mdl="$CHEWIECHAT_MODEL" ctx="$CHEWIECHAT_CONTEXT_FILE" sys="You are a helpful assistant." > /dev/null
63+
}

qb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ fi
1717

1818
QB_CONTEXT_PATH=~/.cache/chewie
1919
QB_CONTEXT=$QB_CONTEXT_PATH/qb-context.json
20+
if [ ! -f $QB_CONTEXT ]; then
21+
init_context()
22+
fi
2023

2124
if [ "$1" == "-h" ] ; then
2225
echo "Usage: qb [options]"
@@ -32,6 +35,7 @@ if [ "$1" == "-s" ] ; then
3235
echo "Using model \"$QB_MODEL\""
3336
echo "Using context file \"$QB_CONTEXT\""
3437
mkdir -p $QB_CONTEXT_PATH
38+
chewie r u ctx="$QB_CONTEXT" > /dev/null
3539
chewie r u ctx="$QB_CONTEXT" mdl="$QB_MODEL" sys="You are an intelligent assistant helping me use bash on Linux. All of your responses should be in the context of using bash on Linux. If you do not know the answer to a question, just say \"I don\'t know\"." > /dev/null
3640
echo "done!"
3741
exit 0

qc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ if [ "$1" == "-s" ] ; then
3333
echo "Using model \"$QC_MODEL\""
3434
echo "Using API \"$CHEWIE_API\""d
3535
echo "Using context file \"$QC_CONTEXT\""
36-
chewie r u ctx="$QC_CONTEXT" mdl="$QC_MODEL" sys="You are an intelligent assistant helping me write computer programs in the C language on Linux. All of your responses should be in the context of using the C programming language on Linux. If you do not know the answer to a question, just say \"I don't know\"." > /dev/null
36+
chewie r u ctx="$QC_CONTEXT" > /dev/null
37+
chewie u ctx="$QC_CONTEXT" mdl="$QC_MODEL" sys="You are an intelligent assistant helping me write computer programs in the C language on Linux. All of your responses should be in the context of using the C programming language on Linux. If you do not know the answer to a question, just say \"I don't know\"." > /dev/null
3738
echo "done!"
3839
exit 0
3940
fi

qg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ if [ "$1" == "-s" ] ; then
3333
echo "Using model \"$QG_MODEL\""
3434
echo "Using context file \"$QG_CONTEXT\""
3535
mkdir -p $QG_CONTEXT_PATH
36-
chewie r u ctx="$QG_CONTEXT" mdl="$QG_MODEL" sys="You are an intelligent assistant helping me with source code management using git. All of your responses should be in the context of using git for source code management. If you do not know the answer to a question, just say \"I don't know\"." > /dev/null
36+
chewie r u ctx="$QG_CONTEXT" > /dev/null
37+
chewie u ctx="$QG_CONTEXT" mdl="$QG_MODEL" sys="You are an intelligent assistant helping me use git on Linux. All of your responses should be in the context of using git on Linux. If you do not know the answer to a question, just say \"I don\'t know\"." > /dev/null
3738
echo "done!"
3839
exit 0
3940
fi

qn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ if [ "$1" == "-s" ] ; then
3232
echo "Using model \"$QN_MODEL\""
3333
echo "Using context file \"$QN_CONTEXT\""
3434
mkdir -p $QN_CONTEXT_PATH
35-
chewie r u ctx="$QN_CONTEXT" mdl="$QN_MODEL" sys="You are an intelligent assistant helping me use NixOS. All of your responses should be in the context of using NixOS. If you do not know the answer to a question, just say \"I don\'t know\"." > /dev/null
35+
chewie r u ctx="$QN_CONTEXT" > /dev/null
36+
chewie u ctx="$QN_CONTEXT" mdl="$QN_MODEL" sys="You are an intelligent assistant helping me use NixOS. All of your responses should be in the context of using NixOS. If you do not know the answer to a question, just say \"I don\'t know\"." > /dev/null
3637
echo "done!"
3738
exit 0
3839
fi

0 commit comments

Comments
 (0)