mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 09:00:52 +03:00
[Usntructured loaders] Make Unstructured API URL optional when environment variable is present (#3414)
* Make Unstructured API URL optional when environment variable is present * Fix empty apiUrl option in Unsctructured flowise loader * Add focumentation for env vars
This commit is contained in:
@@ -29,9 +29,9 @@ type Element = {
|
||||
export class UnstructuredLoader extends BaseDocumentLoader {
|
||||
public filePath: string
|
||||
|
||||
private apiUrl = 'https://api.unstructuredapp.io/general/v0/general'
|
||||
private apiUrl = process.env.UNSTRUCTURED_API_URL || 'https://api.unstructuredapp.io/general/v0/general'
|
||||
|
||||
private apiKey?: string
|
||||
private apiKey: string | undefined = process.env.UNSTRUCTURED_API_KEY
|
||||
|
||||
private strategy: StringWithAutocomplete<UnstructuredLoaderStrategy> = 'hi_res'
|
||||
|
||||
@@ -66,10 +66,10 @@ export class UnstructuredLoader extends BaseDocumentLoader {
|
||||
|
||||
const options = optionsOrLegacyFilePath
|
||||
this.apiKey = options.apiKey
|
||||
this.apiUrl = options.apiUrl ?? this.apiUrl
|
||||
this.strategy = options.strategy ?? this.strategy
|
||||
this.apiUrl = options.apiUrl || this.apiUrl
|
||||
this.strategy = options.strategy || this.strategy
|
||||
this.encoding = options.encoding
|
||||
this.ocrLanguages = options.ocrLanguages ?? this.ocrLanguages
|
||||
this.ocrLanguages = options.ocrLanguages || this.ocrLanguages
|
||||
this.coordinates = options.coordinates
|
||||
this.pdfInferTableStructure = options.pdfInferTableStructure
|
||||
this.xmlKeepTags = options.xmlKeepTags
|
||||
@@ -128,7 +128,7 @@ export class UnstructuredLoader extends BaseDocumentLoader {
|
||||
}
|
||||
|
||||
const headers = {
|
||||
'UNSTRUCTURED-API-KEY': this.apiKey ?? ''
|
||||
'UNSTRUCTURED-API-KEY': this.apiKey || ''
|
||||
}
|
||||
|
||||
const response = await fetch(this.apiUrl, {
|
||||
|
||||
Reference in New Issue
Block a user