Skip to content

Commit

Permalink
Merge pull request #126 from FlowiseAI/feature/debugVerbose
Browse files Browse the repository at this point in the history
Feature/Add debug mode
  • Loading branch information
HenryHengZJ authored May 19, 2023
2 parents fb400cb + 1f4efd6 commit 038845c
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/components/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEBUG=true
8 changes: 8 additions & 0 deletions packages/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Install:
npm i flowise-components
```

## Debug

To view all the logs, create an `.env` file and add:

```
DEBUG=true
```

## License

Source code in this repository is made available under the [MIT License](https://github.com/FlowiseAI/Flowise/blob/master/LICENSE.md).
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ConversationalAgent_Agents implements INode {

const obj: InitializeAgentExecutorOptions = {
agentType: 'chat-conversational-react-description',
verbose: true
verbose: process.env.DEBUG === 'true' ? true : false
}

const agentArgs: any = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MRKLAgentChat_Agents implements INode {
tools = tools.flat()
const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: 'chat-zero-shot-react-description',
verbose: true
verbose: process.env.DEBUG === 'true' ? true : false
})
return executor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MRKLAgentLLM_Agents implements INode {

const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: 'zero-shot-react-description',
verbose: true
verbose: process.env.DEBUG === 'true' ? true : false
})
return executor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class ConversationalRetrievalQAChain_Chains implements INode {
const model = nodeData.inputs?.model as BaseLanguageModel
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever

const chain = ConversationalRetrievalQAChain.fromLLM(model, vectorStoreRetriever)
const chain = ConversationalRetrievalQAChain.fromLLM(model, vectorStoreRetriever, {
verbose: process.env.DEBUG === 'true' ? true : false
})
return chain
}

Expand Down
4 changes: 2 additions & 2 deletions packages/components/nodes/chains/LLMChain/LLMChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class LLMChain_Chains implements INode {
const promptValues = prompt.promptValues as ICommonObject

if (output === this.name) {
const chain = new LLMChain({ llm: model, prompt })
const chain = new LLMChain({ llm: model, prompt, verbose: process.env.DEBUG === 'true' ? true : false })
return chain
} else if (output === 'outputPrediction') {
const chain = new LLMChain({ llm: model, prompt })
const chain = new LLMChain({ llm: model, prompt, verbose: process.env.DEBUG === 'true' ? true : false })
const inputVariables = chain.prompt.inputVariables as string[] // ["product"]
const res = await runPrediction(inputVariables, chain, input, promptValues)
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RetrievalQAChain_Chains implements INode {
const model = nodeData.inputs?.model as BaseLanguageModel
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever

const chain = RetrievalQAChain.fromLLM(model, vectorStoreRetriever)
const chain = RetrievalQAChain.fromLLM(model, vectorStoreRetriever, { verbose: process.env.DEBUG === 'true' ? true : false })
return chain
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const getSQLDBChain = async (databaseType: 'sqlite', dbFilePath: string, llm: Ba

const obj: SqlDatabaseChainInput = {
llm,
database: db
database: db,
verbose: process.env.DEBUG === 'true' ? true : false
}

const chain = new SqlDatabaseChain(obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class VectorDBQAChain_Chains implements INode {
const model = nodeData.inputs?.model as BaseLanguageModel
const vectorStore = nodeData.inputs?.vectorStore as VectorStore

const chain = VectorDBQAChain.fromLLM(model, vectorStore)
const chain = VectorDBQAChain.fromLLM(model, vectorStore, { verbose: process.env.DEBUG === 'true' ? true : false })
return chain
}

Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"express": "^4.17.3",
"form-data": "^4.0.0",
"graphql": "^16.6.0",
"langchain": "^0.0.73",
"langchain": "^0.0.78",
"linkifyjs": "^4.1.1",
"mammoth": "^1.5.1",
"moment": "^2.29.3",
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
import dotenv from 'dotenv'
import path from 'path'

const envPath = path.join(__dirname, '..', '..', '.env')
dotenv.config({ path: envPath })

export * from './Interface'
export * from './utils'

0 comments on commit 038845c

Please sign in to comment.