Code prompts

Local AI Prompt Management Tool

Local AI prompt management tool.

Example code

Python
import json
import os
import hashlib
from datetime import datetime
import tkinter as tk
from tkinter import ttk, messagebox, scrolledtext
import tkinter.font as tkfont
from typing import Dict, List, Optional
import threading

class PromptManager:
    def __init__(self):
        self.data_file = "prompt_vault.json"
        self.prompts: List[Dict] = []
        self.categories = ["Dark", "Erotic", "Violent", "Surreal", "Taboo", "Cyberpunk", "Gothic", "Experimental", "Uncategorized"]
        self.load_data()
    
    def load_data(self):
        if os.path.exists(self.data_file):
            try:
                with open(self.data_file, 'r', encoding='utf-8') as f:
                    data = json.load(f)
                    self.prompts = data.get("prompts", [])
            except:
                self.prompts = []
        else:
            self.prompts = []
    
    def save_data(self):
        try:
            with open(self.data_file, 'w', encoding='utf-8') as f:
                json.dump({"prompts": self.prompts, "last_updated": datetime.now().isoformat()}, f, indent=2, ensure_ascii=False)
        except Exception as e:
            print(f"Save error: {e}")
    
    def generate_id(self, text: str) -> str:
        return hashlib.md5(text.encode('utf-8')).hexdigest()[:12]
    
    def add_prompt(self, content: str, style_tags: List[str], category: str = "Uncategorized", notes: str = "") -> Dict:
        prompt_id = self.generate_id(content)
        entry = {
            "id": prompt_id,
            "content": content.strip(),
            "style_tags": list(set(style_tags)),
            "category": category,
            "notes": notes,
            "created_at": datetime.now().isoformat(),
            "usage_count": 0
        }
        # Avoid duplicates
        if not any(p["content"] == entry["content"] for p in self.prompts):
            self.prompts.append(entry)
            self.save_data()
        return entry
    
    def search_prompts(self, query: str = "", category: str = "All", tags: List[str] = None) -> List[Dict]:
        results = self.prompts
        if category != "All":
            results = [p for p in results if p["category"] == category]
        
        if query:
            q = query.lower()
            results = [p for p in results if q in p["content"].lower() or 
                      any(q in tag.lower() for tag in p.get("style_tags", [])) or
                      q in p.get("notes", "").lower()]
        
        if tags and tags[0]:  # if tags provided
            results = [p for p in results if any(t.lower() in [tag.lower() for tag in p.get("style_tags", [])] for t in tags)]
        
        return sorted(results, key=lambda x: x.get("usage_count", 0), reverse=True)
    
    def increment_usage(self, prompt_id: str):
        for p in self.prompts:
            if p["id"] == prompt_id:
                p["usage_count"] = p.get("usage_count", 0) + 1
                self.save_data()
                break
    
    def delete_prompt(self, prompt_id: str):
        self.prompts = [p for p in self.prompts if p["id"] != prompt_id]
        self.save_data()
    
    def get_all_categories(self):
        return self.categories + list(set(p["category"] for p in self.prompts if p["category"] not in self.categories))

