Azure-Samples / azure-search-power-skills

A collection of useful functions to be deployed as custom skills for Azure Cognitive Search
MIT License
283 stars 168 forks source link

Azure Cog Search Skillset Error or bad doc? #131

Closed evogelpohl closed 1 year ago

evogelpohl commented 1 year ago

Get this error when adding the Azure Function from this repo (https://github.com/Azure-Samples/azure-search-power-skills/tree/main/Vector/EmbeddingGenerator) to the Azure Cognitive Search Service as a skillset, as noted in the documentation.

ERROR: The request is invalid. Details: Incompatible type kinds were found. The type 'Microsoft.Skills.Custom.WebApiSkill' was found to be of kind 'Complex' instead of the expected kind 'Entity'.

This issue is for a: (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. Deploy the function as noted here: https://github.com/Azure-Samples/azure-search-power-skills/tree/main/Vector/EmbeddingGenerator (no errors - i AM able to run a CODE+TEST run in the Portal UI after it enabled CORS. Got the vector output successfully)
  2. Go to function, click 'code + test, click Get Function URL, paste into sample skill as provided on EmbeddingGenerator READMD doc.
  3. Open Azure Cog Search (existing), click skillsets, add the code from the README doc for the search-power-skills to insert the azure fn into the Cog Search pipeline, changing the URL as copied.
  4. Click Save, get error noted above.

Any log messages given by the failure

Expected/desired behavior

It works

OS and Version?

N/a. Azure PaaS services

Versions

N/a

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Careyjmac commented 1 year ago

I answered this question on StackOverflow as well, but you need to add the skill in context of a skillset resource, so within the skills array of the JSON object. So basically it should be like this:

{
  "name": "**skillset name here**",
  "description": "",
  "skills": [
        {
    "@odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
    "description": "Acronym linker",
    "uri": "https://**my_func_url_with_default_key_here**",
    "batchSize": 1,
    "context": "/document/content",
    "inputs": [
        {
            "name": "document_id",
            "source": "/document/document_id"
        },
        {
            "name": "text",
            "source": "/document/content"
        },
        {
            "name": "filepath",
            "source": "/document/file_path"
        },
        {
            "name": "fieldname",
            "source": "='content'"
        }
    ],
    "outputs": [
        {
            "name": "chunks",
            "targetName": "chunks"
        }
    ]
}
    ],
  "cognitiveServices": {
    "@odata.type": "#Microsoft.Azure.Search.DefaultCognitiveServices"
  }
}