from AgentCoord.util.converter import read_outputObject_content
from AgentCoord.RehearsalEngine_V2.Action import BaseAction

ACTION_CUSTOM_NOTE = '''
注意：你可以在给出{OutputName}的最终内容之前先说一些话。当你决定给出{OutputName}的最终内容时，应该这样包含：
```{OutputName}
（{OutputName}的内容）
```
'''

class customAction_Finalize(BaseAction):
    def __init__(self, info, OutputName, KeyObjects) -> None:
        self.KeyObjects = KeyObjects
        self.OutputName = OutputName
        self.Action_Result = None
        self.info = info
        self.Action_Custom_Note = ACTION_CUSTOM_NOTE.format(OutputName = OutputName)

    def postRun_Callback(self) -> None:
        # extract output object
        extracted_outputObject = read_outputObject_content(self.Action_Result, self.OutputName)
        # add the extracted output object to KeyObjects
        self.KeyObjects[self.OutputName] = extracted_outputObject
    