class ArtisticPromptVault(tk.Tk):
    def __init__(self):
        super().__init__()
        self.title("✧ VAULT OF WHISPERS ✧")
        self.geometry("1280x820")
        self.configure(bg="#0a0a0a")
        self.manager = PromptManager()
        
        # Custom fonts
        self.title_font = tkfont.Font(family="Georgia", size=28, weight="bold")
        self.body_font = tkfont.Font(family="Consolas", size=11)
        
        self.current_prompt = None
        self.build_ui()
        self.refresh_lists()
    
    def build_ui(self):
        # Main container with artistic padding
        main_frame = tk.Frame(self, bg="#0a0a0a", padx=30, pady=20)
        main_frame.pack(fill="both", expand=True)
        
        # Header
        header = tk.Label(main_frame, text="VAULT OF WHISPERS", 
                         font=self.title_font, fg="#ff4d94", bg="#0a0a0a")
        header.pack(pady=(0, 25))
        
        subtitle = tk.Label(main_frame, text="Local sanctuary for ambiguous, dangerous, and beautiful style prompts",
                           font=("Georgia", 11), fg="#888888", bg="#0a0a0a", wraplength=800)
        subtitle.pack(pady=(0, 30))
        
        # Paned window for split view
        paned = ttk.PanedWindow(main_frame, orient=tk.HORIZONTAL)
        paned.pack(fill="both", expand=True, padx=10)
        
        # LEFT: Library & Controls
        left_frame = tk.Frame(paned, bg="#111111", width=420, relief="flat", bd=0)
        left_frame.pack_propagate(False)
        
        # Search and filters
        filter_frame = tk.Frame(left_frame, bg="#111111")
        filter_frame.pack(fill="x", padx=15, pady=15)
        
        tk.Label(filter_frame, text="SEARCH THE ABYSS", font=("Georgia", 10), fg="#ff4d94", bg="#111111").pack(anchor="w")
        
        self.search_var = tk.StringVar()
        search_entry = tk.Entry(filter_frame, textvariable=self.search_var, font=self.body_font, 
                               bg="#1a1a1a", fg="#eeeeee", insertbackground="#ff4d94", relief="flat", bd=4)
        search_entry.pack(fill="x", pady=(5, 12))
        search_entry.bind("<KeyRelease>", lambda e: self.refresh_lists())
        
        # Category filter
        tk.Label(filter_frame, text="CATEGORY", font=("Georgia", 10), fg="#ff4d94", bg="#111111").pack(anchor="w")
        self.cat_var = tk.StringVar(value="All")
        cats = ["All"] + self.manager.get_all_categories()
        self.cat_combo = ttk.Combobox(filter_frame, textvariable=self.cat_var, values=cats, state="readonly")
        self.cat_combo.pack(fill="x", pady=(5, 15))
        self.cat_combo.bind("<<ComboboxSelected>>", lambda e: self.refresh_lists())
        
        # Add new prompt section
        tk.Label(left_frame, text="✦ INSCRIBE NEW PROMPT ✦", font=("Georgia", 12, "bold"), 
                fg="#ff99cc", bg="#111111").pack(anchor="w", padx=15, pady=(10, 5))
        
        tk.Label(left_frame, text="Content (the raw ambiguous style prompt):", 
                font=("Georgia", 9), fg="#aaaaaa", bg="#111111").pack(anchor="w", padx=15)
        
        self.new_content = scrolledtext.ScrolledText(left_frame, height=6, font=self.body_font,
                                                    bg="#1a1a1a", fg="#dddddd", wrap=tk.WORD, relief="flat")
        self.new_content.pack(fill="x", padx=15, pady=(3, 12))
        
        # Tags and category
        tag_frame = tk.Frame(left_frame, bg="#111111")
        tag_frame.pack(fill="x", padx=15)
        
        tk.Label(tag_frame, text="Style Tags (comma separated):", font=("Georgia", 9), fg="#aaaaaa", bg="#111111").grid(row=0, column=0, sticky="w")
        self.tags_var = tk.StringVar()
        tk.Entry(tag_frame, textvariable=self.tags_var, font=self.body_font, bg="#1a1a1a", fg="#eeeeee").grid(row=1, column=0, sticky="ew", pady=(2, 8))
        
        tk.Label(tag_frame, text="Category:", font=("Georgia", 9), fg="#aaaaaa", bg="#111111").grid(row=0, column=1, sticky="w", padx=(20, 0))
        self.new_cat_var = tk.StringVar(value="Uncategorized")
        cat_combo_new = ttk.Combobox(tag_frame, textvariable=self.new_cat_var, values=self.manager.categories, width=18)
        cat_combo_new.grid(row=1, column=1, sticky="ew", padx=(20, 0), pady=(2, 8))
        
        tk.Label(left_frame, text="Notes (optional context):", font=("Georgia", 9), fg="#aaaaaa", bg="#111111").pack(anchor="w", padx=15, pady=(12, 3))
        self.notes_text = scrolledtext.ScrolledText(left_frame, height=3, font=self.body_font,
                                                   bg="#1a1a1a", fg="#bbbbbb", wrap=tk.WORD)
        self.notes_text.pack(fill="x", padx=15, pady=(0, 15))
        
        add_btn = tk.Button(left_frame, text="✧ STORE IN THE VAULT ✧", command=self.add_new_prompt,
                           font=("Georgia", 12, "bold"), bg="#ff4d94", fg="#000000", relief="flat", height=2)
        add_btn.pack(fill="x", padx=15, pady=8)
        
        # Prompt list
        tk.Label(left_frame, text="STORED PROMPTS", font=("Georgia", 10), fg="#ff4d94", bg="#111111").pack(anchor="w", padx=15, pady=(20, 5))
        
        list_frame = tk.Frame(left_frame, bg="#111111")
        list_frame.pack(fill="both", expand=True, padx=15, pady=(0, 15))
        
        self.prompt_listbox = tk.Listbox(list_frame, font=self.body_font, bg="#1a1a1a", fg="#cccccc",
                                       selectbackground="#ff4d94", selectforeground="#000000", relief="flat")
        scrollbar = tk.Scrollbar(list_frame, orient="vertical", command=self.prompt_listbox.yview)
        self.prompt_listbox.configure(yscrollcommand=scrollbar.set)
        
        self.prompt_listbox.pack(side="left", fill="both", expand=True)
        scrollbar.pack(side="right", fill="y")
        self.prompt_listbox.bind("<<ListboxSelect>>", self.on_select_prompt)
        
        paned.add(left_frame, weight=1)
        
        # RIGHT: Preview & Usage
        right_frame = tk.Frame(paned, bg="#0f0f0f", relief="flat")
        
        tk.Label(right_frame, text="SELECTED PROMPT", font=("Georgia", 14, "bold"), fg="#ff99cc", bg="#0f0f0f").pack(anchor="w", padx=25, pady=(25, 8))
        
        self.preview_text = scrolledtext.ScrolledText(right_frame, height=12, font=("Georgia", 12), 
                                                     bg="#1a1a1a", fg="#ffddcc", wrap=tk.WORD, relief="flat", padx=15, pady=15)
        self.preview_text.pack(fill="both", expand=True, padx=25, pady=(0, 15))
        
        # Action buttons
        action_frame = tk.Frame(right_frame, bg="#0f0f0f")
        action_frame.pack(fill="x", padx=25, pady=10)
        
        copy_btn = tk.Button(action_frame, text="COPY TO CLIPBOARD", command=self.copy_to_clipboard,
                            font=("Georgia", 10, "bold"), bg="#333333", fg="#ff99cc", relief="flat", width=18)
        copy_btn.grid(row=0, column=0, padx=(0, 8))
        
        use_btn = tk.Button(action_frame, text="USE & INCREMENT", command=self.use_prompt,
                           font=("Georgia", 10, "bold"), bg="#ff4d94", fg="#000000", relief="flat", width=18)
        use_btn.grid(row=0, column=1, padx=(8, 0))
        
        delete_btn = tk.Button(action_frame, text="DELETE FROM VAULT", command=self.delete_selected,
                              font=("Georgia", 10, "bold"), bg="#330000", fg="#ff6666", relief="flat", width=18)
        delete_btn.grid(row=1, column=0, columnspan=2, pady=(12, 0), sticky="ew")
        
        # Stats
        self.stats_label = tk.Label(right_frame, text="", font=("Consolas", 9), fg="#555555", bg="#0f0f0f", justify="left")
        self.stats_label.pack(anchor="w", padx=25, pady=(15, 0))
        
        paned.add(right_frame, weight=2)
        
        # Footer
        footer = tk.Label(main_frame, text="Completely local • All prompts stored encrypted in spirit • Built with love for the ambiguous and forbidden",
                         font=("Georgia", 8), fg="#444444", bg="#0a0a0a")
        footer.pack(side="bottom", pady=15)
        
        # Style the combobox
        style = ttk.Style()
        style.theme_use('default')
        style.configure("TCombobox", fieldbackground="#1a1a1a", background="#222222", foreground="#eeeeee")
    
    def refresh_lists(self):
        self.prompt_listbox.delete(0, tk.END)
        query = self.search_var.get().strip()
        category = self.cat_var.get()
        
        results = self.manager.search_prompts(query, category if category != "All" else None)
        
        for prompt in results:
            tag_str = ", ".join(prompt.get("style_tags", [])[:3])
            if len(prompt.get("style_tags", [])) > 3:
                tag_str += "..."
            display = f"[{prompt['category']}] {prompt['content'][:65]}{'...' if len(prompt['content']) > 65 else ''} | {tag_str}"
            self.prompt_listbox.insert(tk.END, display)
        
        # Update category list occasionally
        if len(self.manager.prompts) % 5 == 0:
            cats = ["All"] + self.manager.get_all_categories()
            self.cat_combo['values'] = cats
    
    def add_new_prompt(self):
        content = self.new_content.get("1.0", tk.END).strip()
        if not content:
            messagebox.showwarning("Empty", "The vault hungers for content.")
            return
        
        tags_text = self.tags_var.get().strip()
        tags = [t.strip() for t in tags_text.split(",") if t.strip()]
        category = self.new_cat_var.get()
        notes = self.notes_text.get("1.0", tk.END).strip()
        
        self.manager.add_prompt(content, tags, category, notes)
        
        # Clear fields
        self.new_content.delete("1.0", tk.END)
        self.tags_var.set("")
        self.notes_text.delete("1.0", tk.END)
        
        self.refresh_lists()
        messagebox.showinfo("Success", "Prompt has been sealed within the vault.")
    
    def on_select_prompt(self, event=None):
        selection = self.prompt_listbox.curselection()
        if not selection:
            return
        
        index = selection[0]
        query = self.search_var.get().strip()
        category = self.cat_var.get()
        results = self.manager.search_prompts(query, category if category != "All" else None)
        
        if index < len(results):
            self.current_prompt = results[index]
            self.display_prompt(self.current_prompt)
    
    def display_prompt(self, prompt: Dict):
        self.preview_text.delete("1.0", tk.END)
        self.preview_text.insert(tk.END, prompt["content"])
        
        stats = f"ID: {prompt['id']}\n"
        stats += f"Category: {prompt['category']}\n"
        stats += f"Tags: {', '.join(prompt.get('style_tags', []))}\n"
        stats += f"Created: {prompt['created_at'][:10]}\n"
        stats += f"Used {prompt.get('usage_count', 0)} times"
        
        if prompt.get("notes"):
            stats += f"\n\nNotes: {prompt['notes']}"
        
        self.stats_label.config(text=stats)
    
    def copy_to_clipboard(self):
        if not self.current_prompt:
            return
        self.clipboard_clear()
        self.clipboard_append(self.current_prompt["content"])
        messagebox.showinfo("Copied", "The prompt has been copied to your clipboard.")
    
    def use_prompt(self):
        if not self.current_prompt:
            return
        self.manager.increment_usage(self.current_prompt["id"])
        self.copy_to_clipboard()
        self.refresh_lists()
        # Re-display to update count
        self.display_prompt(self.current_prompt)
    
    def delete_selected(self):
        if not self.current_prompt:
            return
        if messagebox.askyesno("Confirm Deletion", "Permanently exorcise this prompt from the vault?"):
            self.manager.delete_prompt(self.current_prompt["id"])
            self.current_prompt = None
            self.preview_text.delete("1.0", tk.END)
            self.stats_label.config(text="")
            self.refresh_lists()

if __name__ == "__main__":
    app = ArtisticPromptVault()
    app.mainloop()

Prompt

Use Python to write a complete local AI prompt management tool that can safely categorize and store various ambiguous style prompts. The interface design is simple and artistic, running completely locally.

Generator starting settings

Model
Uncensored Code
Mode
chat
View collection

Questions about this prompt

What is this AI code prompt about?

This prompt focuses on “Local AI Prompt Management Tool”: Local AI prompt management tool. It is ready to use for code generation on HackAIGC.

How do I use this prompt on HackAIGC?

Open the prompt, tap Use prompt or Copy prompt, then run it with your preferred model and settings.

What approach does this code prompt use?

Follow the creative direction in “Local AI Prompt Management Tool”: Local AI prompt management tool. Edit the prompt to change the tone, structure, or level of detail.

Can I edit this prompt before generating?

Yes. Copy the prompt text, modify details, then generate again on HackAIGC.