Skip to content

Commit fa046b2

Browse files
authored
Merge pull request #41 from music-assistant/TheFes-20250122-split_llm_prompt
Split LLM prompt for LLM Enhanced automation
2 parents 238de73 + c4af0ec commit fa046b2

File tree

1 file changed

+104
-34
lines changed

1 file changed

+104
-34
lines changed

llm-enhanced-local-assist-blueprint/mass_llm_enhanced_assist_blueprint_en.yaml

Lines changed: 104 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,10 @@ blueprint:
260260
selector:
261261
boolean: {}
262262
default: true
263-
llm_prompt:
264-
name: LLM query prompt
263+
llm_prompt_intro:
264+
name: Introduction for LLM prompt
265265
description:
266-
The prompt which will be used to the LLM can provide the correct
267-
data for the Music Assistant play media action
266+
Introduction for the LLM to understand the goal of the conversation
268267
selector:
269268
text:
270269
multiline: true
@@ -281,10 +280,17 @@ blueprint:
281280
Here is the structured JSON that I expect in response {"action_data":
282281
{"media_id":"name", "media_type":"type", "artist":"name", "album":"name"},
283282
"media_description": "description of media", "target_data", {"areas":
284-
["area name"], "players": ["player name"]}}
285-
286-
287-
The argument "media_type" is mandatory and must always be provided no
283+
["area name"], "players": ["player name"]}}'
284+
llm_prompt_media_type:
285+
name: Media type LLM prompt
286+
description:
287+
Explanation about the "media_type" parameter in the output
288+
selector:
289+
text:
290+
multiline: true
291+
multiple: false
292+
default:
293+
'The argument "media_type" is mandatory and must always be provided no
288294
matter what!
289295
290296
"media_type" can only be one of 5 different values:
@@ -302,10 +308,17 @@ blueprint:
302308
media_type is mandatory and must always be provided. In case a request
303309
does not match any of these types, for example when music from a specific
304310
genre is requested, then use "track" and provide a list of matching songs
305-
for the "media_id" parameter.
306-
307-
308-
The argument "media_id" is also mandatory and must always be provided
311+
for the "media_id" parameter.'
312+
llm_prompt_media_id:
313+
name: Media ID LLM prompt
314+
description:
315+
Explanation about the "media_id" paramter in the output
316+
selector:
317+
text:
318+
multiline: true
319+
multiple: false
320+
default:
321+
'The argument "media_id" is also mandatory and must always be provided
309322
no matter what!
310323
311324
media_id is the most specific from track, album, and artist.
@@ -329,20 +342,34 @@ blueprint:
329342
330343
- If the search is a radio channel: Then media_id is the requested channel.
331344
332-
"media_id" is a mandatory argument and must always be provided.
333-
334-
335-
If case it is needed, the fields "artist" and "album" can be used to further
345+
"media_id" is a mandatory argument and must always be provided.'
346+
llm_prompt_artist_album:
347+
name: Artist and album LLM prompt
348+
description:
349+
Explanation about the "album" and "artist" parameters in the output
350+
selector:
351+
text:
352+
multiline: true
353+
multiple: false
354+
default:
355+
'In case it is needed, the fields "artist" and "album" can be used to further
336356
restrict the search.
337357
338358
For example, if the input is "Hells Bells by ACDC", then the output should
339359
be {"media_id":"Hells Bells", "media_type":"track", "artist":"AC/DC"}
340360
341361
"artist" and "album" are optional and never used in the case of a playlist
342-
search.
343-
344-
345-
There can be several types of answers for the "action_data" dictionary.
362+
search.'
363+
llm_prompt_examples:
364+
name: Examples action data LLM prompt
365+
description:
366+
Examples for the "action_data" of the output
367+
selector:
368+
text:
369+
multiline: true
370+
multiple: false
371+
default:
372+
'There can be several types of answers for the "action_data" dictionary.
346373
Here are some examples:
347374
348375
Just an artist >> {"media_id": "artist name", "media_type":"artist"}.
@@ -364,17 +391,31 @@ blueprint:
364391
song name"], "media_type":"track"}.
365392
366393
Multiple tracks of the same artist >> {"media_id": ["Song name", "Another
367-
song name"], "artist": "artist name", "media_type":"track"}
368-
369-
370-
The "media_description" key is used to describe the media which will be
394+
song name"], "artist": "artist name", "media_type":"track"}'
395+
llm_prompt_media_description:
396+
name: Media description LLM prompt
397+
description:
398+
Explanation on the "media_description" part of the output
399+
selector:
400+
text:
401+
multiline: true
402+
multiple: false
403+
default:
404+
'The "media_description" key is used to describe the media which will be
371405
played. This can be taken from the voice command query, but it should
372406
be only the part which is relevant for the media. So if the voice request
373407
is "Play the best Queen songs on the living room player" the value for
374-
"media_description" should be "the best Queen songs"
375-
376-
377-
The "target_data" key is used to define the information on which the request
408+
"media_description" should be "the best Queen songs"'
409+
llm_prompt_target:
410+
name: Target data LLM prompt
411+
description:
412+
Explanation of the "target_data" part of the output
413+
selector:
414+
text:
415+
multiline: true
416+
multiple: false
417+
default:
418+
'The "target_data" key is used to define the information on which the request
378419
should be played.
379420
380421
{% if expose_areas %}These are the area names which have a Music Assantant
@@ -409,17 +450,37 @@ blueprint:
409450
as area name. Besides removing the first article, use exactly what was
410451
provided in the request.{% endif %}When no player is mentioned in the
411452
voice request{% if expose_players %} or no player could be matched {%
412-
endif %}, use {"players":[]}
413-
414-
415-
Note that the input query can be in a different language. For the "media_type"
453+
endif %}, use {"players":[]}'
454+
llm_prompt_outro:
455+
name: Outro for LLM prompt
456+
description:
457+
Some final notes with additional explanation for the LLM
458+
selector:
459+
text:
460+
multiline: true
461+
multiple: false
462+
default:
463+
'Note that the input query can be in a different language. For the "media_type"
416464
the untranslated English terms should be used, in case of a playlist search
417465
use the language used in the input.
418466
419467
420468
IMPORTANT: You must reply with only the JSON model, nothing before nor
421469
after because your response will be processed by a search component of
422470
a media player service. So also no code tags. Only the JSON!'
471+
llm_prompt:
472+
name: Legacy LLM prompt setting
473+
description:
474+
This field contains the LLM prompt set before the prompt settings were split into
475+
multiple parts. By default it will be empty, it will only contain text in case
476+
you were using the automation before this LLM prompt settins were split. If this
477+
setting contains the prompt, you can use it to copy back changes to the relevant
478+
part above, as this prompt setting will not be used in the automation
479+
selector:
480+
text:
481+
multiline: true
482+
multiple: false
483+
default: ''
423484
triggers:
424485
- alias: Trigger to request for music
425486
trigger: conversation
@@ -429,7 +490,15 @@ actions:
429490
variables:
430491
expose_areas: !input expose_areas
431492
expose_players: !input expose_players
432-
play_continuously: !input play_continuously
493+
prompt:
494+
intro: !input llm_prompt_intro
495+
media_type: !input llm_prompt_media_type
496+
media_id: !input llm_prompt_media_id
497+
artist_album: !input llm_prompt_artist_album
498+
examples: !input llm_prompt_examples
499+
description: !input llm_prompt_media_description
500+
target: !input llm_prompt_target
501+
outro: !input llm_prompt_outro
433502
area_names:
434503
"{{ integration_entities('music_assistant') | map('area_name')
435504
| join(', ') }}"
@@ -439,12 +508,13 @@ actions:
439508
- alias: Send the request to the LLM
440509
action: conversation.process
441510
data:
442-
text: !input llm_prompt
511+
text: "{{ prompt.values() | join('\n\n') }}"
443512
agent_id: !input llm_agent
444513
response_variable: result
445514
- alias: Store relevant part of LLM result in variable and define target
446515
variables:
447516
llm_result: "{{ result.response.speech.plain.speech | from_json }}"
517+
play_continuously: !input play_continuously
448518
llm_action_data:
449519
media_id: "{{ llm_result.action_data.media_id }}"
450520
media_type: "{{ llm_result.action_data.media_type }}"

0 commit comments

Comments
 (0)