Update aichat version and add conf generation using ollama API.
This commit is contained in:
@@ -79,7 +79,9 @@ services:
|
|||||||
dockerfile: src/aichat/Dockerfile
|
dockerfile: src/aichat/Dockerfile
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
|
- OLLAMA_HOST=ollama
|
||||||
- API_KEY=${LLM_API_KEY}
|
- API_KEY=${LLM_API_KEY}
|
||||||
|
- MODELS=${MODELS}
|
||||||
depends_on:
|
depends_on:
|
||||||
- ollama
|
- ollama
|
||||||
links:
|
links:
|
||||||
|
|||||||
@@ -9,43 +9,14 @@ if [[ ! -x $(command -v aichat) ]]; then
|
|||||||
if [[ $(docker compose ps -q aichat) ]]; then
|
if [[ $(docker compose ps -q aichat) ]]; then
|
||||||
docker compose cp "aichat:/usr/bin/aichat" "./tools/"
|
docker compose cp "aichat:/usr/bin/aichat" "./tools/"
|
||||||
else
|
else
|
||||||
cargo install aichat@0.29.0
|
cargo install aichat@0.30.0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -a
|
||||||
source .env
|
source .env
|
||||||
mkdir -p ~/.config/aichat/
|
OLLAMA_HOST=localhost ./tools/gen_aichat_conf.sh >~/.config/aichat/config.yaml
|
||||||
cat src/aichat/config.yaml | sed "s/__LLM_API_KEY__/${LLM_API_KEY}/" >~/.config/aichat/config.yaml
|
set +a
|
||||||
OLLAMA_HOST=$(cat .env | grep OLLAMA_HOST | cut -d'=' -f2 | cut -d'/' -f3)
|
|
||||||
if [[ ! -z $OLLAMA_HOST ]]; then
|
|
||||||
cat ~/.config/aichat/config.yaml | sed "s/http/https/" >~/.config/aichat/config.yaml.tmp
|
|
||||||
cat ~/.config/aichat/config.yaml.tmp | sed "s/localhost:11434/${OLLAMA_HOST}/" >~/.config/aichat/config.yaml
|
|
||||||
fi
|
|
||||||
DEFAULT_MODEL=$(cat .env | grep '^MODELS=' | cut -d'=' -f2 | cut -d',' -f2)
|
|
||||||
EMBEDDING_MODEL=$(cat .env | grep '^MODELS=' | cut -d'=' -f2 | cut -d',' -f1)
|
|
||||||
if [[ -z ${EMBEDDING_MODEL} ]] || [[ -z ${DEFAULT_MODEL} ]]; then
|
|
||||||
echo "MODELS in .env are missing."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat ~/.config/aichat/config.yaml | sed "s/__EMBEDDING_MODEL__/ollama:${EMBEDDING_MODEL}/" >~/.config/aichat/config.yaml.tmp
|
|
||||||
cat ~/.config/aichat/config.yaml.tmp | sed "s/__DEFAULT_MODEL__/ollama:${DEFAULT_MODEL}/" >~/.config/aichat/config.yaml
|
|
||||||
|
|
||||||
MODELS=$(cat .env | grep '^MODELS=' | cut -d'=' -f2 | cut -d',' -f2- | tr ',' ' ')
|
|
||||||
for i in ${MODELS}; do
|
|
||||||
echo " - name: ${i}" >>~/.config/aichat/config.yaml
|
|
||||||
echo
|
|
||||||
read -p "Does the model ${i} support function calling? [y/N] " -n 1 -r
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
echo " supports_function_calling: true" >>~/.config/aichat/config.yaml
|
|
||||||
else
|
|
||||||
echo " supports_function_calling: false" >>~/.config/aichat/config.yaml
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
read -rp "What is the maximum number of input tokens ${i} supports? [128000] " max_input_tokens
|
|
||||||
max_input_tokens=${max_input_tokens:-128000}
|
|
||||||
echo " max_input_tokens: ${max_input_tokens}" >>~/.config/aichat/config.yaml
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p ~/.config/aichat/roles
|
mkdir -p ~/.config/aichat/roles
|
||||||
cp src/aichat/roles/* ~/.config/aichat/roles/
|
cp src/aichat/roles/* ~/.config/aichat/roles/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
FROM rust:latest
|
FROM rust:latest
|
||||||
|
|
||||||
RUN rustup target add x86_64-unknown-linux-musl
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
RUN apt update && apt install -y musl-tools musl-dev curl
|
RUN apt update && apt install -y musl-tools musl-dev curl jq
|
||||||
RUN update-ca-certificates
|
RUN update-ca-certificates
|
||||||
|
|
||||||
ADD src/aichat/entrypoint.sh /entrypoint.sh
|
ADD src/aichat/entrypoint.sh /entrypoint.sh
|
||||||
@@ -11,7 +11,7 @@ RUN useradd -ms /bin/bash aichat
|
|||||||
USER aichat
|
USER aichat
|
||||||
|
|
||||||
WORKDIR /home/aichat
|
WORKDIR /home/aichat
|
||||||
RUN git clone --branch v0.29.0 --depth 1 https://github.com/sigoden/aichat
|
RUN git clone --branch v0.30.0 --depth 1 https://github.com/sigoden/aichat
|
||||||
WORKDIR /home/aichat/aichat
|
WORKDIR /home/aichat/aichat
|
||||||
RUN cargo build --release --target=x86_64-unknown-linux-musl
|
RUN cargo build --release --target=x86_64-unknown-linux-musl
|
||||||
|
|
||||||
@@ -20,8 +20,8 @@ RUN cp /home/aichat/aichat/target/x86_64-unknown-linux-musl/release/aichat /usr/
|
|||||||
|
|
||||||
USER aichat
|
USER aichat
|
||||||
RUN mkdir -p /home/aichat/.config/aichat
|
RUN mkdir -p /home/aichat/.config/aichat
|
||||||
|
ADD tools/gen_aichat_conf.sh /home/aichat/gen_aichat_conf.sh
|
||||||
|
|
||||||
ADD src/aichat/config.yaml /home/aichat/.config/aichat/config.yaml
|
|
||||||
ADD src/aichat/roles /home/aichat/.config/aichat/roles
|
ADD src/aichat/roles /home/aichat/.config/aichat/roles
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cat ~/.config/aichat/config.yaml | grep -v 'api_key' | sed "s/localhost/ollama/" | tee ~/.config/aichat/config.yaml.tmp
|
bash ~/gen_aichat_conf.sh > ~/.config/aichat/config.yaml
|
||||||
mv ~/.config/aichat/config.yaml.tmp ~/.config/aichat/config.yaml
|
|
||||||
|
|
||||||
aichat --serve 0.0.0.0
|
aichat --serve 0.0.0.0
|
||||||
|
|||||||
33
tools/gen_aichat_conf.sh
Executable file
33
tools/gen_aichat_conf.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
DEFAULT_MODEL=$(echo "${MODELS}" | cut -d',' -f2)
|
||||||
|
EMBEDDING_MODEL=$(echo "${MODELS}" | cut -d',' -f1)
|
||||||
|
if [[ -z ${EMBEDDING_MODEL} ]] || [[ -z ${DEFAULT_MODEL} ]]; then
|
||||||
|
echo "MODELS in .env are missing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "rag_embedding_model: ollama:${EMBEDDING_MODEL}
|
||||||
|
rag_chunk_size: 8192
|
||||||
|
rag_chunk_overlap: 409
|
||||||
|
model: ollama:${DEFAULT_MODEL}
|
||||||
|
temperature: 0
|
||||||
|
clients:
|
||||||
|
- type: openai-compatible
|
||||||
|
name: ollama
|
||||||
|
api_base: http://${OLLAMA_HOST}:11434/v1
|
||||||
|
api_key: ${LLM_API_KEY}
|
||||||
|
models:"
|
||||||
|
|
||||||
|
MODELS_LIST=$(echo "${MODELS}" | cut -d',' -f2- | tr ',' ' ')
|
||||||
|
for i in ${MODELS_LIST}; do
|
||||||
|
echo " - name: ${i}"
|
||||||
|
echo -n " max_input_tokens: "
|
||||||
|
curl -s "http://${OLLAMA_HOST}:11434/api/show" -H 'Authorization: Bearer 634e87c39907a94faa5f1618c9e501b1' -d "{\"model\": \"${i}\"}" | jq '.model_info | with_entries(select(.key | endswith(".context_length")))[]'
|
||||||
|
TOOLS=$(curl -s "http://${OLLAMA_HOST}:11434/api/show" -H 'Authorization: Bearer 634e87c39907a94faa5f1618c9e501b1' -d "{\"model\": \"${i}\"}" | jq -r .capabilities[] | grep tools)
|
||||||
|
if [[ -z "${TOOLS}" ]]; then
|
||||||
|
echo " supports_function_calling: false"
|
||||||
|
else
|
||||||
|
echo " supports_function_calling: true"
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user