Spaces:
Paused
Paused
Download agent_zero_framework/python/api/ctx_window_get.py from Oldmangrizzz/Agent-Node: direct link, hf CLI and curl.
- Browser
- Download file 593 Bytes
-
https://huggingface.co/spaces/Oldmangrizzz/Agent-Node/resolve/main/agent_zero_framework/python/api/ctx_window_get.py
- Command line
-
hf download hf://spaces/Oldmangrizzz/Agent-Node/agent_zero_framework/python/api/ctx_window_get.py
-
curl -L -o ctx_window_get.py https://huggingface.co/spaces/Oldmangrizzz/Agent-Node/resolve/main/agent_zero_framework/python/api/ctx_window_get.py
593 Bytes
| from python.helpers.api import ApiHandler, Input, Output, Request | |
| class GetCtxWindow(ApiHandler): | |
| async def process(self, input: Input, request: Request) -> Output: | |
| ctxid = input.get("context", []) | |
| context = self.use_context(ctxid) | |
| agent = context.streaming_agent or context.agent0 | |
| window = agent.get_data(agent.DATA_NAME_CTX_WINDOW) | |
| if not window or not isinstance(window, dict): | |
| return {"content": "", "tokens": 0} | |
| text = window["text"] | |
| tokens = window["tokens"] | |
| return {"content": text, "tokens": tokens} | |