Merge branch 'main' into bugfix/Concurrent-Chat-Session

# Conflicts:
#	packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts
This commit is contained in:
Henry
2024-01-15 13:22:59 +00:00
20 changed files with 460 additions and 82 deletions
+10 -1
View File
@@ -606,9 +606,18 @@ class ExceptionTool extends Tool {
export const formatAgentSteps = (steps: AgentStep[]): BaseMessage[] =>
steps.flatMap(({ action, observation }) => {
const create_function_message = (observation: string, action: AgentAction) => {
let content: string
if (typeof observation !== 'string') {
content = JSON.stringify(observation)
} else {
content = observation
}
return new FunctionMessage(content, action.tool)
}
if ('messageLog' in action && action.messageLog !== undefined) {
const log = action.messageLog as BaseMessage[]
return log.concat(new FunctionMessage(observation, action.tool))
return log.concat(create_function_message(observation, action))
} else {
return [new AIMessage(action.log)]
}