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'
|
||||
#
|
||||
ollama_url=${AQUAAI_OLLAMA_URL:='https://ollama.aquamorph.com'}
|
||||
ollama_url=${AQUAAI_OLLAMA_URL:='https://ai.aquamorph.com'}
|
||||
#
|
||||
# Set the default model.
|
||||
#
|
||||
@@ -116,11 +116,23 @@ rich_format_path=${AQUAAI_RICH_FORMAT_PATH:=streamdown}
|
||||
# export AQUAAI_INSECURE_MODE=true
|
||||
#
|
||||
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.
|
||||
OLLAMA_URL=${ollama_url}
|
||||
CURL_FLAGS='-sN'
|
||||
CURL_FLAGS=('-sN')
|
||||
USER=$(whoami)
|
||||
DATA_DIR="${HOME}/.local/share/aquaai"
|
||||
RESPONSE_FIFO="${DATA_DIR}/.response"
|
||||
@@ -264,14 +276,31 @@ function check_requirements() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Get list of available models.
|
||||
# Get available models info.
|
||||
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.
|
||||
function print_models() {
|
||||
get_models | jq -r '.models[].model' | column -t -s $'\t'
|
||||
get_models_list | column -t -s $'\t'
|
||||
}
|
||||
|
||||
# Print message variable.
|
||||
@@ -282,7 +311,7 @@ function print_debug_message_history() {
|
||||
# Check if the model exists.
|
||||
function check_if_model_exists() {
|
||||
local model=${1}
|
||||
local model_list=($(get_models | jq -r '.models[].model'))
|
||||
local model_list=($(get_models_list))
|
||||
|
||||
for m in "${model_list[@]}"; do
|
||||
if [[ "$m" == "$model" ]]; then
|
||||
@@ -517,7 +546,7 @@ function get_friendly_save_names() {
|
||||
|
||||
# Validate site certificate.
|
||||
function check_cert() {
|
||||
curl ${OLLAMA_URL} ${CURL_FLAGS} 2>&1 >/dev/null
|
||||
curl "${CURL_FLAGS[@]}" ${OLLAMA_URL} 2>&1 >/dev/null
|
||||
local ec=$?
|
||||
if [ "${ec}" == '60' ]; then
|
||||
print_error 'unable to get local issuer certificate.'
|
||||
@@ -630,6 +659,7 @@ function chat() {
|
||||
handle_edit
|
||||
handle_cli_mode
|
||||
handle_debug
|
||||
rc=$((rc + $?))
|
||||
handle_save
|
||||
rc=$((rc + $?))
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
@@ -654,9 +684,20 @@ function chat() {
|
||||
else
|
||||
cat ${RESPONSE_FIFO} &
|
||||
fi
|
||||
local response=$(curl -sN "$OLLAMA_URL/api/chat" \
|
||||
-d "$JSON_PAYLOAD" \
|
||||
| stdbuf -o0 jq -j '.message.content // empty' \
|
||||
local flags=("${CURL_FLAGS[@]}")
|
||||
local chat_path=''
|
||||
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})
|
||||
wait
|
||||
# Newline for AI response.
|
||||
@@ -682,10 +723,13 @@ function chat() {
|
||||
|
||||
check_requirements
|
||||
if [ "${insecure_mode}" == true ]; then
|
||||
CURL_FLAGS+=' -k'
|
||||
CURL_FLAGS+=('-k')
|
||||
else
|
||||
check_cert
|
||||
fi
|
||||
if [ "${openai_api}" == true ]; then
|
||||
CURL_FLAGS+=(-H "Authorization: Bearer ${key}")
|
||||
fi
|
||||
cmd=chat_loop
|
||||
set_default_agent
|
||||
|
||||
|
@@ -16,11 +16,15 @@ HISTFILE=~/.zsh_history
|
||||
HISTSIZE=99999999
|
||||
SAVEHIST=99999999
|
||||
|
||||
source "$HOME/.config/settings.conf"
|
||||
|
||||
# Text Editor
|
||||
alias emacs='emacs -nw'
|
||||
alias e='emacs -nw'
|
||||
|
||||
# Search
|
||||
alias g='grep -Irn'
|
||||
|
||||
# Other
|
||||
alias i='sudo dnf install'
|
||||
alias d='sudo dnf'
|
||||
@@ -33,7 +37,6 @@ alias a='git add'
|
||||
alias ga='git add -A'
|
||||
alias gu='git add -u'
|
||||
alias s='git status'
|
||||
alias g='git'
|
||||
alias p='git pull'
|
||||
alias gp='git push'
|
||||
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_CODING_MODEL='qwen2.5:3b'
|
||||
export AQUAAI_RICH_FORMAT_MODE=true
|
||||
export AQUAAI_KEY
|
||||
|
||||
export TERM=xterm
|
||||
export EDITOR='emacs -nw'
|
||||
|
Reference in New Issue
Block a user