Skip to content

Commit

Permalink
yay
Browse files Browse the repository at this point in the history
  • Loading branch information
adnan wahab committed Oct 21, 2024
1 parent 1416483 commit b0085bf
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 388 deletions.
154 changes: 66 additions & 88 deletions scripts/_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,80 @@

# Symlink each category into a data folder in the root of this git repo
#chmod +x scripts/*
ln -s ~/derp/actions ~/homelab_status_page/data/actions
ln -s ~/derp/cartoons ~/homelab_status_page/data/cartoons
ln -s ~/derp/comics ~/homelab_status_page/data/comics
ln -s ~/derp/embeddings ~/homelab_status_page/data/embeddings
ln -s ~/derp/intermediate_representation ~/homelab_status_page/data/intermediate_representation
ln -s ~/derp/logs ~/homelab_status_page/data/logs
# ln -s ~/derp/actions ~/homelab_status_page/data/actions
# ln -s ~/derp/cartoons ~/homelab_status_page/data/cartoons
# ln -s ~/derp/comics ~/homelab_status_page/data/comics
# ln -s ~/derp/embeddings ~/homelab_status_page/data/embeddings
# ln -s ~/derp/intermediate_representation ~/homelab_status_page/data/intermediate_representation
# ln -s ~/derp/logs ~/homelab_status_page/data/logs

ln -s ~/derp/sensor_data ~/homelab_status_page/data/sensor_data
# ln -s ~/derp/sensor_data ~/homelab_status_page/data/sensor_data

#!/bin/bash

# Script to clone and build specified Jetson containers

# Check if Git is installed
if ! command -v git &> /dev/null
then
echo "Git is not installed. Please install Git before running this script."
exit
fi

# Check if Docker is installed
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Please install Docker before running this script."
exit
fi

# Clone or update the jetson-containers repository
if [ ! -d "jetson-containers" ]; then
echo "Cloning jetson-containers repository..."
git clone https://github.com/dusty-nv/jetson-containers.git
else
echo "Updating jetson-containers repository..."
cd jetson-containers
git pull
cd ..
fi

cd jetson-containers
# if ! command -v git &> /dev/null
# then
# echo "Git is not installed. Please install Git before running this script."
# exit
# fi

# # Check if Docker is installed
# if ! command -v docker &> /dev/null
# then
# echo "Docker is not installed. Please install Docker before running this script."
# exit
# fi

# # Clone or update the jetson-containers repository
# if [ ! -d "jetson-containers" ]; then
# echo "Cloning jetson-containers repository..."
# git clone https://github.com/dusty-nv/jetson-containers.git
# else
# echo "Updating jetson-containers repository..."
# cd jetson-containers
# git pull
# cd ..
# fi


#cd jetson-containers

# List of package paths
packages=(
"packages/llm/ollama"
"packages/llm/llama_cpp"
"packages/llm/llama-factory"
"packages/llm/exllama"
"packages/vlm/llama-vision"
)

# Build each container
for package in "${packages[@]}"; do
echo "-----------------------------------------"
echo "Building container for $package"
cd "$package"

# Check if a build script exists
if [ -f "build.sh" ]; then
echo "Found build.sh, executing..."
chmod +x build.sh
./build.sh
elif [ -f "Dockerfile" ]; then
# Build the Docker image
image_name="${package##*/}"
echo "No build.sh found. Building Docker image: $image_name"
docker build -t "$image_name" .
else
echo "No build script or Dockerfile found in $package. Skipping..."
fi

cd - > /dev/null
done

echo "All containers have been built."
# packages=(
# "packages/llm/ollama"
# "packages/llm/llama_cpp"
# "packages/llm/llama-factory"
# "packages/llm/exllama"
# "packages/vlm/llama-vision"
# )

# # Build each container
# for package in "${packages[@]}"; do
# echo "-----------------------------------------"
# echo "Building container for $package"
# cd "$package"

# # Check if a build script exists
# if [ -f "build.sh" ]; then
# echo "Found build.sh, executing..."
# chmod +x build.sh
# ./build.sh
# elif [ -f "Dockerfile" ]; then
# # Build the Docker image
# image_name="${package##*/}"
# echo "No build.sh found. Building Docker image: $image_name"
# docker build -t "$image_name" .
# else
# echo "No build script or Dockerfile found in $package. Skipping..."
# fi

