mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
Merge pull request #16826 from selenecodes/feat/azure-document-intelligence-azure-entra-auth
feat: Authenticate Azure Document Intelligence using DefaultAzureCredential
This commit is contained in:
commit
4267e22d4a
2 changed files with 16 additions and 9 deletions
|
|
@ -4,6 +4,7 @@ import ftfy
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from azure.identity import DefaultAzureCredential
|
||||||
from langchain_community.document_loaders import (
|
from langchain_community.document_loaders import (
|
||||||
AzureAIDocumentIntelligenceLoader,
|
AzureAIDocumentIntelligenceLoader,
|
||||||
BSHTMLLoader,
|
BSHTMLLoader,
|
||||||
|
|
@ -327,7 +328,6 @@ class Loader:
|
||||||
elif (
|
elif (
|
||||||
self.engine == "document_intelligence"
|
self.engine == "document_intelligence"
|
||||||
and self.kwargs.get("DOCUMENT_INTELLIGENCE_ENDPOINT") != ""
|
and self.kwargs.get("DOCUMENT_INTELLIGENCE_ENDPOINT") != ""
|
||||||
and self.kwargs.get("DOCUMENT_INTELLIGENCE_KEY") != ""
|
|
||||||
and (
|
and (
|
||||||
file_ext in ["pdf", "xls", "xlsx", "docx", "ppt", "pptx"]
|
file_ext in ["pdf", "xls", "xlsx", "docx", "ppt", "pptx"]
|
||||||
or file_content_type
|
or file_content_type
|
||||||
|
|
@ -340,11 +340,18 @@ class Loader:
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
loader = AzureAIDocumentIntelligenceLoader(
|
if self.kwargs.get("DOCUMENT_INTELLIGENCE_KEY") != "":
|
||||||
file_path=file_path,
|
loader = AzureAIDocumentIntelligenceLoader(
|
||||||
api_endpoint=self.kwargs.get("DOCUMENT_INTELLIGENCE_ENDPOINT"),
|
file_path=file_path,
|
||||||
api_key=self.kwargs.get("DOCUMENT_INTELLIGENCE_KEY"),
|
api_endpoint=self.kwargs.get("DOCUMENT_INTELLIGENCE_ENDPOINT"),
|
||||||
)
|
api_key=self.kwargs.get("DOCUMENT_INTELLIGENCE_KEY"),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
loader = AzureAIDocumentIntelligenceLoader(
|
||||||
|
file_path=file_path,
|
||||||
|
api_endpoint=self.kwargs.get("DOCUMENT_INTELLIGENCE_ENDPOINT"),
|
||||||
|
azure_credential=DefaultAzureCredential(),
|
||||||
|
)
|
||||||
elif (
|
elif (
|
||||||
self.engine == "mistral_ocr"
|
self.engine == "mistral_ocr"
|
||||||
and self.kwargs.get("MISTRAL_OCR_API_KEY") != ""
|
and self.kwargs.get("MISTRAL_OCR_API_KEY") != ""
|
||||||
|
|
|
||||||
|
|
@ -185,10 +185,9 @@
|
||||||
|
|
||||||
if (
|
if (
|
||||||
RAGConfig.CONTENT_EXTRACTION_ENGINE === 'document_intelligence' &&
|
RAGConfig.CONTENT_EXTRACTION_ENGINE === 'document_intelligence' &&
|
||||||
(RAGConfig.DOCUMENT_INTELLIGENCE_ENDPOINT === '' ||
|
RAGConfig.DOCUMENT_INTELLIGENCE_ENDPOINT === ''
|
||||||
RAGConfig.DOCUMENT_INTELLIGENCE_KEY === '')
|
|
||||||
) {
|
) {
|
||||||
toast.error($i18n.t('Document Intelligence endpoint and key required.'));
|
toast.error($i18n.t('Document Intelligence endpoint required.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|
@ -644,6 +643,7 @@
|
||||||
<SensitiveInput
|
<SensitiveInput
|
||||||
placeholder={$i18n.t('Enter Document Intelligence Key')}
|
placeholder={$i18n.t('Enter Document Intelligence Key')}
|
||||||
bind:value={RAGConfig.DOCUMENT_INTELLIGENCE_KEY}
|
bind:value={RAGConfig.DOCUMENT_INTELLIGENCE_KEY}
|
||||||
|
required={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{:else if RAGConfig.CONTENT_EXTRACTION_ENGINE === 'mistral_ocr'}
|
{:else if RAGConfig.CONTENT_EXTRACTION_ENGINE === 'mistral_ocr'}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue