fix linting
This commit is contained in:
parent
3b0c5b0c0d
commit
939daff0a1
|
|
@ -1,35 +1,36 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface';
|
||||
import { TextSplitter } from 'langchain/text_splitter';
|
||||
import { SerpAPILoader } from 'langchain/document_loaders/web/serpapi';import { getCredentialData, getCredentialParam } from '../../../src';
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { SerpAPILoader } from 'langchain/document_loaders/web/serpapi'
|
||||
import { getCredentialData, getCredentialParam } from '../../../src'
|
||||
|
||||
class SerpAPI_DocumentLoaders implements INode {
|
||||
label: string;
|
||||
name: string;
|
||||
version: number;
|
||||
description: string;
|
||||
type: string;
|
||||
icon: string;
|
||||
category: string;
|
||||
baseClasses: string[];
|
||||
credential: INodeParams;
|
||||
inputs: INodeParams[];
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
credential: INodeParams
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'SerpApi For Web Search';
|
||||
this.name = 'serpApi';
|
||||
this.version = 1.0;
|
||||
this.type = 'Document';
|
||||
this.icon = 'serp.png';
|
||||
this.category = 'Document Loaders';
|
||||
this.description = 'Load and process data from web search results';
|
||||
this.baseClasses = [this.type];
|
||||
this.label = 'SerpApi For Web Search'
|
||||
this.name = 'serpApi'
|
||||
this.version = 1.0
|
||||
this.type = 'Document'
|
||||
this.icon = 'serp.png'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = 'Load and process data from web search results'
|
||||
this.baseClasses = [this.type]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
optional: false,
|
||||
credentialNames: ['serpApi']
|
||||
};
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
optional: false,
|
||||
credentialNames: ['serpApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Query',
|
||||
|
|
@ -49,21 +50,21 @@ class SerpAPI_DocumentLoaders implements INode {
|
|||
optional: true,
|
||||
additionalParams: true
|
||||
}
|
||||
];
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter;
|
||||
const query = nodeData.inputs?.query as string;
|
||||
const metadata = nodeData.inputs?.metadata;
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const query = nodeData.inputs?.query as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options);
|
||||
const serpApiKey = getCredentialParam('serpApiKey', credentialData, nodeData);
|
||||
const loader = new SerpAPILoader({ q: query, apiKey: serpApiKey });
|
||||
const docs = textSplitter ? await loader.loadAndSplit() : await loader.load();
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const serpApiKey = getCredentialParam('serpApiKey', credentialData, nodeData)
|
||||
const loader = new SerpAPILoader({ q: query, apiKey: serpApiKey })
|
||||
const docs = textSplitter ? await loader.loadAndSplit() : await loader.load()
|
||||
|
||||
if (metadata) {
|
||||
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata);
|
||||
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
|
||||
return docs.map((doc) => {
|
||||
return {
|
||||
...doc,
|
||||
|
|
@ -71,12 +72,12 @@ class SerpAPI_DocumentLoaders implements INode {
|
|||
...doc.metadata,
|
||||
...parsedMetadata
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return docs;
|
||||
return docs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: SerpAPI_DocumentLoaders };
|
||||
module.exports = { nodeClass: SerpAPI_DocumentLoaders }
|
||||
|
|
|
|||
|
|
@ -15,12 +15,7 @@
|
|||
"version": 1,
|
||||
"name": "chatOpenAI",
|
||||
"type": "ChatOpenAI",
|
||||
"baseClasses": [
|
||||
"ChatOpenAI",
|
||||
"BaseChatModel",
|
||||
"BaseLanguageModel",
|
||||
"Runnable"
|
||||
],
|
||||
"baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"],
|
||||
"category": "Chat Models",
|
||||
"description": "Wrapper around OpenAI large language models that use the Chat endpoint",
|
||||
"inputParams": [
|
||||
|
|
@ -28,9 +23,7 @@
|
|||
"label": "Connect Credential",
|
||||
"name": "credential",
|
||||
"type": "credential",
|
||||
"credentialNames": [
|
||||
"openAIApi"
|
||||
],
|
||||
"credentialNames": ["openAIApi"],
|
||||
"id": "chatOpenAI_0-input-credential-credential"
|
||||
},
|
||||
{
|
||||
|
|
@ -191,11 +184,7 @@
|
|||
"version": 1,
|
||||
"name": "conversationalRetrievalQAChain",
|
||||
"type": "ConversationalRetrievalQAChain",
|
||||
"baseClasses": [
|
||||
"ConversationalRetrievalQAChain",
|
||||
"BaseChain",
|
||||
"Runnable"
|
||||
],
|
||||
"baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "Runnable"],
|
||||
"category": "Chains",
|
||||
"description": "Document QA - built on RetrievalQAChain to provide a chat history component",
|
||||
"inputParams": [
|
||||
|
|
@ -305,10 +294,7 @@
|
|||
"version": 1,
|
||||
"name": "openAIEmbeddings",
|
||||
"type": "OpenAIEmbeddings",
|
||||
"baseClasses": [
|
||||
"OpenAIEmbeddings",
|
||||
"Embeddings"
|
||||
],
|
||||
"baseClasses": ["OpenAIEmbeddings", "Embeddings"],
|
||||
"category": "Embeddings",
|
||||
"description": "OpenAI API to generate embeddings for a given text",
|
||||
"inputParams": [
|
||||
|
|
@ -316,9 +302,7 @@
|
|||
"label": "Connect Credential",
|
||||
"name": "credential",
|
||||
"type": "credential",
|
||||
"credentialNames": [
|
||||
"openAIApi"
|
||||
],
|
||||
"credentialNames": ["openAIApi"],
|
||||
"id": "openAIEmbeddings_0-input-credential-credential"
|
||||
},
|
||||
{
|
||||
|
|
@ -394,11 +378,7 @@
|
|||
"version": 1,
|
||||
"name": "memoryVectorStore",
|
||||
"type": "Memory",
|
||||
"baseClasses": [
|
||||
"Memory",
|
||||
"VectorStoreRetriever",
|
||||
"BaseRetriever"
|
||||
],
|
||||
"baseClasses": ["Memory", "VectorStoreRetriever", "BaseRetriever"],
|
||||
"category": "Vector Stores",
|
||||
"description": "In-memory vectorstore that stores embeddings and does an exact, linear search for the most similar embeddings.",
|
||||
"inputParams": [
|
||||
|
|
@ -428,9 +408,7 @@
|
|||
}
|
||||
],
|
||||
"inputs": {
|
||||
"document": [
|
||||
"{{serpApi_2.data.instance}}"
|
||||
],
|
||||
"document": ["{{serpApi_2.data.instance}}"],
|
||||
"embeddings": "{{openAIEmbeddings_0.data.instance}}",
|
||||
"topK": ""
|
||||
},
|
||||
|
|
@ -483,9 +461,7 @@
|
|||
"version": 1,
|
||||
"name": "serpApi",
|
||||
"type": "Document",
|
||||
"baseClasses": [
|
||||
"Document"
|
||||
],
|
||||
"baseClasses": ["Document"],
|
||||
"category": "Document Loaders",
|
||||
"description": "Load and process data from web search results",
|
||||
"inputParams": [
|
||||
|
|
@ -494,9 +470,7 @@
|
|||
"name": "credential",
|
||||
"type": "credential",
|
||||
"optional": false,
|
||||
"credentialNames": [
|
||||
"serpApi"
|
||||
],
|
||||
"credentialNames": ["serpApi"],
|
||||
"id": "serpApi_2-input-credential-credential"
|
||||
},
|
||||
{
|
||||
|
|
@ -593,4 +567,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue