mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
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>
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user