Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AI assistant plugin

This plugin adds a chat with a language model, in a tab of its own on the right of the window. The model can read the score you have open, write notes and tracks into it, run OxiGuitar’s tools, and answer your questions.

It is an early plugin, built partly to find what the plugin interface was still missing. The package repositories don’t suggest it, so you install it on purpose.

Plugins → AI Settings… chooses the server. How to use it walks through it.

Language models, in a few words

A language model (an LLM, the kind of program behind ChatGPT, Claude or Gemini) is a very large neural network trained on huge amounts of text to predict what comes next. Given a conversation, it writes a reply. It has no hands of its own: on its own it can only produce text.

Tool calling gives it hands. Along with your question, the plugin tells the model which actions it may take (“read bars 1 to 8 of track 2”, “write these notes into the bass track”, “run Transpose”) and how to ask for them. The model answers with a request for one of those actions, the plugin carries it out in OxiGuitar and sends back the result, and the model goes on until it has an answer for you. That is how it can read and change your score.

Models run either on your own computer, through a free program such as Ollama, llama.cpp or LM Studio, or on a company’s servers (OpenAI, Anthropic, Google and others), which you reach with an account and a key. Most of them, local or hosted, accept requests in the same shape, OpenAI’s chat completions format, so one plugin talks to all of them.

A local model keeps everything on your computer and costs nothing per question, but needs a capable computer and is usually smaller and less reliable with tools. A hosted model is stronger and needs no hardware, but your question and the parts of the score it reads leave your computer, and you pay for what you use.

Music and language models

A language model doesn’t hear. It reads a score written out as text and writes music back the same way, so it is better at structure (adding a bass line that follows the chords, filling a drum part, transposing, fixing bars that don’t add up) than at taste. Treat what it writes as a suggestion: listen to it, and undo it if it isn’t right.

How to use it

Set it up

  1. Start a model server, or get a key for a hosted one (see Which model below).
  2. Choose Plugins → AI Settings….
  3. Pick a preset under Server, such as Ollama on this computer or a hosted service, and change what you need: the host, the port, the key and the model.

  1. Click OK.

Ask

Open the AI tab on the right, type in the box at the bottom and press Enter, or click the paper plane beside the box. Ask about the song, or for a change: “write a bass line for bars 1 to 8”, “fit every bar to its time signature”, “transpose the whole song down a whole step”.

The conversation fills the tab. What you wrote is blue, on the left; what the model says is green, on the right, with the tools it used in smaller type and problems in red. Each message shows the time it was written. You can select any text in it and copy it with Ctrl + C or the right-click menu.

The box starts one line tall and grows as you type, up to a third of the tab. Shift + Enter starts a new line. To make it taller, drag the thin line just above it.

While the model works, the paper plane becomes a square: click it, or press Escape, to stop. The red circle starts a new chat. Everything the model changes in one answer is a single step called “AI: …”, so Edit → Undo takes it all back.

What you can do with it

  • Ask for music. The model can write bars into a track’s voice, add tracks, change time and key signatures, tempo and sections, and set the title.
  • Ask about a score. It reads an overview of the song and any bars of it.
  • Hand it routine work. It can run OxiGuitar’s tools, such as Transpose, Find Fingering, Fit Bars to Time Signature, Harmonize and Infer Key Signatures, and other plugins’ tools.

Everything the model changes in one answer is one change, named “AI: …”. Edit → Undo takes it all back.

Skills: your own habits

A skill is a note of your own that the model reads when it fits: how you like a blues shuffle written, that you never want the top string in a bass line, a rule such as “answer in Portuguese”. You write it once and every chat can use it. It matters most with a model on your computer, which doesn’t know your habits and has little room to spare.

Make a Markdown file in the skills folder, which sits beside your plugins folder:

SystemYour skills folder
Linux~/.local/share/oxiguitar/skills/
Linux, Flatpak~/.var/app/io.github.mateusrdp.OxiGuitar/data/oxiguitar/skills/
macOS~/Library/Application Support/OxiGuitar/skills/
Windows%APPDATA%\OxiGuitar\skills\

OxiGuitar makes the folder when it starts with this plugin installed. A skill is either NAME.md or a folder NAME/SKILL.md. It can begin with a header between two lines of ---:

---
name: blues-shuffle
description: How I write a 12-bar blues shuffle.
---
Write it in 4/4 with eighth-note swing: e/3 triplets, the first and
third of each group tied. Keep the bass on the low strings, a dominant
seventh on every chord.
  • name is what the model calls it. Without it, the file’s name (or the folder’s) is used.
  • description says when it applies, in a line. Without it, the first line of the text is used.
  • always: true puts the whole text in the model’s instructions for every request, for habits that hold everywhere. Leave it out for the rest.

The model is told each skill’s name and description and loads the text when your request fits, as the chat shows (“Read the skill …”). Ask for it by name if you want to be sure: “use my blues-shuffle skill”.

Things to know:

  • A skill’s file may hold up to 64 KiB, and at most 64 skills are used. A file that is empty, isn’t text or is too big is left out, and the chat says so.
  • If two folders hold a skill with the same name, yours wins over one a package installed.
  • Skills are read each time you send a message, so you can edit one while the chat is open.
  • A skill is sent to the server with your question, like the rest of the chat. With a server away from this computer, anything you write in a skill goes there once you have allowed that server.

Which model

Any server that speaks OpenAI’s chat completions protocol, with tool calling. On your own computer, that means Ollama, llama.cpp’s llama-server (start it with --jinja) and LM Studio. Hosted, with your own key, it means OpenAI, Anthropic, Google, OpenRouter, or any compatible server. The plugin doesn’t start a model for you.

Small local models call tools less reliably and write weaker music than large hosted ones. Pick a model that supports tool calling.

Your data

A server on your own computer is used at once. Before anything goes to a server anywhere else, the chat asks, naming the server. Only what you type and what the model reads of the score is sent, and only when you send a question. OxiGuitar itself never connects anywhere. This plugin does, as you set it up.

Keys are stored as typed in OxiGuitar’s settings.json, or read from an environment variable you name instead.

In the Flatpak

OxiGuitar’s Flatpak has no network access, so the plugin can’t reach even a server on your own computer. To allow it:

flatpak override --user --share=network io.github.mateusrdp.OxiGuitar

To take it away again, use --unshare=network.

Architecture and strategy

The plugin is a tab and a settings window. The core holds nothing of it: both are the plugin’s own Slint views (ui/ai.slint), which OxiGuitar shows with its own widgets and colours, and everything the model does goes through the interface’s score changes and tool calls.

There is one protocol, OpenAI’s chat completions. Presets fill in an address, but each part of it, which is the scheme, host, port, path, query, key header, model and more, is its own saved setting. HTTP uses ureq with rustls, and the root certificates come from Mozilla.

The model may run tools, and may move the caret or the selection. It may not use File menu entries, so files stay yours.

Current limitations

  • It reads and writes a compact text form of the score: notes and frets, rests, durations, ties, chords, dead notes and drums. Effects such as bends, slides, palm mutes and dynamics aren’t in it, so the model can’t see or write them; notes it writes get a plain mezzo-forte.
  • Small local models struggle. Tool calling and music both take a capable model. Small ones may call tools wrongly or write weak parts.
  • The conversation isn’t saved with the song.
  • No audio. The model never hears the song; it only reads the notes.

Left out on purpose

  • Running a model inside OxiGuitar. Bundling a model would make the download huge and tie it to one model. You run the one you like with a program made for it.
  • Being on by default. This is the one official plugin that can connect to the internet, so the package repositories don’t suggest it: you install it on purpose, and it asks before sending anything to a server that isn’t on your computer.
  • The File menu. The model can’t open, save, export or delete files. Your files stay yours.
  • Provider-specific protocols. One protocol, OpenAI’s chat completions, covers local servers and the big hosted ones alike, so there is one code path to keep right.

Where you can help

  • Prompts and tools. Better descriptions of the tools, or new ones, make every model better at the job (src/).
  • Testing models. Tell us which local and hosted models work well, and which don’t, with an example.
  • Effects in the text notation, starting with bends and slides, so the model can write expressive guitar parts (src/notation.rs).

Every change needs its tests and a row on the Features page; the Testing page says how to run them.

Requirements and assumptions

Requirements

  • OxiGuitar 0.25 or later (plugin interface 3.0). See the OxiGuitar manual.
  • A language model server, on your computer or hosted.
  • Windows, macOS or Linux.

Assumptions

  • You supply the server, the model and any key.
  • A model that supports tool calling is needed for anything beyond a plain conversation.
  • The model’s output is a suggestion. You can undo it and you should listen to it.

Installing

You need OxiGuitar first: its manual says how to get it. This page is about the AI assistant plugin.

From a release

Each release on the releases page has a zip for each system (Linux, Windows and macOS; Linux and Windows for x86_64 and ARM64), a .deb, an .rpm and a Flatpak for Linux, a setup program for Windows that installs for you alone (no administrator password), a .pkg for macOS that does the same, and a SHA256SUMS file to check the downloads against. Take the file that matches your system.

Copying the file yourself

A plugin is a single file ending in .oxp. Unzip the release for your system and put ai.oxp in your plugins folder:

SystemYour plugins folder
Linux~/.local/share/oxiguitar/plugins/
macOS~/Library/Application Support/OxiGuitar/plugins/
Windows%APPDATA%\OxiGuitar\plugins\

Start OxiGuitar again. Tools → Plugins… lists what it found. The same menu switches a plugin off, and deleting the file removes it.

On macOS, a plugin file you downloaded yourself may be refused as coming from an unverified developer. Clear the download mark and start OxiGuitar again:

xattr -d com.apple.quarantine ~/Library/Application\ Support/OxiGuitar/plugins/*.oxp

A plugin installed with the .pkg is not marked this way.

Linux package managers

The package is called oxiguitar-ai. It lives in a signed package repository on GitHub Pages that you add once.

Debian, Ubuntu and relatives:

sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.gpg -o /etc/apt/keyrings/oxiguitar.gpg
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.sources -o /etc/apt/sources.list.d/oxiguitar.sources
sudo apt update
sudo apt install oxiguitar-ai

Fedora and relatives:

sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.repo -o /etc/yum.repos.d/oxiguitar.repo
sudo dnf install oxiguitar-ai

Normal system updates keep the plugin current from then on.

OxiGuitar’s Flatpak is a sandbox that cannot see the system’s plugin folders, so it needs the plugin as a Flatpak extension. Flathub comes first because Flatpak takes its runtime from there:

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists oxiguitar https://mateusrdp.github.io/oxiguitar-packages/flatpak/oxiguitar.flatpakrepo
flatpak install oxiguitar io.github.mateusrdp.OxiGuitar.Plugin.ai

flatpak update keeps it current and flatpak remove takes it away.

Features and their tests

Everything the AI assistant plugin does, and the tests that check it. The test names are the ones cargo test prints. scripts/test-all.py fails when a feature here names no test, or names a test that doesn’t exist, so a new feature gets its row and its tests in the same pull request (the Testing page says how to run them).

The tests talk to a scripted server on 127.0.0.1 and to a stand-in for OxiGuitar; none needs a real model or the network.

FeatureWhat it doesTests
The chat tabA Slint panel (Chat in ui/ai.slint) that fills the tab: the conversation, each entry with its kind, words and local time (the user’s in blue on the left, the model’s in green on the right, problems in red), selectable and copyable; a server to allow asked as a question with Allow and Cancel icons; the input under it, one line to start, growing with the text and taller when its divider is dragged; Send (Stop while the model works) and New Chat as icons beside it; the model’s thinking is left out. Through OxiGuitar’s host, a question sent shows and clears the box, and with no server to ask it ends in a sentence.ui::chat::tests::the_view_shows_the_conversation, agent::tests::entries_are_stamped_with_the_time, ui::chat::tests::a_question_for_a_server_away_waits_and_new_chat_clears, ui::chat::tests::thinking_is_left_out_of_what_shows, contract::a_question_goes_through_the_host
Any chat completions serverOpenAI’s protocol: answers streamed in pieces or whole, tool calls, the model list; a server’s error is a sentence with a hint.client::tests::a_stream_brings_text_and_tool_calls_in_pieces, client::tests::a_stream_without_indexes_or_with_an_error_is_understood, client::tests::a_whole_answer_and_the_model_list_are_read, client::tests::server_errors_are_sentences_with_a_hint, agent::tests::a_whole_answer_and_a_servers_error_show_in_the_chat
Presets and the addressPresets fill the address; scheme, host, port, path and query each kept on its own; numbers checked; old settings take defaults.settings::tests::a_preset_fills_the_address_and_keeps_the_key_and_model, settings::tests::every_part_of_the_address_is_its_own, settings::tests::numbers_are_checked, settings::tests::settings_read_back_and_old_ones_take_defaults
Keys and headersThe key as typed, or from an environment variable the settings name; extra header lines.settings::tests::headers_carry_the_key_and_the_extra_lines, settings::tests::a_named_environment_variable_gives_the_key
Your dataA server on this computer is used at once; one elsewhere only after the user allows it, by name.settings::tests::only_this_computer_needs_no_permission, agent::tests::a_server_away_from_this_computer_needs_permission
Reading the scoreAn overview of the song (tracks, tunings, changes) and any bars, in the plugin’s text notation.notation::tests::the_overview_names_tracks_tunings_and_changes, notation::tests::bars_written_read_back_the_same, notation::tests::pitches_and_durations_read_and_write, notation::tests::keys_read_and_write
Writing musicBars into a track’s voice, new tracks, time and key signatures, tempo, sections and the song’s title, artist and album; wrong bars change nothing and say why, uneven ones are said.tools::tests::writes_are_kept_as_one_change_at_the_end, tools::tests::set_info_changes_the_title_artist_and_album, tools::tests::section_letters_count_on, notation::tests::wrong_bars_change_nothing_and_say_why, notation::tests::uneven_bars_are_written_and_said
Running OxiGuitar’s toolsThe model lists the core’s and other plugins’ tools, selects bars and runs them; the changes so far are handed back first.tools::tests::a_tool_of_oxiguitar_runs_after_the_changes_are_handed_back, tools::tests::the_tools_are_well_formed
One answer, one UndoEverything the model changes in one answer is one change named “AI: …”.tools::tests::writes_are_kept_as_one_change_at_the_end, agent::tests::a_turn_streams_calls_a_tool_and_keeps_the_change
The conversationA turn streams, calls tools and keeps the change; tool calls are described in words; the user’s instructions follow the plugin’s; New Chat starts over.agent::tests::a_turn_streams_calls_a_tool_and_keeps_the_change, agent::tests::tool_calls_are_described_in_words, agent::tests::the_users_instructions_follow_the_plugins, agent::tests::clearing_starts_a_new_conversation
SkillsMarkdown notes of the user’s own in the skills folder (NAME.md or NAME/SKILL.md, with an optional header): the model is told their names and descriptions and loads one with use_skill; always: true puts one in the instructions; files that are empty, too big or not text are left out and said; the user’s folder wins over a system one.skills::tests::a_header_names_and_describes_a_skill, skills::tests::without_a_header_the_file_names_it_and_the_first_line_describes_it, skills::tests::files_and_folders_load_and_the_first_name_wins, skills::tests::the_prompt_lists_what_is_on_request_and_holds_what_always_applies, tools::tests::the_model_loads_a_skill_by_name, agent::tests::a_skill_is_listed_then_loaded_when_the_model_asks, agent::tests::the_skills_come_after_the_plugins_instructions_and_before_the_users
Mistakes are sentencesA wrong tool call gets a sentence the model can act on, never a crash.tools::tests::mistakes_are_sentences_for_the_model
The settings windowA Slint window (SettingsWindow in ui/ai.slint) in six tabs: a preset fills the texts; what is typed counts and isn’t set back under the caret; the key is hidden unless shown; models and allowed servers are picked from lists; a number that isn’t one is said and the rest kept; Cancel forgets.ui::settings_window::tests::a_preset_fills_the_texts_and_cancel_forgets, ui::settings_window::tests::a_number_that_isnt_one_is_said_and_the_rest_kept, ui::settings_window::tests::models_and_allowed_servers_are_picked_from_lists, links::tests::only_web_addresses_are_opened
The views compileui/ai.slint compiles as OxiGuitar compiles it, with every property and callback the chat and the window use.tests::the_slint_file_has_what_the_views_set_and_hear
A working plugin fileThe .oxp file keeps the plugin contract, with this repository’s SDK version and with the newest release of OxiGuitar.contract::the_plugin_file_keeps_the_contract, tests::the_manifest_is_valid_for_the_plugin, oxiguitar_plugin_checks::the_manifest_matches_the_plugin, stage:contract (latest core)

Testing

Every test of this repository runs with one command, on your own machine, and anyone can run it. When something fails, it tells you how to report it.

Run everything

python3 scripts/test-all.py

On Windows, type python instead of python3 if that’s what you have.

You need:

  • Rust, from rustup (the version in Cargo.toml’s rust-version or newer);
  • git, and Python 3.8 or newer (nothing to install with pip);
  • on Linux, the libraries a build needs: libasound2-dev, libpipewire-0.3-dev and libclang-dev on Debian and Ubuntu (alsa-lib-devel, pipewire-devel and clang-devel on Fedora);

It runs:

  1. every Rust test of the repository (cargo test over the whole workspace), with a progress bar;
  2. the plugin against the newest release of OxiGuitar: it fetches that release’s source with git (once per release, kept in a cache folder every OxiGuitar repository on your machine shares: ~/.cache/oxiguitar-test-all, ~/Library/Caches/oxiguitar-test-all on macOS, %LOCALAPPDATA%\oxiguitar-test-all on Windows, or OXIGUITAR_TEST_CACHE), builds its oxiguitar-cli and oxiguitar-plugin-test, builds this repository’s plugin file for your system and runs the plugin contract on it;
  3. a check of the Features page: every feature names a test, and every test it names exists.

It tests the system and processor it runs on, and only those (as Rust sees them: rustc -vV’s host). Tests for other systems are left out and the summary says so; they are not failures.

What you get

A line per stage while it runs, then the result. In target/test-all/<date>-<time>/:

  • summary.md: the result, your system, what failed and why, short enough to paste into a GitHub issue;
  • test-all.log: everything that happened, every command and its output;

The script exits with 0 when everything passed, 1 when something failed, and 2 when it couldn’t start.

When something fails

  1. Update to the newest develop (git checkout develop && git pull) and run it again: it may be fixed already.
  2. Look for an issue about the same test at github.com/mateusrdp/oxiguitar-ai/issues.
  3. Otherwise open one: call it test-all: <the first failing test>, paste the whole summary.md, and attach test-all.log (drag it onto the text box; zip it first if it’s over 25 MB). Read the log first: it has your folder names, so change anything you’d rather keep private.
  4. You can also give summary.md and test-all.log to a language model along with this repository and ask it to find the cause.

Options

  • --release: an optimised test build: slower to build, faster corpus tests.
  • --ignore-rust-version: for a Rust older than rust-version (unsupported, but handy).
  • --core DIR: test against a checkout of OxiGuitar you already have, instead of its newest release; --core-version v0.21.5 picks a release.
  • --out DIR: where the results go.

Adding a feature

A new feature comes with its tests and a row on the Features page, in the same pull request; a new corpus test uses tests/support/corpus.rs. The script fails until the row names tests that exist.

Credits

Thank you to the people whose work this plugin is built on.

Code we use

ProjectAuthorsWhat it does hereLicence
OxiGuitar’s plugin SDK (oxiguitar-plugin, and oxiguitar-host and oxiguitar-plugin-test for the tests)Mateus Rocha de Paula and the OxiGuitar contributorsThe plugin interface, and OxiGuitar’s own host to test againstMIT OR Apache-2.0
ureqMartin Algesten, Jacob Hoffman-Andrews and contributorsHTTP requests to the model serverMIT OR Apache-2.0
RustlsThe Rustls contributorsEncrypted connections (HTTPS)Apache-2.0 OR ISC OR MIT
ringBrian Smith and contributorsThe cryptography under RustlsApache-2.0 AND ISC
webpki-rootsThe Rustls contributors, from Mozilla’s listThe trusted root certificatesCDLA-Permissive-2.0
serde and serde_jsonErick Tryzelaar, David Tolnay and contributorsReading and writing the protocol’s JSONMIT OR Apache-2.0
jiffAndrew Gallant and contributorsThe local time each message of the chat showsUnlicense OR MIT
Rust and its standard libraryThe Rust ProjectEverything elseMIT OR Apache-2.0

Standards and services

The protocol is OpenAI’s chat completions format with tool calling, as implemented by many servers: Ollama, llama.cpp, LM Studio and the hosted services. The plugin works with them; it has nothing to do with the companies behind them.

Tools

ToolUse
mdBookBuilds this manual
cargo-denyChecks the licences of everything we build with

Thanks

To the people who build open model servers that anyone can run on their own computer, and to everyone who tries this plugin and tells us what worked.