我正在努力将 Azure OpenAI 的嵌入技能集成到我的 Azure 认知搜索技能集中,但当我尝试创建或更新技能集时遇到 RestError。 splitSkill 工作正常,但 embeddingSkill 会抛出错误,尽管 ResourceUri 设置正确。
这是我收到的错误消息:
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"
}
下面是我定义我的
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.`);
}
我已验证 resourcesUri 设置正确并指向我的 Azure OpenAI 资源。该过程中与 splitSkill 相关的部分按预期工作,并且仅在添加 embeddingSkill 时才会出现问题。
有人可以帮助我使用 Azure OpenAI 嵌入技能确定可能导致此 uri 参数错误的原因吗?
最新版本的
@azure/search-documents
不支持某些技能。
使用以下命令安装测试版:
npm i @azure/[email protected]
然后,执行您的代码。
在技能组中:
您可以在文档中阅读更多相关信息。
在上面,你可以看到预览版本中添加的技能,但最新版本中没有这些技能。