Break tool config schema import cycle

This commit is contained in:
chengyongru
2026-06-13 21:59:07 +08:00
committed by Xubin Ren
parent 7ff8e02eaf
commit 3a221d74cf
9 changed files with 62 additions and 59 deletions
+4 -10
View File
@@ -4,10 +4,10 @@ from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, model_validator
from pydantic.alias_generators import to_camel
from pydantic import AliasChoices, ConfigDict, Field, model_validator
from pydantic_settings import BaseSettings
from nanobot.config_base import Base
from nanobot.cron.types import CronSchedule
if TYPE_CHECKING:
@@ -18,12 +18,6 @@ if TYPE_CHECKING:
from nanobot.agent.tools.web import WebToolsConfig
class Base(BaseModel):
"""Base model that accepts both camelCase and snake_case keys."""
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
class ChannelsConfig(Base):
"""Configuration for chat channels.
@@ -320,8 +314,8 @@ class ToolsConfig(Base):
"""Tools configuration.
Field types for tool-specific sub-configs are resolved via model_rebuild()
at the bottom of this file to avoid circular imports (tool modules import
Base from schema.py).
at the bottom of this file so tool config classes can stay next to their
tool implementations.
"""
web: WebToolsConfig = Field(default_factory=lambda: _lazy_default("nanobot.agent.tools.web", "WebToolsConfig"))