Initial commit: agent-inference service

Moved from gnommoweb/agent-inference. Generic LLM inference bridge
supporting litellm (anthropic/openai/ollama/lm_studio), Agent Zero MCP,
and Hermes JSON-RPC WebSocket agent types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 17:41:29 +02:00
commit bc8631c49b
6 changed files with 799 additions and 0 deletions
Executable
+110
View File
@@ -0,0 +1,110 @@
#!/bin/bash
# dev.sh - Run Agent inference inference service locally
#
# Usage:
# ./dev.sh [--port <port>]
#
# Options:
# --port N Port to listen on (default: 8089)
#
# Requires: Python 3, pip (installs deps from requirements.txt if missing)
# Logs are written to ./dev.log in this directory.
set -e
# ── Parse arguments ────────────────────────────────────────────────────────────
PORT=8089
while [[ $# -gt 0 ]]; do
case "$1" in
--port) PORT="$2"; shift 2 ;;
*) echo "Unknown option: $1" >&2; exit 1 ;;
esac
done
# ── Setup ─────────────────────────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="$SCRIPT_DIR/dev.log"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() {
local color="$1"; shift
echo -e "${color}$*${NC}"
echo "$*" >> "$LOG_FILE"
}
echo "=== dev.sh started $(date -u '+%Y-%m-%d %H:%M:%S UTC') ===" > "$LOG_FILE"
echo "Service: agent-inference Port: ${PORT}" >> "$LOG_FILE"
log "$GREEN" "Starting Agent inference inference service on port ${PORT}..."
log "$GREEN" " Log file : ${LOG_FILE}"
# Pull latest changes
log "$GREEN" "Pulling latest changes..."
git -C "$SCRIPT_DIR" pull --ff-only >> "$LOG_FILE" 2>&1 \
|| log "$YELLOW" "Warning: git pull failed — continuing with local state"
# ── Python environment ─────────────────────────────────────────────────────────
if [ ! -d "$SCRIPT_DIR/.venv" ]; then
log "$YELLOW" "Creating virtual environment..."
python3 -m venv "$SCRIPT_DIR/.venv" >> "$LOG_FILE" 2>&1
fi
source "$SCRIPT_DIR/.venv/bin/activate"
if [ -f "$SCRIPT_DIR/requirements.txt" ]; then
log "$GREEN" "Installing dependencies..."
pip install -q -r "$SCRIPT_DIR/requirements.txt" >> "$LOG_FILE" 2>&1
fi
# ── Load .env ──────────────────────────────────────────────────────────────────
if [ -f "$SCRIPT_DIR/.env" ]; then
log "$GREEN" "✓ Loading .env file"
set -a
source "$SCRIPT_DIR/.env"
set +a
fi
export AGENT_INFERENCE_PORT="$PORT"
# ── Cleanup trap ───────────────────────────────────────────────────────────────
cleanup() {
echo ""
log "$YELLOW" "Shutting down Agent inference inference..."
kill $SERVER_PID 2>/dev/null || true
echo "=== dev.sh stopped $(date -u '+%Y-%m-%d %H:%M:%S UTC') ===" >> "$LOG_FILE"
exit 0
}
trap cleanup SIGINT SIGTERM
# ── Start server ───────────────────────────────────────────────────────────────
log "$GREEN" "Starting uvicorn on port ${PORT}..."
cd "$SCRIPT_DIR"
uvicorn server:app --host 0.0.0.0 --port "$PORT" --reload >> "$LOG_FILE" 2>&1 &
SERVER_PID=$!
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN} Agent inference inference is running!${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo -e " Service : ${YELLOW}http://localhost:${PORT}${NC}"
echo -e " Health : ${YELLOW}http://localhost:${PORT}/health${NC}"
echo -e " Log file : ${YELLOW}${LOG_FILE}${NC}"
echo ""
echo -e " Press ${RED}Ctrl+C${NC} to stop"
echo ""
wait