from haystack import component from typing import List @component class JSONGrabber: """ A component that takes out a JSON body from a given string. The string should have a JSON body encased with "" and "" strings. """ @component.output_types(body=str) def run(self, replies: List[str]): reply = replies[0] body = reply[reply.find("") + len("") :].strip() body = body[: body.find("")].strip() print(f"Grabbed JSON:\n{body}") return {"body": body}