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