能否在Azure OpenAI Ingestion Job API中指定容器查询?
Azure OpenAI Ingestion Job API 指定虚拟文件夹处理方案
可以在Ingestion Job API中指定虚拟文件夹,只需在请求体的datasource对象里添加prefix字段,指定目标虚拟文件夹的路径即可。
修改你的代码,在containerName下方添加prefix参数:
const endpoint = openaiEndpoint; const jobId = indexName; const apiVersion = "2024-04-01-preview"; const url = `${endpoint}/openai/ingestion/jobs/${jobId}?api-version=${apiVersion}`; const requestBody = { "kind": "SystemCompute", "searchServiceConnection": { "kind": "EndpointWithKey", "key": searchAdminApiKey, "endpoint": searchEndpoint }, "datasource": { "kind": "Storage", "storageAccountConnection": { "kind": "ConnectionString", "connectionString": blobStorageConnectionString }, "containerName": "iverdokument", // 添加prefix指定目标虚拟文件夹 "prefix": "your-target-folder/", "chunking": { "maxChunkSizeInTokens": 1024 }, "embeddings": [ { "connection": { "kind": "RelativeConnection" }, "deploymentName": "Ada" } ] }, "completionAction": "cleanUpTempAssets" }; try { const response = await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json', 'api-key': openaiApiKey! }, body: JSON.stringify(requestBody) }); if (response.ok) { const data = await response.json(); console.log('Request successful:', data); return data; } else { const errorData = await response.json(); console.error('Request failed ingestion:', errorData); } } catch (error) { console.error('Error:', error); }
参数说明
prefix的值是Blob存储中的虚拟目录路径,格式要以斜杠/结尾(比如目标文件夹是annual-reports,就写annual-reports/)。- 指定后,Ingestion Job只会扫描并处理该前缀路径下的所有文件及子文件夹内容,容器内其他路径的文件会被忽略。
内容的提问来源于stack exchange,提问作者Max Claesson
相关产品推荐
相关产品推荐

