| 1 | from helpers.api import ApiHandler, Request, Response |
| 2 | |
| 3 | |
| 4 | class GetHistory(ApiHandler): |
| 5 | async def process(self, input: dict, request: Request) -> dict | Response: |
| 6 | ctxid = input.get("context", []) |
| 7 | context = self.use_context(ctxid) |
| 8 | agent = context.streaming_agent or context.agent0 |
| 9 | history = agent.history.output_text() |
| 10 | size = agent.history.get_tokens() |
| 11 | |
| 12 | return { |
| 13 | "history": history, |
| 14 | "tokens": size |
| 15 | } |