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

Example "plan-and-execute" not work #116

Open
zrg-team opened this issue Apr 12, 2024 · 0 comments
Open

Example "plan-and-execute" not work #116

zrg-team opened this issue Apr 12, 2024 · 0 comments

Comments

@zrg-team
Copy link

Issues went implement "plan-and-execute"

i followed
https://github.com/langchain-ai/langgraphjs/blob/main/examples/plan-and-execute/plan-and-execute.ipynb

Input

const createAgentRunnable = async (
  llm: ChatOpenAI,
  tools: Awaited<ReturnType<typeof createAgentTools>>,
) => {
  // Get the prompt to use - you can modify this!
  const prompt = new ChatPromptTemplate({
    inputVariables: ['input', 'chat_history', 'agent_scratchpad'],
    promptMessages: [
      new SystemMessage(AGENT_PROMPT_SYSTEM_MESSAGE),
      new MessagesPlaceholder('chat_history'),
      HumanMessagePromptTemplate.fromTemplate('{input}'),
      HumanMessagePromptTemplate.fromTemplate(RESPONSE_INTRODUCT_MESSAGE_TEMPLATE),
      new MessagesPlaceholder('agent_scratchpad'),
    ],
  })
  // Construct the OpenAI Functions agent
  return await createOpenAIFunctionsAgent({
    llm,
    tools,
    prompt,
  })
}

export const createOGDeveloperAgentExecutor = async (
  data: AgentDataInput,
  services: AgentServiceInput,
) => {
  const tools = await createAgentTools(data, services)
  const agent = await createAgentRunnable(services.llm, tools)

  const agentExecutor = createAgentExecutor({
    agentRunnable: agent,
    tools: [],
  })

  return agentExecutor
}

ExecuteStep

executeStep = async (state: PlanExecuteState): Promise<Partial<PlanExecuteState>> => {
    const task = state.input
    const agentResponse = await this.agentExecutor.invoke({
      input: task,
      chat_history: state.chatHistory,
    })
    console.log('agentResponse', agentResponse)
    return { pastSteps: [task, agentResponse.agentOutcome.returnValues.output] }
  }

Error

err TypeError: Cannot read properties of undefined (reading 'returnValues')

The agentExcutor invoke response is not including "agentOutcome"

agentResponse {
  input: 'hi',
  chat_history: [
    AIMessage {
      lc_serializable: true,
      lc_kwargs: [Object],
      lc_namespace: [Array],
      content: '(Backend Developer) Sorry can not help you now. Please try again later.',
      name: undefined,
      additional_kwargs: {},
      response_metadata: {},
      tool_calls: [],
      invalid_tool_calls: []
    },
    AIMessage {
      lc_serializable: true,
      lc_kwargs: [Object],
      lc_namespace: [Array],
      content: '(Backend Developer) AI thinking ...',
      name: undefined,
      additional_kwargs: {},
      response_metadata: {},
      tool_calls: [],
      invalid_tool_calls: []
    }
  ],
  output: "I'm ready to assist you. How can I help you today?",
  intermediateSteps: []
}
@zrg-team zrg-team changed the title Examle "plan-and-execute" not work Example "plan-and-execute" not work Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant