mirror of https://github.com/FlowiseAI/Flowise.git
Bugfix/observation-includes-not-function (#2744)
* Bugfix: observation?.includes is not a function * Check type of observation before checking source document prefix * lint-fix --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>pull/2765/head
parent
dfdeb02b3a
commit
b1e38783e4
|
|
@ -427,9 +427,10 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
|||
usedTools.push({
|
||||
tool: tool.name,
|
||||
toolInput: action.toolInput as any,
|
||||
toolOutput: observation.includes(SOURCE_DOCUMENTS_PREFIX)
|
||||
? observation.split(SOURCE_DOCUMENTS_PREFIX)[0]
|
||||
: observation
|
||||
toolOutput:
|
||||
typeof observation === 'string' && observation.includes(SOURCE_DOCUMENTS_PREFIX)
|
||||
? observation.split(SOURCE_DOCUMENTS_PREFIX)[0]
|
||||
: observation
|
||||
})
|
||||
} else {
|
||||
observation = `${action.tool} is not a valid tool, try another one.`
|
||||
|
|
@ -449,7 +450,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
|||
return { action, observation: observation ?? '' }
|
||||
}
|
||||
}
|
||||
if (observation?.includes(SOURCE_DOCUMENTS_PREFIX)) {
|
||||
if (typeof observation === 'string' && observation.includes(SOURCE_DOCUMENTS_PREFIX)) {
|
||||
const observationArray = observation.split(SOURCE_DOCUMENTS_PREFIX)
|
||||
observation = observationArray[0]
|
||||
const docs = observationArray[1]
|
||||
|
|
@ -558,7 +559,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
|
|||
input: this.input
|
||||
}
|
||||
)
|
||||
if (observation?.includes(SOURCE_DOCUMENTS_PREFIX)) {
|
||||
if (typeof observation === 'string' && observation.includes(SOURCE_DOCUMENTS_PREFIX)) {
|
||||
const observationArray = observation.split(SOURCE_DOCUMENTS_PREFIX)
|
||||
observation = observationArray[0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue