ctx window popup fix, default settings fix

frdel committed Dec 15, 2024 at 18:01 UTC 9d4e1b68b2ab41eefc534ef1f48953496d7d1cc6
4 files changed +11 -8
agent.py
+3
@@ -271,6 +271,9 @@ class Agent:
271 printer.stream(chunk)
272 self.log_from_stream(full, log)
273
274 + # store as last context window content
275 + self.set_data(Agent.DATA_NAME_CTX_WINDOW, prompt.format())
276 +
277 agent_response = await self.call_chat_model(
278 prompt, callback=stream_callback
279 )
models.py
+3 -3
@@ -83,9 +83,9 @@ def get_rate_limiter(
83 key = f"{provider.name}\\{name}"
84 rate_limiters[key] = limiter = rate_limiters.get(key, RateLimiter(seconds=60))
85 # always update
86 - limiter.limits["requests"] = requests
87 - limiter.limits["input"] = input
88 - limiter.limits["output"] = output
86 + limiter.limits["requests"] = requests or 0
87 + limiter.limits["input"] = input or 0
88 + limiter.limits["output"] = output or 0
89 return limiter
90
91
python/helpers/rate_limiter.py
+2 -2
@@ -6,8 +6,8 @@ from typing import Callable, Awaitable
6 class RateLimiter:
7 def __init__(self, seconds: int = 60, **limits: int):
8 self.timeframe = seconds
9 - self.limits = limits or {}
10 - self.values = {key: [] for key in limits.keys()}
9 + self.limits = {key: value if isinstance(value, (int, float)) else 0 for key, value in (limits or {}).items()}
10 + self.values = {key: [] for key in self.limits.keys()}
11 self._lock = asyncio.Lock()
12
13 def add(self, **kwargs: int):
python/helpers/settings.py
+3 -3
@@ -690,7 +690,7 @@ def normalize_settings(settings: Settings) -> Settings:
690 try:
691 copy[key] = type(value)(copy[key]) # type: ignore
692 except (ValueError, TypeError):
693 - pass
693 + copy[key] = value # make default instead
694 return copy
695
696
@@ -775,7 +775,7 @@ def get_default_settings() -> Settings:
775 return Settings(
776 chat_model_provider=ModelProvider.OPENAI.name,
777 chat_model_name="gpt-4o-mini",
778 - chat_model_temperature=0,
778 + chat_model_temperature=0.0,
779 chat_model_kwargs={},
780 chat_model_ctx_length=120000,
781 chat_model_ctx_history=0.7,
@@ -784,7 +784,7 @@ def get_default_settings() -> Settings:
784 chat_model_rl_output=0,
785 util_model_provider=ModelProvider.OPENAI.name,
786 util_model_name="gpt-4o-mini",
787 - util_model_temperature=0,
787 + util_model_temperature=0.0,
788 util_model_ctx_length=120000,
789 util_model_ctx_input=0.7,
790 util_model_kwargs={},