mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-21 22:54:00 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user