feat: enhance bot configuration with new sections and JSON field hooks
- Added support for new configuration sections: relationship, database, maisaka, mcp, and plugin_runtime. - Introduced complex field hooks for handling JSON configurations in chat talk value rules, expression learning lists, and more. - Updated the field hooks to include schema metadata for better UI representation. - Refactored the bot configuration page to utilize a more dynamic approach for managing section values and state. - Improved the configuration schema generation to ensure all top-level sections have UI metadata. - Added tests to validate the new configuration schema and ensure proper functionality of the JSON field hooks.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import inspect
|
||||
from typing import Any, Dict, List, get_args, get_origin
|
||||
|
||||
import inspect
|
||||
|
||||
from pydantic_core import PydanticUndefined
|
||||
|
||||
from src.config.config_base import ConfigBase
|
||||
@@ -56,7 +57,7 @@ class ConfigSchemaGenerator:
|
||||
if inspect.isclass(annotation) and issubclass(annotation, ConfigBase):
|
||||
return cls.generate_config_schema(annotation)
|
||||
|
||||
if origin in {list, tuple} and args:
|
||||
if origin in {list, set, tuple} and args:
|
||||
first = args[0]
|
||||
if inspect.isclass(first) and issubclass(first, ConfigBase):
|
||||
return cls.generate_config_schema(first)
|
||||
@@ -83,7 +84,7 @@ class ConfigSchemaGenerator:
|
||||
origin = get_origin(annotation)
|
||||
args = get_args(annotation)
|
||||
|
||||
if origin is list and args:
|
||||
if origin in {list, set} and args:
|
||||
schema["items"] = {"type": cls._map_field_type(args[0])}
|
||||
|
||||
if options := cls._extract_options(annotation):
|
||||
@@ -120,7 +121,7 @@ class ConfigSchemaGenerator:
|
||||
origin = get_origin(annotation)
|
||||
args = get_args(annotation)
|
||||
|
||||
if origin in {list, tuple}:
|
||||
if origin in {list, set, tuple}:
|
||||
return "array"
|
||||
if inspect.isclass(annotation) and issubclass(annotation, ConfigBase):
|
||||
return "object"
|
||||
@@ -133,7 +134,7 @@ class ConfigSchemaGenerator:
|
||||
if annotation is str:
|
||||
return "string"
|
||||
|
||||
if origin in {list, tuple} and args:
|
||||
if origin in {list, set, tuple} and args:
|
||||
return "array"
|
||||
|
||||
if origin in {dict}:
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"""WebSocket 路由聚合导出。"""
|
||||
|
||||
from .auth import router as ws_auth_router
|
||||
from .unified import router as unified_ws_router
|
||||
"""WebSocket 路由包。"""
|
||||
|
||||
__all__ = [
|
||||
"unified_ws_router",
|
||||
"ws_auth_router",
|
||||
"auth",
|
||||
"manager",
|
||||
"unified",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user