def get_context(messages): history=[] for m in messages: history.append( f"{m.role}: {m.content}" ) return "\n".join(history)