clean(components): is debug boolean syntax shorthand (#3770)

🧹 CLEAN(components): is debug boolean syntax shorthand
This commit is contained in:
Ahmed Rowaihi
2025-01-03 17:20:59 +03:00
committed by GitHub
parent 7af5815fa9
commit e22c60115e
18 changed files with 23 additions and 23 deletions
@@ -163,7 +163,7 @@ json.dumps(my_dict)`
const chain = new LLMChain({ const chain = new LLMChain({
llm: model, llm: model,
prompt: PromptTemplate.fromTemplate(systemPrompt), prompt: PromptTemplate.fromTemplate(systemPrompt),
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
const inputs = { const inputs = {
dict: dataframeColDict, dict: dataframeColDict,
@@ -192,7 +192,7 @@ json.dumps(my_dict)`
const chain = new LLMChain({ const chain = new LLMChain({
llm: model, llm: model,
prompt: PromptTemplate.fromTemplate(finalSystemPrompt), prompt: PromptTemplate.fromTemplate(finalSystemPrompt),
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
const inputs = { const inputs = {
question: input, question: input,
@@ -170,7 +170,7 @@ json.dumps(my_dict)`
const chain = new LLMChain({ const chain = new LLMChain({
llm: model, llm: model,
prompt: PromptTemplate.fromTemplate(systemPrompt), prompt: PromptTemplate.fromTemplate(systemPrompt),
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
const inputs = { const inputs = {
dict: dataframeColDict, dict: dataframeColDict,
@@ -201,7 +201,7 @@ json.dumps(my_dict)`
prompt: PromptTemplate.fromTemplate( prompt: PromptTemplate.fromTemplate(
systemMessagePrompt ? `${systemMessagePrompt}\n${finalSystemPrompt}` : finalSystemPrompt systemMessagePrompt ? `${systemMessagePrompt}\n${finalSystemPrompt}` : finalSystemPrompt
), ),
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
const inputs = { const inputs = {
question: input, question: input,
@@ -286,7 +286,7 @@ const prepareAgent = async (
sessionId: flowObj?.sessionId, sessionId: flowObj?.sessionId,
chatId: flowObj?.chatId, chatId: flowObj?.chatId,
input: flowObj?.input, input: flowObj?.input,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
@@ -96,13 +96,13 @@ class AnthropicAgent_LlamaIndex_Agents implements INode {
tools, tools,
llm: model, llm: model,
chatHistory: chatHistory, chatHistory: chatHistory,
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
let text = '' let text = ''
const usedTools: IUsedTool[] = [] const usedTools: IUsedTool[] = []
const response = await agent.chat({ message: input, chatHistory, verbose: process.env.DEBUG === 'true' ? true : false }) const response = await agent.chat({ message: input, chatHistory, verbose: process.env.DEBUG === 'true' })
if (response.sources.length) { if (response.sources.length) {
for (const sourceTool of response.sources) { for (const sourceTool of response.sources) {
@@ -107,7 +107,7 @@ class OpenAIFunctionAgent_LlamaIndex_Agents implements INode {
tools, tools,
llm: model, llm: model,
chatHistory: chatHistory, chatHistory: chatHistory,
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
let text = '' let text = ''
@@ -119,7 +119,7 @@ class OpenAIFunctionAgent_LlamaIndex_Agents implements INode {
message: input, message: input,
chatHistory, chatHistory,
stream: true, stream: true,
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
for await (const chunk of stream) { for await (const chunk of stream) {
//console.log('chunk', chunk) //console.log('chunk', chunk)
@@ -147,7 +147,7 @@ class OpenAIFunctionAgent_LlamaIndex_Agents implements INode {
} }
} }
} else { } else {
const response = await agent.chat({ message: input, chatHistory, verbose: process.env.DEBUG === 'true' ? true : false }) const response = await agent.chat({ message: input, chatHistory, verbose: process.env.DEBUG === 'true' })
if (response.sources.length) { if (response.sources.length) {
for (const sourceTool of response.sources) { for (const sourceTool of response.sources) {
usedTools.push({ usedTools.push({
@@ -97,7 +97,7 @@ class ReActAgentLLM_Agents implements INode {
const executor = new AgentExecutor({ const executor = new AgentExecutor({
agent, agent,
tools, tools,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
@@ -336,7 +336,7 @@ const prepareAgent = async (
sessionId: flowObj?.sessionId, sessionId: flowObj?.sessionId,
chatId: flowObj?.chatId, chatId: flowObj?.chatId,
input: flowObj?.input, input: flowObj?.input,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
@@ -276,7 +276,7 @@ const prepareAgent = async (
chatId: flowObj?.chatId, chatId: flowObj?.chatId,
input: flowObj?.input, input: flowObj?.input,
isXML: true, isXML: true,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
@@ -129,7 +129,7 @@ const getAPIChain = async (documents: string, llm: BaseLanguageModel, headers: s
const chain = APIChain.fromLLMAndAPIDocs(llm, documents, { const chain = APIChain.fromLLMAndAPIDocs(llm, documents, {
apiUrlPrompt, apiUrlPrompt,
apiResponsePrompt, apiResponsePrompt,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {} headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {}
}) })
return chain return chain
@@ -128,7 +128,7 @@ const initChain = async (nodeData: INodeData, options: ICommonObject) => {
return await createOpenAPIChain(yamlString, { return await createOpenAPIChain(yamlString, {
llm: model, llm: model,
headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {}, headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {},
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
} }
@@ -119,7 +119,7 @@ const getAPIChain = async (documents: string, llm: BaseLanguageModel, headers: s
const chain = APIChain.fromLLMAndAPIDocs(llm, documents, { const chain = APIChain.fromLLMAndAPIDocs(llm, documents, {
apiUrlPrompt, apiUrlPrompt,
apiResponsePrompt, apiResponsePrompt,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {} headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {}
}) })
return chain return chain
@@ -66,7 +66,7 @@ class MultiPromptChain_Chains implements INode {
promptNames, promptNames,
promptDescriptions, promptDescriptions,
promptTemplates, promptTemplates,
llmChainOpts: { verbose: process.env.DEBUG === 'true' ? true : false } llmChainOpts: { verbose: process.env.DEBUG === 'true' }
}) })
return chain return chain
@@ -74,7 +74,7 @@ class MultiRetrievalQAChain_Chains implements INode {
retrieverNames, retrieverNames,
retrieverDescriptions, retrieverDescriptions,
retrievers, retrievers,
retrievalQAChainOpts: { verbose: process.env.DEBUG === 'true' ? true : false, returnSourceDocuments } retrievalQAChainOpts: { verbose: process.env.DEBUG === 'true', returnSourceDocuments }
}) })
return chain return chain
} }
@@ -53,7 +53,7 @@ class RetrievalQAChain_Chains implements INode {
const model = nodeData.inputs?.model as BaseLanguageModel const model = nodeData.inputs?.model as BaseLanguageModel
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever
const chain = RetrievalQAChain.fromLLM(model, vectorStoreRetriever, { verbose: process.env.DEBUG === 'true' ? true : false }) const chain = RetrievalQAChain.fromLLM(model, vectorStoreRetriever, { verbose: process.env.DEBUG === 'true' })
return chain return chain
} }
@@ -242,7 +242,7 @@ const getSQLDBChain = async (
const obj: SqlDatabaseChainInput = { const obj: SqlDatabaseChainInput = {
llm, llm,
database: db, database: db,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
topK: topK topK: topK
} }
@@ -55,7 +55,7 @@ class VectorDBQAChain_Chains implements INode {
const chain = VectorDBQAChain.fromLLM(model, vectorStore, { const chain = VectorDBQAChain.fromLLM(model, vectorStore, {
k: (vectorStore as any)?.k ?? 4, k: (vectorStore as any)?.k ?? 4,
verbose: process.env.DEBUG === 'true' ? true : false verbose: process.env.DEBUG === 'true'
}) })
return chain return chain
} }
@@ -233,7 +233,7 @@ async function createAgent(
sessionId: flowObj?.sessionId, sessionId: flowObj?.sessionId,
chatId: flowObj?.chatId, chatId: flowObj?.chatId,
input: flowObj?.input, input: flowObj?.input,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
return executor return executor
@@ -668,7 +668,7 @@ async function createAgent(
sessionId: flowObj?.sessionId, sessionId: flowObj?.sessionId,
chatId: flowObj?.chatId, chatId: flowObj?.chatId,
input: flowObj?.input, input: flowObj?.input,
verbose: process.env.DEBUG === 'true' ? true : false, verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
}) })
return executor return executor