fix(llm-script): make shuffle tool-friendly for OpenAI-style JSON (HA LLM integrations) - #131
Open
beralt85 wants to merge 1 commit into
Open
Conversation
…ibilityfix(llm-script): text shuffle field + bool() for LLM tool JSON compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the LLM Script for Music Assistant blueprint so the
shufflescript field works reliably when an LLM calls it via OpenAI-style function/tool JSON (e.g. Custom Conversation + LiteLLM + a local OpenAI-compatible server such as vLLM).Context
My goal was to have complete local voice control, without relying on external providers. Since the official LLM integrations do not allow the specification of a custom (local) OpenAI compatible endpoint, I was trying to use this script with this project: https://github.com/michelle-avery/custom-conversation .
While the LLM generated a valid tool call
.json(as specified by the script), the parsing of the boolean variable failed{"media_type": "artist", "artist": "Pink Floyd", "album": "", "media_id": "Pink Floyd", "media_description": "Pink Floyd", "shuffle": false}Changing this to a string and then adding the additional parsing as in this PR, resolved the problem.
Setup was vLLM backend running this model https://huggingface.co/btbtyler09/Qwen3-Coder-30B-A3B-Instruct-gptq-4bit.
More Details
Problem
Some Home Assistant LLM integrations (in particular: https://github.com/michelle-avery/custom-conversation) parse tool arguments against the script’s field schema. With
shuffledefined as a boolean selector, tool calls that include JSON booleans (e.g."shuffle": false) can fail with “Failed to parse tool arguments” even when the JSON is valid. The model output was observed streaming correctly; the failure happened when mapping arguments to the script fields.Solution
fields.shufflefrombooleantotextso string values from tool JSON are accepted.variablesstep (same idea as the previous| bool(false)), including support for common string forms ("true","1","yes","on")."true"/"false"when needed for compatibility.versionto20260416so instances can tell the blueprint changed.Testing
shuffle: false(boolean)shuffle: "false"(string)media_player.shuffle_setbehavior.Backward compatibility
shuffle: true/shuffle: falseas booleans should still work; the template treats native booleans like before and applies| boolat the end.shufflechanges from a toggle to a text field