mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Bugfix/Update file loader (#4420)
* update file loader * delete temp for o1 * fix tavily
This commit is contained in:
@@ -237,7 +237,7 @@ class AzureChatOpenAI_ChatModels implements INode {
|
||||
console.error('Error parsing base options', exception)
|
||||
}
|
||||
}
|
||||
if (modelName === 'o3-mini') {
|
||||
if (modelName === 'o3-mini' || modelName.includes('o1')) {
|
||||
delete obj.temperature
|
||||
}
|
||||
if ((modelName.includes('o1') || modelName.includes('o3')) && reasoningEffort) {
|
||||
|
||||
@@ -243,7 +243,7 @@ class ChatOpenAI_ChatModels implements INode {
|
||||
streaming: streaming ?? true
|
||||
}
|
||||
|
||||
if (modelName.includes('o3')) {
|
||||
if (modelName.includes('o3') || modelName.includes('o1')) {
|
||||
delete obj.temperature
|
||||
}
|
||||
if ((modelName.includes('o1') || modelName.includes('o3')) && reasoningEffort) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class File_DocumentLoaders implements INode {
|
||||
},
|
||||
{
|
||||
label: 'Pdf Usage',
|
||||
name: 'pdfUsage',
|
||||
name: 'usage',
|
||||
type: 'options',
|
||||
description: 'Only when loading PDF files',
|
||||
options: [
|
||||
@@ -64,6 +64,14 @@ class File_DocumentLoaders implements INode {
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Use Legacy Build',
|
||||
name: 'legacyBuild',
|
||||
type: 'boolean',
|
||||
description: 'Use legacy build for PDF compatibility issues',
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'JSONL Pointer Extraction',
|
||||
name: 'pointerName',
|
||||
@@ -113,7 +121,8 @@ class File_DocumentLoaders implements INode {
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const fileBase64 = nodeData.inputs?.file as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
const pdfUsage = nodeData.inputs?.pdfUsage
|
||||
const pdfUsage = nodeData.inputs?.pdfUsage || nodeData.inputs?.usage
|
||||
const legacyBuild = nodeData.inputs?.legacyBuild as boolean
|
||||
const pointerName = nodeData.inputs?.pointerName as string
|
||||
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
|
||||
const output = nodeData.outputs?.output as string
|
||||
@@ -173,10 +182,21 @@ class File_DocumentLoaders implements INode {
|
||||
const match = file.match(/^data:([A-Za-z-+\/]+);base64,/)
|
||||
|
||||
if (!match) {
|
||||
fileBlobs.push({
|
||||
blob,
|
||||
ext: extension
|
||||
})
|
||||
// Fallback: check if there's a filename pattern at the end
|
||||
const filenameMatch = file.match(/,filename:(.+\.\w+)$/)
|
||||
if (filenameMatch && filenameMatch[1]) {
|
||||
const filename = filenameMatch[1]
|
||||
const fileExt = filename.split('.').pop() || ''
|
||||
fileBlobs.push({
|
||||
blob,
|
||||
ext: fileExt
|
||||
})
|
||||
} else {
|
||||
fileBlobs.push({
|
||||
blob,
|
||||
ext: extension
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const mimeType = match[1]
|
||||
fileBlobs.push({
|
||||
@@ -199,9 +219,18 @@ class File_DocumentLoaders implements INode {
|
||||
pdf: (blob) =>
|
||||
pdfUsage === 'perFile'
|
||||
? // @ts-ignore
|
||||
new PDFLoader(blob, { splitPages: false, pdfjs: () => import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js') })
|
||||
new PDFLoader(blob, {
|
||||
splitPages: false,
|
||||
pdfjs: () =>
|
||||
// @ts-ignore
|
||||
legacyBuild ? import('pdfjs-dist/legacy/build/pdf.js') : import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js')
|
||||
})
|
||||
: // @ts-ignore
|
||||
new PDFLoader(blob, { pdfjs: () => import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js') }),
|
||||
new PDFLoader(blob, {
|
||||
pdfjs: () =>
|
||||
// @ts-ignore
|
||||
legacyBuild ? import('pdfjs-dist/legacy/build/pdf.js') : import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js')
|
||||
}),
|
||||
'': (blob) => new TextLoader(blob)
|
||||
})
|
||||
let docs = []
|
||||
|
||||
@@ -18,20 +18,12 @@ class TavilyAPI_Tools implements INode {
|
||||
constructor() {
|
||||
this.label = 'Tavily API'
|
||||
this.name = 'tavilyAPI'
|
||||
this.version = 1.1
|
||||
this.version = 1.2
|
||||
this.type = 'TavilyAPI'
|
||||
this.icon = 'tavily.svg'
|
||||
this.category = 'Tools'
|
||||
this.description = 'Wrapper around TavilyAPI - A specialized search engine designed for LLMs and AI agents'
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
optional: false,
|
||||
description: 'The search query to execute with Tavily',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Topic',
|
||||
name: 'topic',
|
||||
@@ -165,7 +157,6 @@ class TavilyAPI_Tools implements INode {
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const tavilyApiKey = getCredentialParam('tavilyApiKey', credentialData, nodeData)
|
||||
|
||||
const query = nodeData.inputs?.query as string
|
||||
const topic = nodeData.inputs?.topic as string
|
||||
const searchDepth = nodeData.inputs?.searchDepth as string
|
||||
const chunksPerSource = nodeData.inputs?.chunksPerSource as number
|
||||
@@ -181,14 +172,13 @@ class TavilyAPI_Tools implements INode {
|
||||
|
||||
const config: any = {
|
||||
apiKey: tavilyApiKey,
|
||||
query,
|
||||
topic,
|
||||
searchDepth,
|
||||
maxResults,
|
||||
includeAnswer,
|
||||
includeRawContent,
|
||||
includeImages,
|
||||
includeImageDescriptions
|
||||
includeAnswer: includeAnswer || undefined,
|
||||
includeRawContent: includeRawContent || undefined,
|
||||
includeImages: includeImages || undefined,
|
||||
includeImageDescriptions: includeImageDescriptions || undefined
|
||||
}
|
||||
|
||||
if (chunksPerSource) config.chunksPerSource = chunksPerSource
|
||||
|
||||
Reference in New Issue
Block a user