feat(performance): Optimize system resources and token estimation

- Improve JSON history file processing
- Add memory and disk space validation
- Enhance parallel request handling
- Refine token counting heuristics
This commit is contained in:
SMKRV
2024-12-06 03:14:52 +03:00
parent 0c4399b46c
commit ca3ae982b0
+2 -4
View File
@@ -865,8 +865,7 @@ class HATextAICoordinator(DataUpdateCoordinator):
context_tokens = self._calculate_context_tokens(
[{"content": entry["question"]} for entry in context_history] +
[{"content": entry["response"]} for entry in context_history] +
[{"content": question}],
temp_model
[{"content": question}]
)
# Dynamic token allocation
@@ -886,8 +885,7 @@ class HATextAICoordinator(DataUpdateCoordinator):
context_tokens = self._calculate_context_tokens(
[{"content": entry["question"]} for entry in context_history] +
[{"content": entry["response"]} for entry in context_history] +
[{"content": question}],
temp_model
[{"content": question}]
)
# Rebuild messages with trimmed context