From 7e4ed6816881dc4a4158456e0b8076b8f336b251 Mon Sep 17 00:00:00 2001 From: retoor Date: Fri, 28 Feb 2025 21:18:55 +0100 Subject: [PATCH] Added Liebranca. --- disk_usage.sh | 37 +++++++++++++++++++++++++++++++ liebranca.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 disk_usage.sh create mode 100644 liebranca.py diff --git a/disk_usage.sh b/disk_usage.sh new file mode 100755 index 0000000..615a3c1 --- /dev/null +++ b/disk_usage.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +echo "šŸ” Analyzing disk usage... Please wait." + +# 1. Show overall disk usage +echo -e "\nšŸ“Š Disk Usage Overview:" +df -h + +# 2. Show the largest directories in / +echo -e "\nšŸ“‚ Top 10 Largest Directories in Root (/):" +du -ahx / 2>/dev/null | sort -rh | head -10 + +# 3. Show the largest directories in /home +echo -e "\nšŸ  Top 10 Largest Directories in /home:" +du -ahx /home 2>/dev/null | sort -rh | head -10 + +# 4. Show the largest files over 1GB +echo -e "\nšŸ“„ Top 10 Largest Files Over 1GB:" +find / -type f -size +1G -exec ls -lh {} + 2>/dev/null | sort -k5 -rh | head -10 + +# 5. Check system logs +echo -e "\nšŸ“ Checking Large Log Files in /var/log:" +sudo du -sh /var/log/* 2>/dev/null | sort -rh | head -10 + +# 6. Find large installed packages (Debian-based) +if command -v dpkg-query &> /dev/null; then + echo -e "\nšŸ“¦ Top 10 Largest Installed Packages (Debian-based):" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rh | head -10 +fi + +# 7. Find large installed packages (RPM-based) +if command -v dnf &> /dev/null; then + echo -e "\nšŸ“¦ Top 10 Largest Installed Packages (Fedora-based):" + dnf list installed | awk '{print $2, $1}' | sort -rh | head -10 +fi + +echo -e "\nāœ… Disk Usage Analysis Completed!" diff --git a/liebranca.py b/liebranca.py new file mode 100644 index 0000000..c113fd4 --- /dev/null +++ b/liebranca.py @@ -0,0 +1,61 @@ +# Written by retoor@molodetz.nl + +# This script connects to a Pinecone assistant service and provides a command-line interface for user interaction. It includes functionality for creating or retrieving an assistant, handling chat messages, and uploading files to the assistant with specific metadata. + +# External library used: Pinecone, along with pinecone_plugins.assistant.models.chat for handling message interactions with the assistant. + +# MIT License + + +from pinecone import Pinecone +import os +import pathlib +import sys +from pinecone_plugins.assistant.models.chat import Message + +pc = Pinecone(api_key=os.environ.get('PINECONE_API_KEY')) + +ASSISTANT_NAME = "liebranca2" + +def get_or_create_assistant(assistant_name): + assistant = None + try: + assistant = pc.assistant.create_assistant( + assistant_name=assistant_name, + instructions="Your data is based on someone called Liebranka. Act as Liebranka and talk like Liebranca. Respond as Liebranca would do. You also are used to be called libry.", + region="us", + timeout=30 + ) + except Exception as e: + assistant = pc.assistant.Assistant(assistant_name=assistant_name) + return assistant + +assistant = get_or_create_assistant(ASSISTANT_NAME) + +def cli(): + messages = [] + while True: + messages.append(Message(role="user", content=input("> "))) + resp = assistant.chat(messages=messages) + print(resp['message']['content']) + +def upload(path, glob_pattern): + files = pathlib.Path(path).glob(glob_pattern) + for file in files: + try: + response = assistant.upload_file( + file_path=file.absolute(), + metadata={"document_type": "text"}, + timeout=None + ) + print(response) + except Exception as e: + print(e) + +if "--test" in sys.argv or "train" in sys.argv: + upload("/home/retoor/projects/drstats/export", "*Liebranca*") + upload("/home/retoor/projects/drstats/export", "*mentions*") + print("Training complete.") + exit() + +cli() \ No newline at end of file