# cd - > /dev/null
# done

# echo "All containers have been built."

# https://github.com/dusty-nv/jetson-inference

Expand Down Expand Up @@ -508,30 +509,7 @@ echo "All containers have been built."


# Function to install and run Portainer
install_portainer() {
# Update package list and install dependencies
sudo apt-get update
sudo apt-get install -y docker.io

# Pull the latest Portainer image
sudo docker pull portainer/portainer-ce:latest

# Create a Docker volume for Portainer data
sudo docker volume create portainer_data

# Run Portainer container
sudo docker run -d \
--name=portainer \
--restart=always \
-p 8000:8000 \
-p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest

echo "Portainer installation and setup completed."
}

# l


# Call the functions to install Portainer and configure Caddy
Expand Down
4 changes: 1 addition & 3 deletions scripts/infra/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ hashirama.blog {
}

route /* {
reverse_proxy localhost:8080
reverse_proxy localhost:3333
}

/

# Add logging for this site
log {
output file /home/adnan/derp/log/caddy/hashirama.blog.log {
Expand Down
48 changes: 48 additions & 0 deletions scripts/init_containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# List of package paths
packages=(
"packages/llm/ollama"
"packages/llm/llama_cpp"
"packages/llm/llama-factory"
"packages/llm/exllama"
"packages/vlm/llama-vision"
)

# Store the initial directory
initial_dir=$(pwd)

# Build each container
for package in "${packages[@]}"; do
echo "-----------------------------------------"
echo "Building container for $package"

# Check if the directory exists
if [ ! -d "$package" ]; then
echo "Error: Directory $package does not exist. Skipping..."
continue
fi

# Change to the package directory
cd "$initial_dir/$package" || { echo "Error: Unable to change to directory $package. Skipping..."; continue; }

# Check if a build script exists
if [ -f "build.sh" ]; then
echo "Found build.sh, executing..."
chmod +x build.sh
./build.sh
elif [ -f "Dockerfile" ]; then
# Build the Docker image
image_name="${package##*/}"
echo "No build.sh found. Building Docker image: $image_name"
docker build -t "$image_name" .
else
echo "No build script or Dockerfile found in $package. Skipping..."
fi

# Return to the initial directory
cd "$initial_dir" || { echo "Error: Unable to return to initial directory. Exiting..."; exit 1; }
done

echo "-----------------------------------------"
echo "Container build process completed."
65 changes: 65 additions & 0 deletions web-ui/js/bun_handlers/ollama-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import fs from "fs";

async function runOllamaCommand(prompt) {
try {
const command = `ollama run llama2 "${prompt}"`;

const result = await Bun.spawn(["sh", "-c", command]).text();

const logEntry = {
timestamp: new Date().toISOString(),
prompt: prompt,
result: result
};

const logDir = "/derp/log";
const logFile = path.join(logDir, "llama.json");

if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true });
}

let logData = [];
if (fs.existsSync(logFile)) {
const existingLog = fs.readFileSync(logFile, "utf-8");
logData = JSON.parse(existingLog);
}

logData.push(logEntry);
fs.writeFileSync(logFile, JSON.stringify(logData, null, 2));
return result.trim();
} catch (error) {
console.error("Error running Ollama command:", error);
throw error;
}
}

export async function handleOllamaRequest(req) {
if (req.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });
}

try {
const { prompt } = await req.json();

if (!prompt) {
return new Response(JSON.stringify({ error: 'Prompt is required' }), {
status: 400,
headers: { 'Content-Type': 'application/json' }
});
}

const result = await runOllamaCommand(prompt);

return new Response(JSON.stringify({ result }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
} catch (error) {
console.error('Error in handleOllamaRequest:', error);
return new Response(JSON.stringify({ error: 'Internal server error' }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
}
5 changes: 2 additions & 3 deletions web-ui/js/bun_main_server.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

// proxy-server.

const port = 8000;


const port = 3333;
/// bun - dockerized + system or whateer
// --- this proxies to vite for app
//// --- this proxies to another bun or deno server for iteration /sanit
Expand Down Expand Up @@ -34,3 +32,4 @@ Bun.serve({
}
},
});
console.log("server running on port", port);
Loading

0 comments on commit b0085bf

Please sign in to comment.