Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces ignored in sentence matching #92

Open
abmantis opened this issue Dec 29, 2023 · 2 comments
Open

Spaces ignored in sentence matching #92

abmantis opened this issue Dec 29, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@abmantis
Copy link

abmantis commented Dec 29, 2023

Spaces are being ignored when matching words. For example:

Sentence: adiciona <item> a [minha ]lista
Test input: adiciona batatas à minha lista

Current item match: batatas à minh
Expected match: nothing (notice that it has an 'à' and not 'a' in the test input)

The following sentence also results in the same match: adiciona <item> (a|à) [minha ]lista
But this will work as expected: adiciona <item> (à|a) [minha ]lista

@synesthesiam synesthesiam added the bug Something isn't working label Jan 4, 2024
@synesthesiam synesthesiam self-assigned this Jan 4, 2024
@abmantis
Copy link
Author

abmantis commented Feb 27, 2024

This is manifesting in HA now, despite passing in the tests with the current "pt" sentence: <verbos> <item> (na|à|a) <lista>

hassil's recongnize_all returns the following two results:

{
  "text": "coloca batatas na lista",
  "match": true,
  "intent": "HassShoppingListAddItem",
  "slots": {
    "item": "batatas "
  },
  "context": {},
  "response_key": "item_added",
  "response": "Adicionei batatas"
}
{
  "text": "coloca batatas na lista",
  "match": true,
  "intent": "HassShoppingListAddItem",
  "slots": {
    "item": "batatas n"
  },
  "context": {},
  "response_key": "item_added",
  "response": "Adicionei batatas n"
}

HA is using the later.

@OzGav
Copy link

OzGav commented Apr 11, 2024

Similar issue that I was asked to add here from Discord

I am playing with JLo's MA AI automation to enable a random song to be be played given a starting track and also enabling playback to a specified speaker but I have run into a problem where the parser doesn't seem to be following the sentence structure. For a start here is the modified blueprint

blueprint:
  name: Play Music on Music Assistant
  description: "Play any music you want on any Music Assistant speaker\nRequirements:\n
    \ - Media Player coming from the Music Assistant integration\n  - OpenAI Conversation
    **configured with the prompt found [here](https://gist.github.com/jlpouffier/8d5dc8a6b94f42f4929bfd1df2f22008)**\n"
  domain: automation
  author: JLo
  homeassistant:
    min_version: 2023.8.0
  input:
    assist_command:
      name: Assist Command
      description: "The Assist command you will use to start the music\nYou can change
        the overall sentence to match your style and language. \n**WARNING** you **MUST**
        include {query} in order to pass that variable to OpenAI.\n"
      default: Give me {query} on [the] {name}
      selector:
        text: {}
    open_ai_config_entry:
      name: OpenAI Configuration
      description: The OpenAI configuration **configured with the prompt found [here](https://gist.github.com/jlpouffier/8d5dc8a6b94f42f4929bfd1df2f22008)**
      selector:
        config_entry:
          integration: openai_conversation
    media_player:
      name: Media player
      description: Media player that will play the music
      selector:
        entity:
          filter:
          - integration: mass
            domain:
            - media_player
          multiple: false
    additional_conditions:
      name: Additional conditions
      description: "Extra conditions you may want to add to this automation \n(Example:
        Home occupied, Speaker on, etc)\n"
      default: []
      selector:
        condition: {}
  source_url: https://github.com/jlpouffier/home-assistant-config/blob/master/blueprints/automation/perso/play_media_on_music_assistant.yaml
trigger:
- platform: conversation
  command: !input assist_command
condition: !input additional_conditions
action:
- service: conversation.process
  data:
    agent_id: !input open_ai_config_entry
    text: '{{trigger.slots.query}}'
  response_variable: response_from_ai
- service: mass.play_media
  data: '{{response_from_ai.response.speech.plain.speech|from_json}}'
  target:
    entity_id: "{{ expand(states.media_player) | selectattr('name' , 'search', trigger.slots.name, ignorecase=true ) | select('search', 'ma_') | map(attribute='entity_id') | join }}"
mode: single

When I typed in this: give me a song like eve of destruction on the study player the automation trace showed query was resolved as a song like eve of destructi and name resolved as on the study player

To be clear if I type give me a song like gimme shelter on study player it works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants