как я могу передать данные, полученные от пользователя, в инструмент в langchain

у меня есть эта функция в langchain

      app.post('/new', async (req, res) => {
  const { question } = req.body;
  const formattedPromptValue = await promptTemplate.format({
    userPrompt: question,
  });
  try {
    // loaded agent
    const executor = await initializeAgentExecutorWithOptions(tools, model, {
      agentType: 'chat-conversational-react-description',
      maxIterations: 3,
    });
  
    const result = await executor.call({
      input: formattedPromptValue.toString(),
    });
   console.log('tool result', result);
}

теперь в моих инструментах есть

      export const getProductInfo = new DynamicTool({
  name: 'Get the product info',
  description: `call this to get information about products that are in myapp, 
      The input to this tool is called question which contains products infomation and the the output will be response gotten from pinecone that match the query.
      `,
  func: getProductsDetails,
});

и в функции getProductsDetails у меня есть

      export const getProductsDetails = async () => {
    await createPineconeIndex(client, indexName, vectorDimension);
    await updatePinecone(client, indexName, docs);
    const queryResponse = await queryPineconeVectorStoreAndQueryLLM(client, indexName, question);
  
          return queryResponse ;    
      };

теперь проблема в том, что «вопрос», который я передаю здесь, queryPineconeVectorStoreAndQueryLLM (client, indexName, вопрос) не был передан, поскольку я получаю вопрос, неопределенный.

пожалуйста, как я могу передать пользовательский ввод («вопрос») в инструмент, чтобы он мог перейти к функции

0 ответов

Другие вопросы по тегам