mirror of
https://github.com/AquaMorph/dotfiles.git
synced 2025-08-16 02:35:31 +00:00
Compare commits
3 Commits
5613fdefa9
...
8764d4446b
Author | SHA1 | Date | |
---|---|---|---|
8764d4446b | |||
5985673d8c | |||
d21f532b70 |
@@ -74,7 +74,7 @@
|
|||||||
#
|
#
|
||||||
# export AQUAAI_OLLAMA_URL='192.168.1.156:11434'
|
# export AQUAAI_OLLAMA_URL='192.168.1.156:11434'
|
||||||
#
|
#
|
||||||
ollama_url=${AQUAAI_OLLAMA_URL:='https://ollama.aquamorph.com'}
|
ollama_url=${AQUAAI_OLLAMA_URL:='https://ai.aquamorph.com'}
|
||||||
#
|
#
|
||||||
# Set the default model.
|
# Set the default model.
|
||||||
#
|
#
|
||||||
@@ -116,11 +116,23 @@ rich_format_path=${AQUAAI_RICH_FORMAT_PATH:=streamdown}
|
|||||||
# export AQUAAI_INSECURE_MODE=true
|
# export AQUAAI_INSECURE_MODE=true
|
||||||
#
|
#
|
||||||
insecure_mode=${AQUAAI_INSECURE_MODE:=false}
|
insecure_mode=${AQUAAI_INSECURE_MODE:=false}
|
||||||
|
#
|
||||||
|
# Use OpenAI api design instead of Ollama.
|
||||||
|
#
|
||||||
|
# export AQUAAI_OPENAI_API:=true
|
||||||
|
#
|
||||||
|
openai_api=${AQUAAI_OPENAI_API:=true}
|
||||||
|
#
|
||||||
|
# Set key used to authenticate with the API.
|
||||||
|
#
|
||||||
|
# export AQUAAI_KEY:=true
|
||||||
|
#
|
||||||
|
key=${AQUAAI_KEY:=''}
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
# Constants.
|
# Constants.
|
||||||
OLLAMA_URL=${ollama_url}
|
OLLAMA_URL=${ollama_url}
|
||||||
CURL_FLAGS='-sN'
|
CURL_FLAGS=('-sN')
|
||||||
USER=$(whoami)
|
USER=$(whoami)
|
||||||
DATA_DIR="${HOME}/.local/share/aquaai"
|
DATA_DIR="${HOME}/.local/share/aquaai"
|
||||||
RESPONSE_FIFO="${DATA_DIR}/.response"
|
RESPONSE_FIFO="${DATA_DIR}/.response"
|
||||||
@@ -264,14 +276,31 @@ function check_requirements() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get list of available models.
|
# Get available models info.
|
||||||
function get_models() {
|
function get_models() {
|
||||||
curl "${OLLAMA_URL}/api/tags" ${CURL_FLAGS}
|
local model_path=''
|
||||||
|
if [ "${openai_api}" == true ]; then
|
||||||
|
model_path='/api/models'
|
||||||
|
else
|
||||||
|
model_path='/api/tags'
|
||||||
|
fi
|
||||||
|
curl "${CURL_FLAGS[@]}" "${OLLAMA_URL}${model_path}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a list of available models.
|
||||||
|
function get_models_list() {
|
||||||
|
local jq_filter=''
|
||||||
|
if [ "${openai_api}" == true ]; then
|
||||||
|
jq_filter='.data[].id'
|
||||||
|
else
|
||||||
|
jq_filter='.models[].model'
|
||||||
|
fi
|
||||||
|
get_models | jq -r ${jq_filter}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print list of models.
|
# Print list of models.
|
||||||
function print_models() {
|
function print_models() {
|
||||||
get_models | jq -r '.models[].model' | column -t -s $'\t'
|
get_models_list | column -t -s $'\t'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print message variable.
|
# Print message variable.
|
||||||
@@ -282,7 +311,7 @@ function print_debug_message_history() {
|
|||||||
# Check if the model exists.
|
# Check if the model exists.
|
||||||
function check_if_model_exists() {
|
function check_if_model_exists() {
|
||||||
local model=${1}
|
local model=${1}
|
||||||
local model_list=($(get_models | jq -r '.models[].model'))
|
local model_list=($(get_models_list))
|
||||||
|
|
||||||
for m in "${model_list[@]}"; do
|
for m in "${model_list[@]}"; do
|
||||||
if [[ "$m" == "$model" ]]; then
|
if [[ "$m" == "$model" ]]; then
|
||||||
@@ -517,7 +546,7 @@ function get_friendly_save_names() {
|
|||||||
|
|
||||||
# Validate site certificate.
|
# Validate site certificate.
|
||||||
function check_cert() {
|
function check_cert() {
|
||||||
curl ${OLLAMA_URL} ${CURL_FLAGS} 2>&1 >/dev/null
|
curl "${CURL_FLAGS[@]}" ${OLLAMA_URL} 2>&1 >/dev/null
|
||||||
local ec=$?
|
local ec=$?
|
||||||
if [ "${ec}" == '60' ]; then
|
if [ "${ec}" == '60' ]; then
|
||||||
print_error 'unable to get local issuer certificate.'
|
print_error 'unable to get local issuer certificate.'
|
||||||
@@ -630,6 +659,7 @@ function chat() {
|
|||||||
handle_edit
|
handle_edit
|
||||||
handle_cli_mode
|
handle_cli_mode
|
||||||
handle_debug
|
handle_debug
|
||||||
|
rc=$((rc + $?))
|
||||||
handle_save
|
handle_save
|
||||||
rc=$((rc + $?))
|
rc=$((rc + $?))
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
@@ -654,9 +684,20 @@ function chat() {
|
|||||||
else
|
else
|
||||||
cat ${RESPONSE_FIFO} &
|
cat ${RESPONSE_FIFO} &
|
||||||
fi
|
fi
|
||||||
local response=$(curl -sN "$OLLAMA_URL/api/chat" \
|
local flags=("${CURL_FLAGS[@]}")
|
||||||
-d "$JSON_PAYLOAD" \
|
local chat_path=''
|
||||||
| stdbuf -o0 jq -j '.message.content // empty' \
|
local filter=''
|
||||||
|
if [ "${openai_api}" == true ]; then
|
||||||
|
flags+=(-H "Content-Type: application/json")
|
||||||
|
chat_path='/api/chat/completions'
|
||||||
|
filter='.choices[].delta.content // empty'
|
||||||
|
else
|
||||||
|
chat_path='/api/chat'
|
||||||
|
filter='.message.content // empty'
|
||||||
|
fi
|
||||||
|
local response=$(curl "${flags[@]}" "${OLLAMA_URL}${chat_path}" \
|
||||||
|
-d "${JSON_PAYLOAD}" | stdbuf -o0 sed 's/^data: //' \
|
||||||
|
| stdbuf -o0 jq -j "${filter}" 2>/dev/null \
|
||||||
| tee ${RESPONSE_FIFO})
|
| tee ${RESPONSE_FIFO})
|
||||||
wait
|
wait
|
||||||
# Newline for AI response.
|
# Newline for AI response.
|
||||||
@@ -682,10 +723,13 @@ function chat() {
|
|||||||
|
|
||||||
check_requirements
|
check_requirements
|
||||||
if [ "${insecure_mode}" == true ]; then
|
if [ "${insecure_mode}" == true ]; then
|
||||||
CURL_FLAGS+=' -k'
|
CURL_FLAGS+=('-k')
|
||||||
else
|
else
|
||||||
check_cert
|
check_cert
|
||||||
fi
|
fi
|
||||||
|
if [ "${openai_api}" == true ]; then
|
||||||
|
CURL_FLAGS+=(-H "Authorization: Bearer ${key}")
|
||||||
|
fi
|
||||||
cmd=chat_loop
|
cmd=chat_loop
|
||||||
set_default_agent
|
set_default_agent
|
||||||
|
|
||||||
|
@@ -16,11 +16,15 @@ HISTFILE=~/.zsh_history
|
|||||||
HISTSIZE=99999999
|
HISTSIZE=99999999
|
||||||
SAVEHIST=99999999
|
SAVEHIST=99999999
|
||||||
|
|
||||||
|
source "$HOME/.config/settings.conf"
|
||||||
|
|
||||||
# Text Editor
|
# Text Editor
|
||||||
alias emacs='emacs -nw'
|
alias emacs='emacs -nw'
|
||||||
alias e='emacs -nw'
|
alias e='emacs -nw'
|
||||||
|
|
||||||
|
# Search
|
||||||
|
alias g='grep -Irn'
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
alias i='sudo dnf install'
|
alias i='sudo dnf install'
|
||||||
alias d='sudo dnf'
|
alias d='sudo dnf'
|
||||||
@@ -33,7 +37,6 @@ alias a='git add'
|
|||||||
alias ga='git add -A'
|
alias ga='git add -A'
|
||||||
alias gu='git add -u'
|
alias gu='git add -u'
|
||||||
alias s='git status'
|
alias s='git status'
|
||||||
alias g='git'
|
|
||||||
alias p='git pull'
|
alias p='git pull'
|
||||||
alias gp='git push'
|
alias gp='git push'
|
||||||
alias gd='git diff $(git rev-parse --abbrev-ref HEAD)'
|
alias gd='git diff $(git rev-parse --abbrev-ref HEAD)'
|
||||||
@@ -49,6 +52,7 @@ alias cr="${AQUAAI_PATH} --code-review"
|
|||||||
export AQUAAI_DEFAULT_MODEL='qwen2.5:1.5b'
|
export AQUAAI_DEFAULT_MODEL='qwen2.5:1.5b'
|
||||||
export AQUAAI_CODING_MODEL='qwen2.5:3b'
|
export AQUAAI_CODING_MODEL='qwen2.5:3b'
|
||||||
export AQUAAI_RICH_FORMAT_MODE=true
|
export AQUAAI_RICH_FORMAT_MODE=true
|
||||||
|
export AQUAAI_KEY
|
||||||
|
|
||||||
export TERM=xterm
|
export TERM=xterm
|
||||||
export EDITOR='emacs -nw'
|
export EDITOR='emacs -nw'
|
||||||
|
Reference in New Issue
Block a user