chore: decrease pool logging

This commit is contained in:
Andy Li
2025-07-22 14:54:22 -07:00
committed by GitHub
parent f44e895d1f
commit 1590e4e3e6
4 changed files with 32 additions and 27 deletions

View File

@@ -25,8 +25,9 @@ DEFAULT_OLLAMA_MODEL = "dolphin2.2-mistral:7b-q6_K"
DEFAULT_WRAPPER = ChatMLInnerMonologueWrapper
DEFAULT_WRAPPER_NAME = "chatml"
INNER_THOUGHTS_KWARG = "thinking" # used to be "inner_thoughts"
INNER_THOUGHTS_KWARG = "thinking"
INNER_THOUGHTS_KWARG_VERTEX = "thinking"
VALID_INNER_THOUGHTS_KWARGS = ("thinking", "inner_thoughts")
INNER_THOUGHTS_KWARG_DESCRIPTION = "Deep inner monologue private to you only."
INNER_THOUGHTS_KWARG_DESCRIPTION_GO_FIRST = f"Deep inner monologue private to you only. Think before you act, so always generate arg '{INNER_THOUGHTS_KWARG}' first before any other arg."
INNER_THOUGHTS_CLI_SYMBOL = "💭"

View File

@@ -78,19 +78,19 @@ def add_missing_heartbeat(llm_json):
def clean_and_interpret_send_message_json(json_string):
from letta.local_llm.constants import INNER_THOUGHTS_KWARG
from letta.local_llm.constants import INNER_THOUGHTS_KWARG, VALID_INNER_THOUGHTS_KWARGS
from letta.settings import model_settings
kwarg = model_settings.inner_thoughts_kwarg
if kwarg not in VALID_INNER_THOUGHTS_KWARGS:
warnings.warn(f"INNER_THOUGHTS_KWARG is not valid: {kwarg}")
kwarg = INNER_THOUGHTS_KWARG
# If normal parsing fails, attempt to clean and extract manually
cleaned_json_string = re.sub(r"[^\x00-\x7F]+", "", json_string) # Remove non-ASCII characters
function_match = re.search(r'"function":\s*"send_message"', cleaned_json_string)
if INNER_THOUGHTS_KWARG == "inner_thoughts":
inner_thoughts_match = re.search(r'"inner_thoughts":\s*"([^"]+)"', cleaned_json_string)
elif INNER_THOUGHTS_KWARG == "thinking":
inner_thoughts_match = re.search(r'"thinking":\s*"([^"]+)"', cleaned_json_string)
else:
warnings.warn(f"INNER_THOUGHTS_KWARG is not valid: {INNER_THOUGHTS_KWARG}")
inner_thoughts_match = re.search(r'"inner_thoughts":\s*"([^"]+)"', cleaned_json_string)
inner_thoughts_match = re.search(rf'"{kwarg}":\s*"([^"]+)"', cleaned_json_string)
message_match = re.search(r'"message":\s*"([^"]+)"', cleaned_json_string)
if function_match and inner_thoughts_match and message_match:

View File

@@ -89,18 +89,18 @@ class DatabasePoolMonitor:
try:
from letta.otel.metric_registry import MetricRegistry
# Record current pool statistics
pool_stats = self._get_pool_stats(pool)
attrs = {
"engine_name": engine_name,
**get_ctx_attributes(),
}
MetricRegistry().db_pool_connections_checked_out_gauge.set(pool_stats["checked_out"], attributes=attrs)
MetricRegistry().db_pool_connections_available_gauge.set(pool_stats["available"], attributes=attrs)
MetricRegistry().db_pool_connections_total_gauge.set(pool_stats["total"], attributes=attrs)
if pool_stats["overflow"] is not None:
MetricRegistry().db_pool_connections_overflow_gauge.set(pool_stats["overflow"], attributes=attrs)
# Record current pool statistics
if isinstance(pool, QueuePool):
pool_stats = self._get_pool_stats(pool)
MetricRegistry().db_pool_connections_checked_out_gauge.set(pool_stats["checked_out"], attributes=attrs)
MetricRegistry().db_pool_connections_available_gauge.set(pool_stats["available"], attributes=attrs)
MetricRegistry().db_pool_connections_total_gauge.set(pool_stats["total"], attributes=attrs)
if pool_stats["overflow"] is not None:
MetricRegistry().db_pool_connections_overflow_gauge.set(pool_stats["overflow"], attributes=attrs)
# Record checkout event
attrs["event"] = "checkout"
@@ -137,15 +137,16 @@ class DatabasePoolMonitor:
try:
from letta.otel.metric_registry import MetricRegistry
# Record current pool statistics after checkin
pool_stats = self._get_pool_stats(pool)
attrs = {
"engine_name": engine_name,
**get_ctx_attributes(),
}
MetricRegistry().db_pool_connections_checked_out_gauge.set(pool_stats["checked_out"], attributes=attrs)
MetricRegistry().db_pool_connections_available_gauge.set(pool_stats["available"], attributes=attrs)
# Record current pool statistics after checkin
if isinstance(pool, QueuePool):
pool_stats = self._get_pool_stats(pool)
MetricRegistry().db_pool_connections_checked_out_gauge.set(pool_stats["checked_out"], attributes=attrs)
MetricRegistry().db_pool_connections_available_gauge.set(pool_stats["available"], attributes=attrs)
# Record checkin event
attrs["event"] = "checkin"

View File

@@ -6,7 +6,7 @@ from typing import Optional
from pydantic import AliasChoices, Field
from pydantic_settings import BaseSettings, SettingsConfigDict
from letta.local_llm.constants import DEFAULT_WRAPPER_NAME
from letta.local_llm.constants import DEFAULT_WRAPPER_NAME, INNER_THOUGHTS_KWARG
from letta.services.summarizer.enums import SummarizationMode
@@ -83,6 +83,8 @@ class ModelSettings(BaseSettings):
global_max_context_window_limit: int = 32000
inner_thoughts_kwarg: str | None = Field(default=INNER_THOUGHTS_KWARG, description="Key used for passing in inner thoughts.")
# env_prefix='my_prefix_'
# when we use /completions APIs (instead of /chat/completions), we need to specify a model wrapper
@@ -150,9 +152,6 @@ class ModelSettings(BaseSettings):
openllm_auth_type: Optional[str] = None
openllm_api_key: Optional[str] = None
# disable openapi schema generation
disable_schema_generation: bool = False
env_cors_origins = os.getenv("ACCEPTABLE_ORIGINS")
@@ -316,12 +315,16 @@ class Settings(BaseSettings):
class TestSettings(Settings):
model_config = SettingsConfigDict(env_prefix="letta_test_", extra="ignore")
letta_dir: Optional[Path] = Field(Path.home() / ".letta/test", env="LETTA_TEST_DIR")
letta_dir: Path | None = Field(Path.home() / ".letta/test", env="LETTA_TEST_DIR")
class LogSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="letta_logging_", extra="ignore")
verbose_telemetry_logging: bool = False
debug: bool | None = Field(False, description="Enable debugging for logging")
json_logging: bool = Field(False, description="Enable json logging instead of text logging")
log_level: str | None = Field("WARNING", description="Logging level")
letta_log_path: Path | None = Field(Path.home() / ".letta" / "logs" / "Letta.log")
verbose_telemetry_logging: bool = Field(False)
# singleton