Removing Friction from Fabric AI CLI with AutoHotkey

Removing Friction from Fabric AI CLI

AutoHotkey (AHK) is an incredibly powerful tool that has become integral to my computer life. With my recent set up of Fabric and Ollama, I've noticed a substantial reduction in friction when working with AI-powered tools. For those interested in installing Fabric locally on Windows, detailed instructions can be found in Fabric AI Made Easy - Direct Installation on (Windows). Having successfully set up Fabric and Ollama, my focus has shifted to automating and integrating them with my AHK and StreamDeck setup to further streamline my workflow.

The Final Result

Here's what I've ended up with:

FabricAI(prompt, pattern, model) {
    terminalTitle := "Fabric_Powershell"
    instance := 1
    top_p := 1 ; Default value for top_p
    temp := 0.4 ; Default value for temp
    while WinExist(terminalTitle . (instance > 1 ? "_" . instance : "")) {
        instance++
    }
    if (instance > 1) {
        terminalTitle .= "_" . instance
    }
    try {
        Run "C:\Users\" . A_UserName . "\AppData\Local\Microsoft\WindowsApps\wt.exe --title " . terminalTitle
    } catch Error as e {
        MsgBox("Error launching Windows Terminal:`n`n" . e.Message)
        return
    }
    WinWait(terminalTitle)
    if WinExist(terminalTitle) {
        WinActivate(terminalTitle)
        cmd := "clear; ollama ps; echo " . (prompt == "Get-Clipboard" ? "$(Get-Clipboard)" : prompt)
        cmd .= " | fabric --pattern " . pattern
        cmd .= (model != "" ? " --model " . model : "")
        cmd .= " --stream"
        cmd .= " --top_p " . top_p
        cmd .= " --temp " . temp
        SendInput(cmd . "{Enter}")
    }
}

The provided code snippet has been integrated into my setup for Hotkeyless AHK, a tool that enables workflow optimizations and general improvements. I highly recommend it, as it can ease a LOT of the burdens that come with a dynamic AutoHotkey system.

I've even exposed it to Flow Launcher, allowing me to either write in the functions I want to run or simply press a button on my StreamDecks.

As a side note, I've recently updated Hotkeyless AHK to include additional features, such as support for parameters. This update enables processing of various data types, including strings, integers, floats, boolean values, arrays, objects, and nulls. The project has also been adapted to work with AHK v2. You can review the changes at this pull request.

Hi Res Studios (Hi-Rez Studios) ✅ 📄