Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fix value.startsWith is not a function error #3747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/components/nodes/sequentialagents/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,22 @@ export const transformObjectPropertyToFunction = (obj: ICommonObject, state: ISe
(message) => message.additional_kwargs && message.additional_kwargs?.nodeId === parsedValue.id
)
const messageOutput = messageOutputs[messageOutputs.length - 1]
if (messageOutput) value = messageOutput.content
if (messageOutput) {
// if messageOutput.content is a string, set value to the content
if (typeof messageOutput.content === 'string') value = messageOutput.content
// if messageOutput.content is an array
else if (Array.isArray(messageOutput.content)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check if the array is not empty?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense... standby

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... should we throw an error if it's empty or...?

// Get the first element of the array
const messageOutputContentFirstElement: any = messageOutput.content[0]

if (typeof messageOutputContentFirstElement === 'string') value = messageOutputContentFirstElement
// If messageOutputContentFirstElement is an object and has a text property, set value to the text property
else if (typeof messageOutputContentFirstElement === 'object' && messageOutputContentFirstElement.text)
value = messageOutputContentFirstElement.text
// Otherwise, stringify the messageOutputContentFirstElement
else value = JSON.stringify(messageOutputContentFirstElement)
}
}
}
} catch (e) {
// do nothing
Expand Down
Loading