-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.sh
More file actions
executable file
·39 lines (32 loc) · 1.13 KB
/
chat.sh
File metadata and controls
executable file
·39 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Check if no arguments were provided
if [ $# -eq 0 ]; then
echo "Provide text prompt as argument or use '--new' flag to start a new chat"
echo "E.g. ./chat.sh 'What is 1+1=' or ./chat.sh --new"
exit 1
fi
# todo implement --justlisten / -noresponse - to just add context
# todo implement --undo (delete lastuserinput)
# todo implement --retry (just redo lastuserinput)
# todo implement --interactive
# Check if --new flag was provided
if [ "$1" = "--new" ]; then
./src/new.sh
echo "New chat ready!"
exit 0
fi
# assume new if there is no preferences file
if ! ls context/*-preferences 1> /dev/null 2>&1; then
./src/new.sh
# don't exit here, we want to continue to process user input
fi
current_date=$(date '+%y-%m-%d %H:%M:%S')
# Create new user input from command line arguments
lastuserinputfile="context/${current_date}-input"
> $lastuserinputfile
echo "$@" >> $lastuserinputfile
# Generate context string from all files
./src/contexttostring.sh
lastresponsefile="context/${current_date}-response"
> $lastresponsefile
ollama run Llama3.1-noheat < tempchatcontext --nowordwrap > $lastresponsefile
cat "$lastresponsefile"