Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /HKUDS_LightRAG /lightrag /api /input_limits.py
| """Shared measurement of normalized model-facing conversation input.""" | |
| from __future__ import annotations | |
| import json | |
| from collections.abc import Sequence | |
| from typing import Any | |
| def count_conversation_input_chars( | |
| query: str, | |
| instruction: str | None, | |
| history: Sequence[dict[str, Any]] | None, | |
| ) -> int: | |
| """Count the canonical conversation input sent into an LLM flow. | |
| ``history`` must be the representation the caller forwards downstream. Its | |
| serialized form deliberately counts roles, field names, and permitted extra | |
| fields, so either API surface cannot hide input outside the shared budget. | |
| """ | |
| total = len(query) + len(instruction or "") | |
| if history: | |
| total += len(json.dumps(history, ensure_ascii=False)) | |
| return total | |
Xet Storage Details
- Size:
- 779 Bytes
- Xet hash:
- 871ab7e2ef726a137f4dc5958934a92592896fbe81e80dbce6c5e99b9ce123c7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.