mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 12:13:36 +00:00
docs: use model_dump(by_alias=True) for default_config in plugin guide
This commit is contained in:
parent
83ad013be5
commit
4648cb9e87
@ -69,7 +69,7 @@ class WebhookChannel(BaseChannel):
|
||||
|
||||
@classmethod
|
||||
def default_config(cls) -> dict[str, Any]:
|
||||
return {"enabled": False, "port": 9000, "allowFrom": []}
|
||||
return WebhookConfig().model_dump(by_alias=True)
|
||||
|
||||
async def start(self) -> None:
|
||||
"""Start an HTTP server that listens for incoming messages.
|
||||
@ -401,10 +401,10 @@ Override `default_config()` so `nanobot onboard` auto-populates `config.json`:
|
||||
```python
|
||||
@classmethod
|
||||
def default_config(cls) -> dict[str, Any]:
|
||||
return {"enabled": False, "port": 9000, "allowFrom": []}
|
||||
return WebhookConfig().model_dump(by_alias=True)
|
||||
```
|
||||
|
||||
> **Note:** `default_config()` still returns a plain `dict` (not a Pydantic model) because it's used to serialize into `config.json`. Use camelCase keys (`allowFrom`) to match the JSON convention.
|
||||
> **Note:** `default_config()` returns a plain `dict` (not a Pydantic model) because it's used to serialize into `config.json`. The recommended way is to instantiate your config model and call `model_dump(by_alias=True)` — this automatically uses camelCase keys (`allowFrom`) and keeps defaults in a single source of truth.
|
||||
|
||||
If not overridden, the base class returns `{"enabled": false}`.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user