SalesforceAIResearch / AgentLite

Apache License 2.0
353 stars 30 forks source link

Finish action customization. #17

Open pluswave opened 2 months ago

pluswave commented 2 months ago

If I want to an agent to output multiline code, it is hard to use current framework .

that is because the syntax:

    Finish [ {"response": "content" } ]

the code should be included in the content, for gpt-3.5 , multiline content inside a json formatted string is error-prone.

If ,the customization code can easily :

  1. re-parse the llm-output if a action parser fails
  2. specify other format other than current FinishAction

it will be easier.

JimSalesforce commented 2 months ago

Thanks for pointing this out. Actually, the only constraint for Finish action is the name should be 'Finish', the output parameters can still be defined in your customized way. To achieve this, there may be two ways to solve it

pluswave commented 2 months ago

I don't think you get my point. the key problem is the parse method for ALL actions are the same. that is , the prompt and the code, together define an action schema like the following format:

ActionName [ {"params1": "content", "params2":"content"} ]

which, force the llm to put the meaningful contents INSIDE a JSON format, which is error prone, because it is easy for llm to output like the format below instead of the format defined above when content has multi-line code:

ActionName

```python
# multi-line code here

```

Another issue for redefine FinishAction, it has some restriction, which is caused in the forward method of BaseAgent, it hardcode FinishAct instead of custom Action in the call chain:

        if agent_act.name == FinishAct.action_name:
            act_found_flag = True
            observation = "Task Completed."
            task.completion = "completed"
            task.answer = FinishAct(**agent_act.params) # this line hardcode FinishAct
JimSalesforce commented 2 months ago

I see. Yea, current action is based on the json output. If you want to define another type of actions, you may have to change the action type and define your own parser.

Yea, we also find this Finish issue. We will create a new PR to fix it.