def main_output(
        self, func: Callable, sig: Signature, bindings: BoundArguments, ret: Any
    ) -> str:
        """
        Determine the main out string for the given function `func` with
        signature `sig` after it is called with the given `bindings` and has
        returned `ret`.
        """

        if isinstance(ret, (AIMessage, AIMessageChunk)):
            return ret.content

        if isinstance(ret, Sequence) and all(
            isinstance(x, Dict) and "content" in x for x in ret
        ):
            # Streaming outputs for some internal methods are lists of dicts
            # with each having "content".
            return "".join(x["content"] for x in ret)

        if isinstance(ret, Sequence) and all(
            isinstance(x, (AIMessage, AIMessageChunk)) for x in ret
        ):
            # Streaming outputs for some internal methods are lists of dicts
            # with each having "content".
            return "".join(x.content for x in ret)

        if isinstance(ret, Sequence) and all(isinstance(x, str) for x in ret):
            # Streaming outputs of main stream methods like Runnable.stream are
            # bundled by us into a sequence of strings.
            return "".join(ret)

        if isinstance(ret, Dict) and python_utils.safe_hasattr(
            self.app, "output_keys"
        ):
            # langchain specific:
            if len(self.app.output_keys) == 0:
                logger.warning(
                    "langchain app has no `output_keys`. `main_output` might not be detected."
                )
                return super().main_output(func, sig, bindings, ret)

            if self.app.output_keys[0] in ret:
                return ret[self.app.output_keys[0]]

        return core_app.App.main_output(self, func, sig, bindings, ret)

        Determine the main out string for the given function `func` with
        signature `sig` after it is called with the given `bindings` and has
        returned `ret`.
        
src/apps/langchain/trulens/apps/langchain/tru_chain.py