Reputation: 11
I am working on integrating Azure OpenAI's embedding skill into my skillset for Azure Cognitive Search, but I'm encountering a RestError when I try to create or update the skillset. The splitSkill works fine, but the embeddingSkill throws an error despite the resourceUri being correctly set.
Here's the error message I receive:
Failed to create or update skillset: RestError: One or more skills are invalid. Details: Error in skill 'Azure OpenAI Embedding skill': 'uri' parameter cannot be null or empty
{
"name": "RestError",
"code": "",
"statusCode": 400,
"request": {
"url": "https://ai-search-service-dev-basic.search.windows.net/skillsets('samplel-skillset')?api-version=2023-11-01",
"headers": {
"content-type": "application/json",
"accept": "application/json;odata.metadata=minimal",
"prefer": "REDACTED",
"accept-encoding": "gzip,deflate",
"user-agent": "azsdk-js-search-documents/12.0.0 core-rest-pipeline/1.12.2 Node/v21.6.2 OS/(arm64-Darwin-23.2.0)",
"x-ms-client-request-id": "818afa6b-5ffe-44ba-bd1a-301fd95b9ce2",
"api-key": "REDACTED",
"content-length": "692"
},
"method": "PUT",
"timeout": 0,
"disableKeepAlive": false,
"streamResponseStatusCodes": {},
"withCredentials": false,
"tracingOptions": {
"tracingContext": {
"_contextMap": {}
}
},
"requestId": "818afa6b-5ffe-44ba-bd1a-301fd95b9ce2",
"allowInsecureConnection": false,
"enableBrowserStreams": false
},
"details": {
"error": {
"code": "",
"message": "One or more skills are invalid. Details: Error in skill 'Azure OpenAI Embedding skill': 'uri' parameter cannot be null or empty"
}
},
"message": "One or more skills are invalid. Details: Error in skill 'Azure OpenAI Embedding skill': 'uri' parameter cannot be null or empty"
}
Creating or updating indexer: samplel-indexer...
Failed to create or update indexer: RestError: This indexer refers to a skillset 'samplel-skillset' that doesn't exist
{
"name": "RestError",
"code": "",
"statusCode": 400,
"request": {
"url": "https://ai-search-service-dev-basic.search.windows.net/indexers('samplel-indexer')?api-version=2023-11-01",
"headers": {
"content-type": "application/json",
"accept": "application/json;odata.metadata=minimal",
"prefer": "REDACTED",
"accept-encoding": "gzip,deflate",
"user-agent": "azsdk-js-search-documents/12.0.0 core-rest-pipeline/1.12.2 Node/v21.6.2 OS/(arm64-Darwin-23.2.0)",
"x-ms-client-request-id": "f6a9e94b-7b39-4238-a387-bfd1b50ded41",
"api-key": "REDACTED",
"content-length": "275"
},
"method": "PUT",
"timeout": 0,
"disableKeepAlive": false,
"streamResponseStatusCodes": {},
"withCredentials": false,
"tracingOptions": {
"tracingContext": {
"_contextMap": {}
}
},
"requestId": "f6a9e94b-7b39-4238-a387-bfd1b50ded41",
"allowInsecureConnection": false,
"enableBrowserStreams": false
},
"details": {
"error": {
"code": "",
"message": "This indexer refers to a skillset 'samplel-skillset' that doesn't exist"
}
},
"message": "This indexer refers to a skillset 'samplel-skillset' that doesn't exist"
}
Below is the code snippet where I define my embeddingSkill
:
// Creating Skillsets
async function createOrUpdateSkillset() {
const endpoint = process.env.AZURE_SEARCH_ENDPOINT || "";
const apiKey = process.env.AZURE_SEARCH_ADMIN_KEY || "";
const indexName = process.env.AZURE_SEARCH_INDEX_NAME;
const azureOpenaiEndpoint = process.env.AZURE_OPENAI_ENDPOINT;
const azureOpenaiDeployment = process.env.AZURE_OPENAI_DEPLOYMENT_NAME;
const azureOpenaiKey = process.env.AZURE_OPENAI_API_KEY;
const indexerClient = new SearchIndexerClient(endpoint, new AzureKeyCredential(apiKey));
const skillsetName = `${indexName}-skillset`;
// Define the split skill
const splitSkill = {
name: "Split skill",
description: "Split skill to chunk documents",
odatatype: "#Microsoft.Skills.Text.SplitSkill",
textSplitMode: "pages",
context: "/document",
maximumPageLength: 2000,
pageOverlapLength: 500,
inputs: [
{ name: "text", source: "/document/content" }
],
outputs: [
{ name: "textItems", targetName: "pages" }
]
};
// Define the embedding skill
const embeddingSkill = {
odatatype: "#Microsoft.Skills.Text.AzureOpenAIEmbeddingSkill",
name: "Azure OpenAI Embedding skill",
description: "Skill to generate embeddings via Azure OpenAI",
context: "/document/pages/*",
resourceUri: azureOpenaiEndpoint, // "https://<resource_name>.openai.azure.com/"
apiKey: azureOpenaiKey,
deploymentId: azureOpenaiDeployment,
inputs: [
{ name: "text", source: "/document/pages/*" }
],
outputs: [
{ name: "embedding", targetName: "vector" }
],
authIdentity: null
};
// Define the skillset
let skillset = {
name: skillsetName,
description: "Skillset to chunk documents and generating embeddings",
skills: [splitSkill, embeddingSkill],
indexProjections: {
selectors: [
{
targetIndexName: indexName,
parentKeyFieldName: "parent_id",
sourceContext: "/document/pages/*",
mappings: [
{ name: "chunk", source: "/document/pages/*" },
{ name: "vector", source: "/document/pages/*/vector" },
{ name: "title", source: "/document/metadata_storage_name" }
]
}
],
parameters: { projectionMode: "skipIndexingParentDocuments" }
}
};
console.log(`Creating or updating skillset: ${skillsetName}...`);
await indexerClient.createOrUpdateSkillset(skillset); // Make sure this method exists or find the equivalent
console.log(`Skillset '${skillsetName}' created or updated successfully.`);
}
I have verified that the resourceUri is correctly set and points to my Azure OpenAI resource. The splitSkill related part of the process works as expected, and the issue only arises when adding the embeddingSkill.
Can someone help me identify what might be causing this uri parameter error with the Azure OpenAI Embedding skill?
Upvotes: 1
Views: 498
Reputation: 8075
Some skills are not supported in the latest version of @azure/search-documents
.
Use the command below to install the beta version:
npm i @azure/[email protected]
Then, execute your code.
And in the skillset:
You can read more about this in the documentation.
Above, you can see the skills added in the preview version, but they are not present in the latest version.
Upvotes: 0