mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
add llamaindex
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { ResponseSynthesizerClass } from '../base'
|
||||
|
||||
class TreeSummarize_LlamaIndex implements INode {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
tags: string[]
|
||||
inputs: INodeParams[]
|
||||
outputs: INodeOutputsValue[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'TreeSummarize'
|
||||
this.name = 'treeSummarizeLlamaIndex'
|
||||
this.version = 1.0
|
||||
this.type = 'TreeSummarize'
|
||||
this.icon = 'treesummarize.svg'
|
||||
this.category = 'Response Synthesizer'
|
||||
this.description =
|
||||
'Given a set of text chunks and the query, recursively construct a tree and return the root node as the response. Good for summarization purposes.'
|
||||
this.baseClasses = [this.type, 'ResponseSynthesizer']
|
||||
this.tags = ['LlamaIndex']
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Prompt',
|
||||
name: 'prompt',
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
default: `Context information from multiple sources is below.
|
||||
---------------------
|
||||
{context}
|
||||
---------------------
|
||||
Given the information from multiple sources and not prior knowledge, answer the query.
|
||||
Query: {query}
|
||||
Answer:`,
|
||||
warning: `Prompt can contains no variables, or up to 2 variables. Variables must be {context} and {query}`,
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const prompt = nodeData.inputs?.prompt as string
|
||||
|
||||
const textQAPromptTemplate = ({ context = '', query = '' }) => prompt.replace('{context}', context).replace('{query}', query)
|
||||
|
||||
return new ResponseSynthesizerClass({ textQAPromptTemplate, type: 'TreeSummarize' })
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: TreeSummarize_LlamaIndex }
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-tree" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 13l-2 -2" /><path d="M12 12l2 -2" /><path d="M12 21v-13" /><path d="M9.824 16a3 3 0 0 1 -2.743 -3.69a3 3 0 0 1 .304 -4.833a3 3 0 0 1 4.615 -3.707a3 3 0 0 1 4.614 3.707a3 3 0 0 1 .305 4.833a3 3 0 0 1 -2.919 3.695h-4z" /></svg>
|
||||
|
After Width: | Height: | Size: 512 B |
Reference in New Issue
Block a user