microsoft / chat-copilot

MIT License
2.06k stars 701 forks source link

The Planner does not pass the correct inputs using the output of the previous step in a multi-step plan (custom plugin) #422

Closed ramarnat closed 1 year ago

ramarnat commented 1 year ago

Describe the bug The plan is correct (that took a fair bit of effort to make it work to use the array index in the input), but even though the plan claims to be correctly setting the input of the second step to the output of the first step, thats not what it ends up doing, Instead it is passing the full $DOCUMENT_LIST object to each input value.

{
  "proposedPlan": {
    "state": [
      {
        "Key": "INPUT",
        "Value": ""
      }
    ],
    "steps": [
      {
        "state": [
          {
            "Key": "INPUT",
            "Value": ""
          }
        ],
        "steps": [],
        "parameters": [
          {
            "Key": "server_url",
            "Value": "http://10.0.1.235:8000/"
          },
          {
            "Key": "version",
            "Value": ""
          },
          {
            "Key": "INPUT",
            "Value": ""
          }
        ],
        "outputs": [
          "DOCUMENTS_LIST"
        ],
        "next_step_index": 0,
        "name": "GetDocuments",
        "skill_name": "LocusPlugin",
        "description": "List all documents uploaded by an user. The output of this contains values needed to use by the search endpoing for searching individual documents."
      },
      {
        "state": [
          {
            "Key": "INPUT",
            "Value": ""
          }
        ],
        "steps": [],
        "parameters": [
          {
            "Key": "server_url",
            "Value": "http://10.0.1.235:8000/"
          },
          {
            "Key": "version",
            "Value": ""
          },
          {
            "Key": "document_id",
            "Value": "$DOCUMENTS_LIST[0].document_id"
          },
          {
            "Key": "model_name",
            "Value": "multi-qa-MiniLM-L6-cos-v1"
          },
          {
            "Key": "query",
            "Value": "what was the first car?"
          },
          {
            "Key": "document_type",
            "Value": "$DOCUMENTS_LIST[0].document_type"
          },
          {
            "Key": "INPUT",
            "Value": ""
          }
        ],
        "outputs": [
          "SEARCH_RESULT"
        ],
        "next_step_index": 0,
        "name": "DoSearch",
        "skill_name": "LocusPlugin",
        "description": "Perform a search over a document."
      }
    ],
    "parameters": [
      {
        "Key": "INPUT",
        "Value": ""
      }
    ],
    "outputs": [],
    "next_step_index": 0,
    "name": "plan830e1fb2299546f1bd45038ed0023661",
    "skill_name": "Plan",
    "description": "Given the following context, accomplish the user intent.\nContext:\nuserName: Default User\nuserId: xxxx1\nINPUT: iterate thru each document in locus and ask the question \"what was the first car?\". The result of step 1 in the plan will be a list of documents, iterate thru each document and dosearch. set the inputs of dosearch with the output of each item of getdocuments. the plan is still wrong. it must set index for each output property used as an input\nmessageType: 0\nUser intent: The user intends to adjust a data processing plan in the Locus AI CoPilot system, instructing it to iterate through each document, perform a search with the question \"what was the first car?\", and then use the results for further operations, ensuring that an index is set for each output property used as an input."
  },
  "type": 1,
  "state": 1
}

What it is actually sending the api is the entire result of the prior step

/v1/search?document_type=%7b%0a++%22content%22%3a+%22%5b%7b%5cu0022user_id%5cu0022%3a%5cu0022mem_clhpc672c0e2v0sg79eimbft5%5cu0022%2c%5cu0022email%5cu0022%3a%5cu0022ro%40omniarcs.com%5cu0022%2c%5cu0022frontend_version%5cu0022%3a%5cu00221.4.0%5cu0022%2c%5cu0022document_id%5cu0022%3a%5cu0022aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvRmVycmFyaQ%3d%3d%5cu0022%2c%5cu0022document_url%5cu0022%3a%5cu0022https%3a%2f%2fen.wikipedia.org%2fwiki%2fFerrari%5cu0022%2c%5cu0022model_id%5cu0022%3a%5cu0022multi-qa-MiniLM-L6-cos-v1%5cu0022%2c%5cu0022status%5cu0022%3a%5cu0022DOC_LOADED%5cu0022%2c%5cu0022last_error%5cu0022%3a%5cu0022%5cu0022%2c%5cu0022status_updated%5cu0022%3a1695994974%2c%5cu0022document_type%5cu0022%3a%5c
... snip ... 
&query=what+was+the+first+car%3f&model_name=multi-qa-MiniLM-L6-cos-v1
TaoChenOSU commented 1 year ago

Planner issue tracked by https://github.com/microsoft/semantic-kernel/issues/2280